@openclaw/openshell-sandbox 2026.9.1 → 2026.9.3
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/dist/index.js +87 -47
- package/node_modules/@openclaw/fs-safe/CHANGELOG.md +700 -0
- package/node_modules/@openclaw/fs-safe/LICENSE +21 -0
- package/node_modules/@openclaw/fs-safe/README.md +564 -0
- package/node_modules/@openclaw/fs-safe/SECURITY.md +45 -0
- package/node_modules/@openclaw/fs-safe/dist/absolute-path.d.ts +33 -0
- package/node_modules/@openclaw/fs-safe/dist/absolute-path.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/absolute-path.js +307 -0
- package/node_modules/@openclaw/fs-safe/dist/advanced.d.ts +26 -0
- package/node_modules/@openclaw/fs-safe/dist/advanced.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/advanced.js +28 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-crc32.d.ts +2 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-crc32.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-crc32.js +14 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-deadline.d.ts +12 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-deadline.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-deadline.js +103 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-entry.d.ts +14 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-entry.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-entry.js +85 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-errors.d.ts +13 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-errors.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-errors.js +23 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-gzip-tail.d.ts +18 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-gzip-tail.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-gzip-tail.js +74 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-input.d.ts +19 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-input.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-input.js +92 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-kind.d.ts +9 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-kind.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-kind.js +82 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-limits.d.ts +57 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-limits.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-limits.js +131 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-merge.d.ts +18 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-merge.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-merge.js +157 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-native.d.ts +20 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-native.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-native.js +107 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-options.d.ts +21 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-options.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-options.js +1 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-parser-errors.d.ts +2 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-parser-errors.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-parser-errors.js +12 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-parser.wasm +0 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-plan.d.ts +20 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-plan.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-plan.js +55 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-policy.d.ts +22 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-policy.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-policy.js +38 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-read.d.ts +6 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-read.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-read.js +225 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-staging.d.ts +31 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-staging.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-staging.js +250 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-tar-inspect.d.ts +7 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-tar-inspect.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-tar-inspect.js +59 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-tar-stream.d.ts +18 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-tar-stream.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-tar-stream.js +95 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-tar-wasm.d.ts +18 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-tar-wasm.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-tar-wasm.js +99 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-tar.d.ts +19 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-tar.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-tar.js +21 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-zip-admission.d.ts +8 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-zip-admission.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-zip-admission.js +60 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-zip-count.d.ts +2 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-zip-count.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-zip-count.js +140 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-zip-directory.d.ts +15 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-zip-directory.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-zip-directory.js +228 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-zip-entry.d.ts +21 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-zip-entry.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-zip-entry.js +27 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-zip-integrity.d.ts +5 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-zip-integrity.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-zip-integrity.js +41 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-zip-names.d.ts +12 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-zip-names.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-zip-names.js +100 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-zip-preflight.d.ts +7 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-zip-preflight.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-zip-preflight.js +44 -0
- package/node_modules/@openclaw/fs-safe/dist/archive.d.ts +15 -0
- package/node_modules/@openclaw/fs-safe/dist/archive.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/archive.js +275 -0
- package/node_modules/@openclaw/fs-safe/dist/async-lock.d.ts +2 -0
- package/node_modules/@openclaw/fs-safe/dist/async-lock.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/async-lock.js +17 -0
- package/node_modules/@openclaw/fs-safe/dist/atomic.d.ts +5 -0
- package/node_modules/@openclaw/fs-safe/dist/atomic.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/atomic.js +4 -0
- package/node_modules/@openclaw/fs-safe/dist/bounded-read-stream.d.ts +4 -0
- package/node_modules/@openclaw/fs-safe/dist/bounded-read-stream.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/bounded-read-stream.js +21 -0
- package/node_modules/@openclaw/fs-safe/dist/bounded-read.d.ts +14 -0
- package/node_modules/@openclaw/fs-safe/dist/bounded-read.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/bounded-read.js +106 -0
- package/node_modules/@openclaw/fs-safe/dist/byte-budget.d.ts +4 -0
- package/node_modules/@openclaw/fs-safe/dist/byte-budget.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/byte-budget.js +9 -0
- package/node_modules/@openclaw/fs-safe/dist/config.d.ts +3 -0
- package/node_modules/@openclaw/fs-safe/dist/config.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/config.js +2 -0
- package/node_modules/@openclaw/fs-safe/dist/containment.d.ts +2 -0
- package/node_modules/@openclaw/fs-safe/dist/containment.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/containment.js +1 -0
- package/node_modules/@openclaw/fs-safe/dist/deny-mutations.d.ts +12 -0
- package/node_modules/@openclaw/fs-safe/dist/deny-mutations.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/deny-mutations.js +69 -0
- package/node_modules/@openclaw/fs-safe/dist/device-path.d.ts +15 -0
- package/node_modules/@openclaw/fs-safe/dist/device-path.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/device-path.js +137 -0
- package/node_modules/@openclaw/fs-safe/dist/directory-durability.d.ts +44 -0
- package/node_modules/@openclaw/fs-safe/dist/directory-durability.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/directory-durability.js +299 -0
- package/node_modules/@openclaw/fs-safe/dist/directory-guard.d.ts +31 -0
- package/node_modules/@openclaw/fs-safe/dist/directory-guard.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/directory-guard.js +82 -0
- package/node_modules/@openclaw/fs-safe/dist/directory-mode-node.d.ts +8 -0
- package/node_modules/@openclaw/fs-safe/dist/directory-mode-node.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/directory-mode-node.js +93 -0
- package/node_modules/@openclaw/fs-safe/dist/directory-mode-owner.d.ts +21 -0
- package/node_modules/@openclaw/fs-safe/dist/directory-mode-owner.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/directory-mode-owner.js +78 -0
- package/node_modules/@openclaw/fs-safe/dist/durability.d.ts +4 -0
- package/node_modules/@openclaw/fs-safe/dist/durability.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/durability.js +3 -0
- package/node_modules/@openclaw/fs-safe/dist/error-detail.d.ts +3 -0
- package/node_modules/@openclaw/fs-safe/dist/error-detail.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/error-detail.js +10 -0
- package/node_modules/@openclaw/fs-safe/dist/errors.d.ts +14 -0
- package/node_modules/@openclaw/fs-safe/dist/errors.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/errors.js +26 -0
- package/node_modules/@openclaw/fs-safe/dist/file-hash.d.ts +10 -0
- package/node_modules/@openclaw/fs-safe/dist/file-hash.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/file-hash.js +73 -0
- package/node_modules/@openclaw/fs-safe/dist/file-identity.d.ts +8 -0
- package/node_modules/@openclaw/fs-safe/dist/file-identity.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/file-identity.js +34 -0
- package/node_modules/@openclaw/fs-safe/dist/file-lock-sync.d.ts +35 -0
- package/node_modules/@openclaw/fs-safe/dist/file-lock-sync.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/file-lock-sync.js +349 -0
- package/node_modules/@openclaw/fs-safe/dist/file-lock.d.ts +24 -0
- package/node_modules/@openclaw/fs-safe/dist/file-lock.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/file-lock.js +46 -0
- package/node_modules/@openclaw/fs-safe/dist/file-observation.d.ts +9 -0
- package/node_modules/@openclaw/fs-safe/dist/file-observation.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/file-observation.js +22 -0
- package/node_modules/@openclaw/fs-safe/dist/file-store-boundary.d.ts +33 -0
- package/node_modules/@openclaw/fs-safe/dist/file-store-boundary.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/file-store-boundary.js +189 -0
- package/node_modules/@openclaw/fs-safe/dist/file-store-limit.d.ts +2 -0
- package/node_modules/@openclaw/fs-safe/dist/file-store-limit.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/file-store-limit.js +8 -0
- package/node_modules/@openclaw/fs-safe/dist/file-store-prune.d.ts +12 -0
- package/node_modules/@openclaw/fs-safe/dist/file-store-prune.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/file-store-prune.js +95 -0
- package/node_modules/@openclaw/fs-safe/dist/file-store-sync-write.d.ts +9 -0
- package/node_modules/@openclaw/fs-safe/dist/file-store-sync-write.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/file-store-sync-write.js +127 -0
- package/node_modules/@openclaw/fs-safe/dist/file-store.d.ts +62 -0
- package/node_modules/@openclaw/fs-safe/dist/file-store.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/file-store.js +357 -0
- package/node_modules/@openclaw/fs-safe/dist/file-sync.d.ts +5 -0
- package/node_modules/@openclaw/fs-safe/dist/file-sync.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/file-sync.js +19 -0
- package/node_modules/@openclaw/fs-safe/dist/filename.d.ts +8 -0
- package/node_modules/@openclaw/fs-safe/dist/filename.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/filename.js +91 -0
- package/node_modules/@openclaw/fs-safe/dist/fs.d.ts +13 -0
- package/node_modules/@openclaw/fs-safe/dist/fs.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/fs.js +30 -0
- package/node_modules/@openclaw/fs-safe/dist/guarded-mkdir.d.ts +14 -0
- package/node_modules/@openclaw/fs-safe/dist/guarded-mkdir.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/guarded-mkdir.js +87 -0
- package/node_modules/@openclaw/fs-safe/dist/guarded-mutation.d.ts +37 -0
- package/node_modules/@openclaw/fs-safe/dist/guarded-mutation.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/guarded-mutation.js +82 -0
- package/node_modules/@openclaw/fs-safe/dist/home-dir.d.ts +12 -0
- package/node_modules/@openclaw/fs-safe/dist/home-dir.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/home-dir.js +84 -0
- package/node_modules/@openclaw/fs-safe/dist/index.d.ts +7 -0
- package/node_modules/@openclaw/fs-safe/dist/index.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/index.js +5 -0
- package/node_modules/@openclaw/fs-safe/dist/install-path.d.ts +20 -0
- package/node_modules/@openclaw/fs-safe/dist/install-path.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/install-path.js +94 -0
- package/node_modules/@openclaw/fs-safe/dist/json-document-store.d.ts +35 -0
- package/node_modules/@openclaw/fs-safe/dist/json-document-store.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/json-document-store.js +97 -0
- package/node_modules/@openclaw/fs-safe/dist/json-durable-queue-directory.d.ts +2 -0
- package/node_modules/@openclaw/fs-safe/dist/json-durable-queue-directory.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/json-durable-queue-directory.js +20 -0
- package/node_modules/@openclaw/fs-safe/dist/json-durable-queue-ownership.d.ts +17 -0
- package/node_modules/@openclaw/fs-safe/dist/json-durable-queue-ownership.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/json-durable-queue-ownership.js +292 -0
- package/node_modules/@openclaw/fs-safe/dist/json-durable-queue.d.ts +46 -0
- package/node_modules/@openclaw/fs-safe/dist/json-durable-queue.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/json-durable-queue.js +383 -0
- package/node_modules/@openclaw/fs-safe/dist/json-store.d.ts +9 -0
- package/node_modules/@openclaw/fs-safe/dist/json-store.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/json-store.js +12 -0
- package/node_modules/@openclaw/fs-safe/dist/json-stringify.d.ts +2 -0
- package/node_modules/@openclaw/fs-safe/dist/json-stringify.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/json-stringify.js +7 -0
- package/node_modules/@openclaw/fs-safe/dist/json.d.ts +50 -0
- package/node_modules/@openclaw/fs-safe/dist/json.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/json.js +343 -0
- package/node_modules/@openclaw/fs-safe/dist/local-file-access.d.ts +9 -0
- package/node_modules/@openclaw/fs-safe/dist/local-file-access.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/local-file-access.js +87 -0
- package/node_modules/@openclaw/fs-safe/dist/local-roots.d.ts +26 -0
- package/node_modules/@openclaw/fs-safe/dist/local-roots.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/local-roots.js +135 -0
- package/node_modules/@openclaw/fs-safe/dist/lock-config.d.ts +10 -0
- package/node_modules/@openclaw/fs-safe/dist/lock-config.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/lock-config.js +12 -0
- package/node_modules/@openclaw/fs-safe/dist/move-path-cleanup.d.ts +43 -0
- package/node_modules/@openclaw/fs-safe/dist/move-path-cleanup.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/move-path-cleanup.js +161 -0
- package/node_modules/@openclaw/fs-safe/dist/move-path.d.ts +21 -0
- package/node_modules/@openclaw/fs-safe/dist/move-path.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/move-path.js +334 -0
- package/node_modules/@openclaw/fs-safe/dist/native-binding.d.ts +93 -0
- package/node_modules/@openclaw/fs-safe/dist/native-binding.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/native-binding.js +1 -0
- package/node_modules/@openclaw/fs-safe/dist/native-config.d.ts +17 -0
- package/node_modules/@openclaw/fs-safe/dist/native-config.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/native-config.js +71 -0
- package/node_modules/@openclaw/fs-safe/dist/native-operations.d.ts +21 -0
- package/node_modules/@openclaw/fs-safe/dist/native-operations.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/native-operations.js +132 -0
- package/node_modules/@openclaw/fs-safe/dist/native-pinned-write-windows.d.ts +8 -0
- package/node_modules/@openclaw/fs-safe/dist/native-pinned-write-windows.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/native-pinned-write-windows.js +96 -0
- package/node_modules/@openclaw/fs-safe/dist/native-pinned-write.d.ts +5 -0
- package/node_modules/@openclaw/fs-safe/dist/native-pinned-write.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/native-pinned-write.js +161 -0
- package/node_modules/@openclaw/fs-safe/dist/native-staged-file.d.ts +31 -0
- package/node_modules/@openclaw/fs-safe/dist/native-staged-file.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/native-staged-file.js +362 -0
- package/node_modules/@openclaw/fs-safe/dist/native.d.ts +14 -0
- package/node_modules/@openclaw/fs-safe/dist/native.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/native.js +204 -0
- package/node_modules/@openclaw/fs-safe/dist/opened-file-failure.d.ts +8 -0
- package/node_modules/@openclaw/fs-safe/dist/opened-file-failure.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/opened-file-failure.js +45 -0
- package/node_modules/@openclaw/fs-safe/dist/opened-realpath.d.ts +16 -0
- package/node_modules/@openclaw/fs-safe/dist/opened-realpath.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/opened-realpath.js +92 -0
- package/node_modules/@openclaw/fs-safe/dist/output.d.ts +15 -0
- package/node_modules/@openclaw/fs-safe/dist/output.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/output.js +123 -0
- package/node_modules/@openclaw/fs-safe/dist/owner-dacl.d.ts +31 -0
- package/node_modules/@openclaw/fs-safe/dist/owner-dacl.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/owner-dacl.js +28 -0
- package/node_modules/@openclaw/fs-safe/dist/path-policy.d.ts +25 -0
- package/node_modules/@openclaw/fs-safe/dist/path-policy.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/path-policy.js +44 -0
- package/node_modules/@openclaw/fs-safe/dist/path.d.ts +21 -0
- package/node_modules/@openclaw/fs-safe/dist/path.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/path.js +136 -0
- package/node_modules/@openclaw/fs-safe/dist/permission-exec.d.ts +25 -0
- package/node_modules/@openclaw/fs-safe/dist/permission-exec.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/permission-exec.js +74 -0
- package/node_modules/@openclaw/fs-safe/dist/permissions-public.d.ts +4 -0
- package/node_modules/@openclaw/fs-safe/dist/permissions-public.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/permissions-public.js +3 -0
- package/node_modules/@openclaw/fs-safe/dist/permissions-windows.d.ts +59 -0
- package/node_modules/@openclaw/fs-safe/dist/permissions-windows.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/permissions-windows.js +296 -0
- package/node_modules/@openclaw/fs-safe/dist/permissions.d.ts +60 -0
- package/node_modules/@openclaw/fs-safe/dist/permissions.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/permissions.js +125 -0
- package/node_modules/@openclaw/fs-safe/dist/pinned-open.d.ts +24 -0
- package/node_modules/@openclaw/fs-safe/dist/pinned-open.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/pinned-open.js +74 -0
- package/node_modules/@openclaw/fs-safe/dist/pinned-operation.d.ts +2 -0
- package/node_modules/@openclaw/fs-safe/dist/pinned-operation.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/pinned-operation.js +35 -0
- package/node_modules/@openclaw/fs-safe/dist/pinned-write.d.ts +36 -0
- package/node_modules/@openclaw/fs-safe/dist/pinned-write.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/pinned-write.js +252 -0
- package/node_modules/@openclaw/fs-safe/dist/private-directory.d.ts +5 -0
- package/node_modules/@openclaw/fs-safe/dist/private-directory.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/private-directory.js +14 -0
- package/node_modules/@openclaw/fs-safe/dist/private-temp-workspace.d.ts +45 -0
- package/node_modules/@openclaw/fs-safe/dist/private-temp-workspace.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/private-temp-workspace.js +299 -0
- package/node_modules/@openclaw/fs-safe/dist/publish-file-failure.d.ts +28 -0
- package/node_modules/@openclaw/fs-safe/dist/publish-file-failure.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/publish-file-failure.js +22 -0
- package/node_modules/@openclaw/fs-safe/dist/publish-file.d.ts +21 -0
- package/node_modules/@openclaw/fs-safe/dist/publish-file.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/publish-file.js +366 -0
- package/node_modules/@openclaw/fs-safe/dist/read-open-flags.d.ts +8 -0
- package/node_modules/@openclaw/fs-safe/dist/read-open-flags.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/read-open-flags.js +13 -0
- package/node_modules/@openclaw/fs-safe/dist/read-opened-file.d.ts +21 -0
- package/node_modules/@openclaw/fs-safe/dist/read-opened-file.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/read-opened-file.js +18 -0
- package/node_modules/@openclaw/fs-safe/dist/regular-file.d.ts +38 -0
- package/node_modules/@openclaw/fs-safe/dist/regular-file.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/regular-file.js +391 -0
- package/node_modules/@openclaw/fs-safe/dist/replace-directory.d.ts +7 -0
- package/node_modules/@openclaw/fs-safe/dist/replace-directory.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/replace-directory.js +42 -0
- package/node_modules/@openclaw/fs-safe/dist/replace-file-copy-fallback.d.ts +39 -0
- package/node_modules/@openclaw/fs-safe/dist/replace-file-copy-fallback.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/replace-file-copy-fallback.js +331 -0
- package/node_modules/@openclaw/fs-safe/dist/replace-file-copy-source.d.ts +21 -0
- package/node_modules/@openclaw/fs-safe/dist/replace-file-copy-source.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/replace-file-copy-source.js +107 -0
- package/node_modules/@openclaw/fs-safe/dist/replace-file-descriptor.d.ts +51 -0
- package/node_modules/@openclaw/fs-safe/dist/replace-file-descriptor.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/replace-file-descriptor.js +161 -0
- package/node_modules/@openclaw/fs-safe/dist/replace-file-rename-policy.d.ts +7 -0
- package/node_modules/@openclaw/fs-safe/dist/replace-file-rename-policy.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/replace-file-rename-policy.js +30 -0
- package/node_modules/@openclaw/fs-safe/dist/replace-file-temp-owner.d.ts +53 -0
- package/node_modules/@openclaw/fs-safe/dist/replace-file-temp-owner.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/replace-file-temp-owner.js +376 -0
- package/node_modules/@openclaw/fs-safe/dist/replace-file.d.ts +58 -0
- package/node_modules/@openclaw/fs-safe/dist/replace-file.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/replace-file.js +329 -0
- package/node_modules/@openclaw/fs-safe/dist/root-context.d.ts +38 -0
- package/node_modules/@openclaw/fs-safe/dist/root-context.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/root-context.js +141 -0
- package/node_modules/@openclaw/fs-safe/dist/root-errors.d.ts +12 -0
- package/node_modules/@openclaw/fs-safe/dist/root-errors.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/root-errors.js +75 -0
- package/node_modules/@openclaw/fs-safe/dist/root-file.d.ts +45 -0
- package/node_modules/@openclaw/fs-safe/dist/root-file.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/root-file.js +120 -0
- package/node_modules/@openclaw/fs-safe/dist/root-impl.d.ts +163 -0
- package/node_modules/@openclaw/fs-safe/dist/root-impl.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/root-impl.js +1230 -0
- package/node_modules/@openclaw/fs-safe/dist/root-path-existing.d.ts +3 -0
- package/node_modules/@openclaw/fs-safe/dist/root-path-existing.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/root-path-existing.js +68 -0
- package/node_modules/@openclaw/fs-safe/dist/root-path-symlink.d.ts +7 -0
- package/node_modules/@openclaw/fs-safe/dist/root-path-symlink.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/root-path-symlink.js +35 -0
- package/node_modules/@openclaw/fs-safe/dist/root-path.d.ts +40 -0
- package/node_modules/@openclaw/fs-safe/dist/root-path.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/root-path.js +481 -0
- package/node_modules/@openclaw/fs-safe/dist/root-paths.d.ts +89 -0
- package/node_modules/@openclaw/fs-safe/dist/root-paths.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/root-paths.js +381 -0
- package/node_modules/@openclaw/fs-safe/dist/root-walk.d.ts +41 -0
- package/node_modules/@openclaw/fs-safe/dist/root-walk.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/root-walk.js +133 -0
- package/node_modules/@openclaw/fs-safe/dist/root-write-mode.d.ts +6 -0
- package/node_modules/@openclaw/fs-safe/dist/root-write-mode.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/root-write-mode.js +61 -0
- package/node_modules/@openclaw/fs-safe/dist/root-write-verification.d.ts +12 -0
- package/node_modules/@openclaw/fs-safe/dist/root-write-verification.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/root-write-verification.js +97 -0
- package/node_modules/@openclaw/fs-safe/dist/root.d.ts +4 -0
- package/node_modules/@openclaw/fs-safe/dist/root.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/root.js +1 -0
- package/node_modules/@openclaw/fs-safe/dist/safe-path-segment.d.ts +12 -0
- package/node_modules/@openclaw/fs-safe/dist/safe-path-segment.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/safe-path-segment.js +75 -0
- package/node_modules/@openclaw/fs-safe/dist/secret-file.d.ts +25 -0
- package/node_modules/@openclaw/fs-safe/dist/secret-file.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/secret-file.js +329 -0
- package/node_modules/@openclaw/fs-safe/dist/secret-read-async.d.ts +4 -0
- package/node_modules/@openclaw/fs-safe/dist/secret-read-async.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/secret-read-async.js +73 -0
- package/node_modules/@openclaw/fs-safe/dist/secret-read-policy.d.ts +17 -0
- package/node_modules/@openclaw/fs-safe/dist/secret-read-policy.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/secret-read-policy.js +40 -0
- package/node_modules/@openclaw/fs-safe/dist/secret.d.ts +4 -0
- package/node_modules/@openclaw/fs-safe/dist/secret.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/secret.js +3 -0
- package/node_modules/@openclaw/fs-safe/dist/secure-file.d.ts +32 -0
- package/node_modules/@openclaw/fs-safe/dist/secure-file.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/secure-file.js +182 -0
- package/node_modules/@openclaw/fs-safe/dist/secure-temp-dir.d.ts +27 -0
- package/node_modules/@openclaw/fs-safe/dist/secure-temp-dir.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/secure-temp-dir.js +160 -0
- package/node_modules/@openclaw/fs-safe/dist/sibling-staged-file.d.ts +15 -0
- package/node_modules/@openclaw/fs-safe/dist/sibling-staged-file.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/sibling-staged-file.js +143 -0
- package/node_modules/@openclaw/fs-safe/dist/sibling-temp.d.ts +27 -0
- package/node_modules/@openclaw/fs-safe/dist/sibling-temp.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/sibling-temp.js +95 -0
- package/node_modules/@openclaw/fs-safe/dist/sidecar-lock-acquire.d.ts +31 -0
- package/node_modules/@openclaw/fs-safe/dist/sidecar-lock-acquire.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/sidecar-lock-acquire.js +336 -0
- package/node_modules/@openclaw/fs-safe/dist/sidecar-lock-handle.d.ts +24 -0
- package/node_modules/@openclaw/fs-safe/dist/sidecar-lock-handle.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/sidecar-lock-handle.js +42 -0
- package/node_modules/@openclaw/fs-safe/dist/sidecar-lock-policy.d.ts +14 -0
- package/node_modules/@openclaw/fs-safe/dist/sidecar-lock-policy.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/sidecar-lock-policy.js +71 -0
- package/node_modules/@openclaw/fs-safe/dist/sidecar-lock-reclaim.d.ts +63 -0
- package/node_modules/@openclaw/fs-safe/dist/sidecar-lock-reclaim.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/sidecar-lock-reclaim.js +305 -0
- package/node_modules/@openclaw/fs-safe/dist/sidecar-lock-root.d.ts +3 -0
- package/node_modules/@openclaw/fs-safe/dist/sidecar-lock-root.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/sidecar-lock-root.js +76 -0
- package/node_modules/@openclaw/fs-safe/dist/sidecar-lock-types.d.ts +63 -0
- package/node_modules/@openclaw/fs-safe/dist/sidecar-lock-types.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/sidecar-lock-types.js +1 -0
- package/node_modules/@openclaw/fs-safe/dist/sidecar-lock.d.ts +14 -0
- package/node_modules/@openclaw/fs-safe/dist/sidecar-lock.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/sidecar-lock.js +265 -0
- package/node_modules/@openclaw/fs-safe/dist/staged-directory.d.ts +16 -0
- package/node_modules/@openclaw/fs-safe/dist/staged-directory.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/staged-directory.js +60 -0
- package/node_modules/@openclaw/fs-safe/dist/staged-file-types.d.ts +56 -0
- package/node_modules/@openclaw/fs-safe/dist/staged-file-types.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/staged-file-types.js +1 -0
- package/node_modules/@openclaw/fs-safe/dist/store.d.ts +4 -0
- package/node_modules/@openclaw/fs-safe/dist/store.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/store.js +3 -0
- package/node_modules/@openclaw/fs-safe/dist/strict-file-identity.d.ts +6 -0
- package/node_modules/@openclaw/fs-safe/dist/strict-file-identity.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/strict-file-identity.js +51 -0
- package/node_modules/@openclaw/fs-safe/dist/string-coerce.d.ts +5 -0
- package/node_modules/@openclaw/fs-safe/dist/string-coerce.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/string-coerce.js +16 -0
- package/node_modules/@openclaw/fs-safe/dist/suppressed-error.d.ts +6 -0
- package/node_modules/@openclaw/fs-safe/dist/suppressed-error.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/suppressed-error.js +15 -0
- package/node_modules/@openclaw/fs-safe/dist/symlink-parents.d.ts +12 -0
- package/node_modules/@openclaw/fs-safe/dist/symlink-parents.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/symlink-parents.js +78 -0
- package/node_modules/@openclaw/fs-safe/dist/temp-cleanup.d.ts +14 -0
- package/node_modules/@openclaw/fs-safe/dist/temp-cleanup.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/temp-cleanup.js +87 -0
- package/node_modules/@openclaw/fs-safe/dist/temp-target.d.ts +28 -0
- package/node_modules/@openclaw/fs-safe/dist/temp-target.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/temp-target.js +137 -0
- package/node_modules/@openclaw/fs-safe/dist/temp-workspace-owner.d.ts +23 -0
- package/node_modules/@openclaw/fs-safe/dist/temp-workspace-owner.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/temp-workspace-owner.js +320 -0
- package/node_modules/@openclaw/fs-safe/dist/temp.d.ts +4 -0
- package/node_modules/@openclaw/fs-safe/dist/temp.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/temp.js +2 -0
- package/node_modules/@openclaw/fs-safe/dist/test-hooks.d.ts +25 -0
- package/node_modules/@openclaw/fs-safe/dist/test-hooks.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/test-hooks.js +13 -0
- package/node_modules/@openclaw/fs-safe/dist/text-atomic.d.ts +14 -0
- package/node_modules/@openclaw/fs-safe/dist/text-atomic.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/text-atomic.js +14 -0
- package/node_modules/@openclaw/fs-safe/dist/timing.d.ts +8 -0
- package/node_modules/@openclaw/fs-safe/dist/timing.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/timing.js +40 -0
- package/node_modules/@openclaw/fs-safe/dist/trash.d.ts +5 -0
- package/node_modules/@openclaw/fs-safe/dist/trash.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/trash.js +171 -0
- package/node_modules/@openclaw/fs-safe/dist/types.d.ts +23 -0
- package/node_modules/@openclaw/fs-safe/dist/types.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/types.js +1 -0
- package/node_modules/@openclaw/fs-safe/dist/walk.d.ts +37 -0
- package/node_modules/@openclaw/fs-safe/dist/walk.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/walk.js +207 -0
- package/node_modules/@openclaw/fs-safe/dist/windows-command.d.ts +2 -0
- package/node_modules/@openclaw/fs-safe/dist/windows-command.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/windows-command.js +34 -0
- package/node_modules/@openclaw/fs-safe/dist/windows-owner.d.ts +32 -0
- package/node_modules/@openclaw/fs-safe/dist/windows-owner.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/windows-owner.js +126 -0
- package/node_modules/@openclaw/fs-safe/dist/write-open-flags.d.ts +5 -0
- package/node_modules/@openclaw/fs-safe/dist/write-open-flags.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/write-open-flags.js +35 -0
- package/node_modules/@openclaw/fs-safe/dist/write-queue.d.ts +2 -0
- package/node_modules/@openclaw/fs-safe/dist/write-queue.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/write-queue.js +18 -0
- package/node_modules/@openclaw/fs-safe/docs/advanced.md +153 -0
- package/node_modules/@openclaw/fs-safe/docs/archive.md +658 -0
- package/node_modules/@openclaw/fs-safe/docs/assets/readme-banner.jpg +0 -0
- package/node_modules/@openclaw/fs-safe/docs/atomic.md +334 -0
- package/node_modules/@openclaw/fs-safe/docs/config.md +131 -0
- package/node_modules/@openclaw/fs-safe/docs/contributing.md +180 -0
- package/node_modules/@openclaw/fs-safe/docs/durability.md +313 -0
- package/node_modules/@openclaw/fs-safe/docs/errors.md +232 -0
- package/node_modules/@openclaw/fs-safe/docs/file-store.md +258 -0
- package/node_modules/@openclaw/fs-safe/docs/filename.md +96 -0
- package/node_modules/@openclaw/fs-safe/docs/index.md +84 -0
- package/node_modules/@openclaw/fs-safe/docs/install-path.md +170 -0
- package/node_modules/@openclaw/fs-safe/docs/install.md +163 -0
- package/node_modules/@openclaw/fs-safe/docs/json-store.md +221 -0
- package/node_modules/@openclaw/fs-safe/docs/json.md +213 -0
- package/node_modules/@openclaw/fs-safe/docs/local-roots.md +141 -0
- package/node_modules/@openclaw/fs-safe/docs/migrating-to-0.5.md +196 -0
- package/node_modules/@openclaw/fs-safe/docs/migrating-to-0.6.md +43 -0
- package/node_modules/@openclaw/fs-safe/docs/native-helper.md +118 -0
- package/node_modules/@openclaw/fs-safe/docs/native.md +196 -0
- package/node_modules/@openclaw/fs-safe/docs/output.md +139 -0
- package/node_modules/@openclaw/fs-safe/docs/path-scope.md +159 -0
- package/node_modules/@openclaw/fs-safe/docs/path.md +208 -0
- package/node_modules/@openclaw/fs-safe/docs/permissions.md +200 -0
- package/node_modules/@openclaw/fs-safe/docs/private-file-store.md +54 -0
- package/node_modules/@openclaw/fs-safe/docs/public-api.md +112 -0
- package/node_modules/@openclaw/fs-safe/docs/quickstart.md +154 -0
- package/node_modules/@openclaw/fs-safe/docs/reading.md +183 -0
- package/node_modules/@openclaw/fs-safe/docs/regular-file.md +190 -0
- package/node_modules/@openclaw/fs-safe/docs/root.md +266 -0
- package/node_modules/@openclaw/fs-safe/docs/secret-file.md +273 -0
- package/node_modules/@openclaw/fs-safe/docs/secure-file.md +100 -0
- package/node_modules/@openclaw/fs-safe/docs/security-model.md +188 -0
- package/node_modules/@openclaw/fs-safe/docs/sidecar-lock.md +439 -0
- package/node_modules/@openclaw/fs-safe/docs/staged-file.md +182 -0
- package/node_modules/@openclaw/fs-safe/docs/store.md +94 -0
- package/node_modules/@openclaw/fs-safe/docs/temp.md +476 -0
- package/node_modules/@openclaw/fs-safe/docs/test-hooks.md +96 -0
- package/node_modules/@openclaw/fs-safe/docs/testing.md +189 -0
- package/node_modules/@openclaw/fs-safe/docs/timing.md +121 -0
- package/node_modules/@openclaw/fs-safe/docs/types.md +188 -0
- package/node_modules/@openclaw/fs-safe/docs/walk.md +128 -0
- package/node_modules/@openclaw/fs-safe/docs/writing.md +347 -0
- package/node_modules/@openclaw/fs-safe/package.json +187 -0
- package/node_modules/@openclaw/fs-safe-darwin-arm64/fs-safe-native.node +0 -0
- package/node_modules/@openclaw/fs-safe-darwin-arm64/package.json +29 -0
- package/node_modules/@openclaw/fs-safe-darwin-x64/fs-safe-native.node +0 -0
- package/node_modules/@openclaw/fs-safe-darwin-x64/package.json +29 -0
- package/node_modules/@openclaw/fs-safe-linux-arm64-gnu/fs-safe-native.node +0 -0
- package/node_modules/@openclaw/fs-safe-linux-arm64-gnu/package.json +32 -0
- package/node_modules/@openclaw/fs-safe-linux-arm64-musl/fs-safe-native.node +0 -0
- package/node_modules/@openclaw/fs-safe-linux-arm64-musl/package.json +32 -0
- package/node_modules/@openclaw/fs-safe-linux-x64-gnu/fs-safe-native.node +0 -0
- package/node_modules/@openclaw/fs-safe-linux-x64-gnu/package.json +32 -0
- package/node_modules/@openclaw/fs-safe-linux-x64-musl/fs-safe-native.node +0 -0
- package/node_modules/@openclaw/fs-safe-linux-x64-musl/package.json +32 -0
- package/node_modules/@openclaw/fs-safe-win32-x64-msvc/fs-safe-native.node +0 -0
- package/node_modules/@openclaw/fs-safe-win32-x64-msvc/package.json +29 -0
- package/node_modules/core-util-is/LICENSE +19 -0
- package/node_modules/core-util-is/README.md +3 -0
- package/node_modules/core-util-is/lib/util.js +107 -0
- package/node_modules/core-util-is/package.json +38 -0
- package/node_modules/immediate/LICENSE.txt +20 -0
- package/node_modules/immediate/README.md +93 -0
- package/node_modules/immediate/dist/immediate.js +75 -0
- package/node_modules/immediate/dist/immediate.min.js +1 -0
- package/node_modules/immediate/lib/browser.js +69 -0
- package/node_modules/immediate/lib/index.js +73 -0
- package/node_modules/immediate/package.json +42 -0
- package/node_modules/inherits/LICENSE +16 -0
- package/node_modules/inherits/README.md +42 -0
- package/node_modules/inherits/inherits.js +9 -0
- package/node_modules/inherits/inherits_browser.js +27 -0
- package/node_modules/inherits/package.json +29 -0
- package/node_modules/isarray/.npmignore +1 -0
- package/node_modules/isarray/.travis.yml +4 -0
- package/node_modules/isarray/Makefile +6 -0
- package/node_modules/isarray/README.md +60 -0
- package/node_modules/isarray/component.json +19 -0
- package/node_modules/isarray/index.js +5 -0
- package/node_modules/isarray/package.json +45 -0
- package/node_modules/isarray/test.js +20 -0
- package/node_modules/jszip/.codeclimate.yml +16 -0
- package/node_modules/jszip/.editorconfig +8 -0
- package/node_modules/jszip/.eslintrc.js +43 -0
- package/node_modules/jszip/.github/workflows/pr.yaml +58 -0
- package/node_modules/jszip/.jekyll-metadata +0 -0
- package/node_modules/jszip/.travis.yml +17 -0
- package/node_modules/jszip/CHANGES.md +204 -0
- package/node_modules/jszip/LICENSE.markdown +651 -0
- package/node_modules/jszip/README.markdown +33 -0
- package/node_modules/jszip/deps.js +37 -0
- package/node_modules/jszip/dist/jszip.js +11577 -0
- package/node_modules/jszip/dist/jszip.min.js +13 -0
- package/node_modules/jszip/graph.svg +601 -0
- package/node_modules/jszip/index.d.ts +330 -0
- package/node_modules/jszip/lib/base64.js +106 -0
- package/node_modules/jszip/lib/compressedObject.js +74 -0
- package/node_modules/jszip/lib/compressions.js +14 -0
- package/node_modules/jszip/lib/crc32.js +77 -0
- package/node_modules/jszip/lib/defaults.js +11 -0
- package/node_modules/jszip/lib/external.js +18 -0
- package/node_modules/jszip/lib/flate.js +85 -0
- package/node_modules/jszip/lib/generate/ZipFileWorker.js +539 -0
- package/node_modules/jszip/lib/generate/index.js +57 -0
- package/node_modules/jszip/lib/index.js +55 -0
- package/node_modules/jszip/lib/license_header.js +11 -0
- package/node_modules/jszip/lib/load.js +88 -0
- package/node_modules/jszip/lib/nodejs/NodejsStreamInputAdapter.js +74 -0
- package/node_modules/jszip/lib/nodejs/NodejsStreamOutputAdapter.js +42 -0
- package/node_modules/jszip/lib/nodejsUtils.js +57 -0
- package/node_modules/jszip/lib/object.js +384 -0
- package/node_modules/jszip/lib/readable-stream-browser.js +10 -0
- package/node_modules/jszip/lib/reader/ArrayReader.js +57 -0
- package/node_modules/jszip/lib/reader/DataReader.js +116 -0
- package/node_modules/jszip/lib/reader/NodeBufferReader.js +19 -0
- package/node_modules/jszip/lib/reader/StringReader.js +38 -0
- package/node_modules/jszip/lib/reader/Uint8ArrayReader.js +22 -0
- package/node_modules/jszip/lib/reader/readerFor.js +28 -0
- package/node_modules/jszip/lib/signature.js +7 -0
- package/node_modules/jszip/lib/stream/ConvertWorker.js +26 -0
- package/node_modules/jszip/lib/stream/Crc32Probe.js +24 -0
- package/node_modules/jszip/lib/stream/DataLengthProbe.js +29 -0
- package/node_modules/jszip/lib/stream/DataWorker.js +116 -0
- package/node_modules/jszip/lib/stream/GenericWorker.js +263 -0
- package/node_modules/jszip/lib/stream/StreamHelper.js +214 -0
- package/node_modules/jszip/lib/support.js +38 -0
- package/node_modules/jszip/lib/utf8.js +275 -0
- package/node_modules/jszip/lib/utils.js +501 -0
- package/node_modules/jszip/lib/zipEntries.js +261 -0
- package/node_modules/jszip/lib/zipEntry.js +293 -0
- package/node_modules/jszip/lib/zipObject.js +133 -0
- package/node_modules/jszip/package.json +67 -0
- package/node_modules/jszip/sponsors.md +21 -0
- package/node_modules/jszip/tsconfig.json +101 -0
- package/node_modules/jszip/vendor/FileSaver.js +247 -0
- package/node_modules/lie/README.md +62 -0
- package/node_modules/lie/dist/lie.js +350 -0
- package/node_modules/lie/dist/lie.min.js +1 -0
- package/node_modules/lie/dist/lie.polyfill.js +358 -0
- package/node_modules/lie/dist/lie.polyfill.min.js +1 -0
- package/node_modules/lie/lib/browser.js +273 -0
- package/node_modules/lie/lib/index.js +298 -0
- package/node_modules/lie/license.md +7 -0
- package/node_modules/lie/lie.d.ts +244 -0
- package/node_modules/lie/package.json +69 -0
- package/node_modules/lie/polyfill.js +4 -0
- package/node_modules/pako/CHANGELOG.md +164 -0
- package/node_modules/pako/LICENSE +21 -0
- package/node_modules/pako/README.md +191 -0
- package/node_modules/pako/dist/pako.js +6818 -0
- package/node_modules/pako/dist/pako.min.js +1 -0
- package/node_modules/pako/dist/pako_deflate.js +3997 -0
- package/node_modules/pako/dist/pako_deflate.min.js +1 -0
- package/node_modules/pako/dist/pako_inflate.js +3300 -0
- package/node_modules/pako/dist/pako_inflate.min.js +1 -0
- package/node_modules/pako/index.js +14 -0
- package/node_modules/pako/lib/deflate.js +400 -0
- package/node_modules/pako/lib/inflate.js +423 -0
- package/node_modules/pako/lib/utils/common.js +105 -0
- package/node_modules/pako/lib/utils/strings.js +187 -0
- package/node_modules/pako/lib/zlib/README +59 -0
- package/node_modules/pako/lib/zlib/adler32.js +51 -0
- package/node_modules/pako/lib/zlib/constants.js +68 -0
- package/node_modules/pako/lib/zlib/crc32.js +59 -0
- package/node_modules/pako/lib/zlib/deflate.js +1874 -0
- package/node_modules/pako/lib/zlib/gzheader.js +58 -0
- package/node_modules/pako/lib/zlib/inffast.js +345 -0
- package/node_modules/pako/lib/zlib/inflate.js +1556 -0
- package/node_modules/pako/lib/zlib/inftrees.js +343 -0
- package/node_modules/pako/lib/zlib/messages.js +32 -0
- package/node_modules/pako/lib/zlib/trees.js +1222 -0
- package/node_modules/pako/lib/zlib/zstream.js +47 -0
- package/node_modules/pako/package.json +44 -0
- package/node_modules/process-nextick-args/index.js +45 -0
- package/node_modules/process-nextick-args/license.md +19 -0
- package/node_modules/process-nextick-args/package.json +25 -0
- package/node_modules/process-nextick-args/readme.md +18 -0
- package/node_modules/readable-stream/.travis.yml +34 -0
- package/node_modules/readable-stream/CONTRIBUTING.md +38 -0
- package/node_modules/readable-stream/GOVERNANCE.md +136 -0
- package/node_modules/readable-stream/LICENSE +47 -0
- package/node_modules/readable-stream/README.md +58 -0
- package/node_modules/readable-stream/doc/wg-meetings/2015-01-30.md +60 -0
- package/node_modules/readable-stream/duplex-browser.js +1 -0
- package/node_modules/readable-stream/duplex.js +1 -0
- package/node_modules/readable-stream/lib/_stream_duplex.js +131 -0
- package/node_modules/readable-stream/lib/_stream_passthrough.js +47 -0
- package/node_modules/readable-stream/lib/_stream_readable.js +1019 -0
- package/node_modules/readable-stream/lib/_stream_transform.js +214 -0
- package/node_modules/readable-stream/lib/_stream_writable.js +685 -0
- package/node_modules/readable-stream/lib/internal/streams/BufferList.js +78 -0
- package/node_modules/readable-stream/lib/internal/streams/destroy.js +84 -0
- package/node_modules/readable-stream/lib/internal/streams/stream-browser.js +1 -0
- package/node_modules/readable-stream/lib/internal/streams/stream.js +1 -0
- package/node_modules/readable-stream/package.json +52 -0
- package/node_modules/readable-stream/passthrough.js +1 -0
- package/node_modules/readable-stream/readable-browser.js +7 -0
- package/node_modules/readable-stream/readable.js +19 -0
- package/node_modules/readable-stream/transform.js +1 -0
- package/node_modules/readable-stream/writable-browser.js +1 -0
- package/node_modules/readable-stream/writable.js +8 -0
- package/node_modules/safe-buffer/LICENSE +21 -0
- package/node_modules/safe-buffer/README.md +584 -0
- package/node_modules/safe-buffer/index.d.ts +187 -0
- package/node_modules/safe-buffer/index.js +62 -0
- package/node_modules/safe-buffer/package.json +37 -0
- package/node_modules/setimmediate/LICENSE.txt +20 -0
- package/node_modules/setimmediate/package.json +30 -0
- package/node_modules/setimmediate/setImmediate.js +186 -0
- package/node_modules/string_decoder/.travis.yml +50 -0
- package/node_modules/string_decoder/LICENSE +48 -0
- package/node_modules/string_decoder/README.md +47 -0
- package/node_modules/string_decoder/lib/string_decoder.js +296 -0
- package/node_modules/string_decoder/package.json +31 -0
- package/node_modules/util-deprecate/History.md +16 -0
- package/node_modules/util-deprecate/LICENSE +24 -0
- package/node_modules/util-deprecate/README.md +53 -0
- package/node_modules/util-deprecate/browser.js +67 -0
- package/node_modules/util-deprecate/node.js +6 -0
- package/node_modules/util-deprecate/package.json +27 -0
- package/package.json +6 -4
- /package/node_modules/{p-limit/node_modules/yocto-queue → yocto-queue}/index.d.ts +0 -0
- /package/node_modules/{p-limit/node_modules/yocto-queue → yocto-queue}/index.js +0 -0
- /package/node_modules/{p-limit/node_modules/yocto-queue → yocto-queue}/license +0 -0
- /package/node_modules/{p-limit/node_modules/yocto-queue → yocto-queue}/package.json +0 -0
- /package/node_modules/{p-limit/node_modules/yocto-queue → yocto-queue}/readme.md +0 -0
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { syncFileBestEffort } from "./file-sync.js";
|
|
2
|
+
import fsSync, {} from "node:fs";
|
|
3
|
+
import fs, {} from "node:fs/promises";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { assertAsyncDirectoryGuard, createAsyncDirectoryGuard } from "./directory-guard.js";
|
|
6
|
+
import { syncDirectoryBestEffort } from "./directory-durability.js";
|
|
7
|
+
import { FsSafeError } from "./errors.js";
|
|
8
|
+
import { resolveReadOpenFlags } from "./read-open-flags.js";
|
|
9
|
+
import { inspectFileIdentity } from "./strict-file-identity.js";
|
|
10
|
+
import { registerTempPathForExit } from "./temp-cleanup.js";
|
|
11
|
+
import { serializePathWrite } from "./write-queue.js";
|
|
12
|
+
function assertRegularFile(stat) {
|
|
13
|
+
if (stat.isSymbolicLink()) {
|
|
14
|
+
throw new FsSafeError("symlink", "symlink sibling temp not allowed");
|
|
15
|
+
}
|
|
16
|
+
if (!stat.isFile()) {
|
|
17
|
+
throw new FsSafeError("not-file", "sibling temp must be a regular file");
|
|
18
|
+
}
|
|
19
|
+
if (stat.nlink !== 1n) {
|
|
20
|
+
throw new FsSafeError("hardlink", "sibling temp must have exactly one link");
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
async function inspectStage(inspect, expected) {
|
|
24
|
+
return await inspectFileIdentity(async () => {
|
|
25
|
+
const stat = await inspect();
|
|
26
|
+
assertRegularFile(stat);
|
|
27
|
+
return stat;
|
|
28
|
+
}, expected);
|
|
29
|
+
}
|
|
30
|
+
// Callback paths are not owned until all three admission observations agree.
|
|
31
|
+
// Keep one descriptor and one exact identity through mode, sync, rename and cleanup.
|
|
32
|
+
// Read/write access is needed only when the caller requests file synchronization.
|
|
33
|
+
export async function writeCallbackSibling(params) {
|
|
34
|
+
const parent = path.dirname(params.tempPath);
|
|
35
|
+
const guard = await createAsyncDirectoryGuard(parent);
|
|
36
|
+
const parentIdentity = await inspectFileIdentity(() => fs.lstat(parent, { bigint: true }));
|
|
37
|
+
const assertParent = async () => {
|
|
38
|
+
await assertAsyncDirectoryGuard(guard);
|
|
39
|
+
await inspectFileIdentity(() => fs.lstat(parent, { bigint: true }), parentIdentity);
|
|
40
|
+
};
|
|
41
|
+
let handle;
|
|
42
|
+
let identity;
|
|
43
|
+
let unregister;
|
|
44
|
+
let renamed = false;
|
|
45
|
+
let failure;
|
|
46
|
+
const inspectPath = (pathname, expected) => inspectStage(() => fs.lstat(pathname, { bigint: true }), expected);
|
|
47
|
+
const assertCurrent = async (pathname) => {
|
|
48
|
+
await assertParent();
|
|
49
|
+
const opened = await inspectStage(() => handle.stat({ bigint: true }), identity);
|
|
50
|
+
const current = await inspectPath(pathname, opened);
|
|
51
|
+
if (params.maxBytes !== undefined &&
|
|
52
|
+
(opened.size > params.maxBytes || current.size > params.maxBytes)) {
|
|
53
|
+
throw new FsSafeError("too-large", `sibling temp exceeds maxBytes (${params.maxBytes})`);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
try {
|
|
57
|
+
const result = await params.write(params.tempPath);
|
|
58
|
+
await assertParent();
|
|
59
|
+
const before = await inspectPath(params.tempPath);
|
|
60
|
+
try {
|
|
61
|
+
// No create/truncate flags; O_NONBLOCK also bounds a FIFO swap during open.
|
|
62
|
+
const access = params.syncTempFile ? fsSync.constants.O_RDWR : fsSync.constants.O_RDONLY;
|
|
63
|
+
handle = await fs.open(params.tempPath, access | resolveReadOpenFlags());
|
|
64
|
+
}
|
|
65
|
+
catch (error) {
|
|
66
|
+
if (error?.code === "ELOOP") {
|
|
67
|
+
throw new FsSafeError("symlink", "symlink sibling temp not allowed", { cause: error });
|
|
68
|
+
}
|
|
69
|
+
throw error;
|
|
70
|
+
}
|
|
71
|
+
const opened = await inspectStage(() => handle.stat({ bigint: true }), before);
|
|
72
|
+
await inspectPath(params.tempPath, opened);
|
|
73
|
+
await assertParent();
|
|
74
|
+
identity = opened;
|
|
75
|
+
unregister = registerTempPathForExit(params.tempPath, { identity, singleLinkFile: true });
|
|
76
|
+
const filePath = path.resolve(params.resolveFinalPath(result));
|
|
77
|
+
if (path.dirname(filePath) !== parent) {
|
|
78
|
+
throw new Error("Final path must be in the sibling temp directory.");
|
|
79
|
+
}
|
|
80
|
+
if (filePath === params.tempPath) {
|
|
81
|
+
throw new FsSafeError("invalid-path", "final path must differ from the sibling temp path");
|
|
82
|
+
}
|
|
83
|
+
await serializePathWrite(filePath, async () => {
|
|
84
|
+
await assertCurrent(params.tempPath);
|
|
85
|
+
if (params.mode !== undefined) {
|
|
86
|
+
try {
|
|
87
|
+
await handle.chmod(params.mode);
|
|
88
|
+
}
|
|
89
|
+
catch (error) {
|
|
90
|
+
if (!params.ignoreModeError)
|
|
91
|
+
throw error;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
if (params.syncTempFile) {
|
|
95
|
+
await assertCurrent(params.tempPath);
|
|
96
|
+
await syncFileBestEffort(handle);
|
|
97
|
+
}
|
|
98
|
+
await assertCurrent(params.tempPath);
|
|
99
|
+
await fs.rename(params.tempPath, filePath);
|
|
100
|
+
// A later verification failure never authorizes rollback of the final name.
|
|
101
|
+
renamed = true;
|
|
102
|
+
unregister();
|
|
103
|
+
await assertCurrent(filePath);
|
|
104
|
+
if (params.syncParentDir)
|
|
105
|
+
await syncDirectoryBestEffort(parent);
|
|
106
|
+
await assertCurrent(filePath);
|
|
107
|
+
});
|
|
108
|
+
return { filePath, result };
|
|
109
|
+
}
|
|
110
|
+
catch (error) {
|
|
111
|
+
failure = { error };
|
|
112
|
+
throw error;
|
|
113
|
+
}
|
|
114
|
+
finally {
|
|
115
|
+
try {
|
|
116
|
+
if (!renamed && identity) {
|
|
117
|
+
try {
|
|
118
|
+
await assertParent();
|
|
119
|
+
await inspectStage(() => handle.stat({ bigint: true }), identity);
|
|
120
|
+
await inspectPath(params.tempPath, identity);
|
|
121
|
+
await fs.unlink(params.tempPath);
|
|
122
|
+
unregister?.();
|
|
123
|
+
}
|
|
124
|
+
catch (error) {
|
|
125
|
+
// Preserve observed substitutes; retry only operational cleanup failures.
|
|
126
|
+
if (error instanceof FsSafeError || error?.code === "ENOENT") {
|
|
127
|
+
unregister?.();
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
finally {
|
|
133
|
+
try {
|
|
134
|
+
await handle?.close();
|
|
135
|
+
}
|
|
136
|
+
catch (error) {
|
|
137
|
+
if (failure)
|
|
138
|
+
throw new AggregateError([failure.error, error], "sibling publication and close failed");
|
|
139
|
+
throw error;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export type WriteSiblingTempFileOptions<T> = {
|
|
2
|
+
dir: string;
|
|
3
|
+
writeTemp: (tempPath: string) => Promise<T>;
|
|
4
|
+
resolveFinalPath: (result: T) => string;
|
|
5
|
+
tempPrefix?: string;
|
|
6
|
+
dirMode?: number;
|
|
7
|
+
chmodDir?: boolean;
|
|
8
|
+
/** Final file mode; omitted preserves the producer's mode. Applied through the retained descriptor. */
|
|
9
|
+
mode?: number;
|
|
10
|
+
/** Sync the staged descriptor before rename; defaults to false. */
|
|
11
|
+
syncTempFile?: boolean;
|
|
12
|
+
/** Best-effort parent directory sync after rename; defaults to false. */
|
|
13
|
+
syncParentDir?: boolean;
|
|
14
|
+
};
|
|
15
|
+
export type WriteSiblingTempFileResult<T> = {
|
|
16
|
+
filePath: string;
|
|
17
|
+
result: T;
|
|
18
|
+
};
|
|
19
|
+
export declare function writeSiblingTempFile<T>(options: WriteSiblingTempFileOptions<T>): Promise<WriteSiblingTempFileResult<T>>;
|
|
20
|
+
export declare function writeViaSiblingTempPath(params: {
|
|
21
|
+
rootDir: string;
|
|
22
|
+
targetPath: string;
|
|
23
|
+
writeTemp: (tempPath: string) => Promise<void>;
|
|
24
|
+
fallbackFileName?: string;
|
|
25
|
+
tempPrefix?: string;
|
|
26
|
+
}): Promise<void>;
|
|
27
|
+
//# sourceMappingURL=sibling-temp.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sibling-temp.d.ts","sourceRoot":"","sources":["../src/sibling-temp.ts"],"names":[],"mappings":"AAaA,MAAM,MAAM,2BAA2B,CAAC,CAAC,IAAI;IAC3C,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC;IAC5C,gBAAgB,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,MAAM,CAAC;IACxC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,uGAAuG;IACvG,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,mEAAmE;IACnE,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,yEAAyE;IACzE,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,0BAA0B,CAAC,CAAC,IAAI;IAC1C,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,CAAC,CAAC;CACX,CAAC;AASF,wBAAsB,oBAAoB,CAAC,CAAC,EAC1C,OAAO,EAAE,2BAA2B,CAAC,CAAC,CAAC,GACtC,OAAO,CAAC,0BAA0B,CAAC,CAAC,CAAC,CAAC,CAoBxC;AAwBD,wBAAsB,uBAAuB,CAAC,MAAM,EAAE;IACpD,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/C,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,GAAG,OAAO,CAAC,IAAI,CAAC,CA0ChB"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import crypto, { randomUUID } from "node:crypto";
|
|
2
|
+
import fs from "node:fs/promises";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { assertAsyncDirectoryGuard, createAsyncDirectoryGuard } from "./directory-guard.js";
|
|
5
|
+
import { fitFileNameToPortableComponent, sanitizeUntrustedFileName } from "./filename.js";
|
|
6
|
+
import { applyDirectoryMode } from "./replace-file-descriptor.js";
|
|
7
|
+
import { root } from "./root.js";
|
|
8
|
+
import { assertSafePathPrefix } from "./safe-path-segment.js";
|
|
9
|
+
import { resolveSecureTempRoot } from "./secure-temp-dir.js";
|
|
10
|
+
import { writeCallbackSibling } from "./sibling-staged-file.js";
|
|
11
|
+
import { tempFile } from "./temp-target.js";
|
|
12
|
+
import { getFsSafeTestHooks } from "./test-hooks.js";
|
|
13
|
+
function buildTempPath(dir, tempPrefix) {
|
|
14
|
+
const safePrefix = assertSafePathPrefix(tempPrefix ?? ".fs-safe-stream", {
|
|
15
|
+
label: "sibling temp prefix",
|
|
16
|
+
});
|
|
17
|
+
return path.join(dir, `${safePrefix}.${process.pid}.${randomUUID()}.tmp`);
|
|
18
|
+
}
|
|
19
|
+
export async function writeSiblingTempFile(options) {
|
|
20
|
+
const dir = path.resolve(options.dir);
|
|
21
|
+
await fs.mkdir(dir, { recursive: true, mode: options.dirMode ?? 0o700 });
|
|
22
|
+
if (options.chmodDir !== false) {
|
|
23
|
+
await applyDirectoryMode({
|
|
24
|
+
fsModule: fs,
|
|
25
|
+
dirPath: dir,
|
|
26
|
+
mode: options.dirMode ?? 0o700,
|
|
27
|
+
ignoreChmodError: true,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
return await writeCallbackSibling({
|
|
31
|
+
tempPath: buildTempPath(dir, options.tempPrefix),
|
|
32
|
+
write: options.writeTemp,
|
|
33
|
+
resolveFinalPath: options.resolveFinalPath,
|
|
34
|
+
mode: options.mode,
|
|
35
|
+
ignoreModeError: true,
|
|
36
|
+
syncTempFile: options.syncTempFile === true,
|
|
37
|
+
syncParentDir: options.syncParentDir === true,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
function buildSiblingTempPath(params) {
|
|
41
|
+
const id = crypto.randomUUID();
|
|
42
|
+
const safePrefix = assertSafePathPrefix(params.tempPrefix, {
|
|
43
|
+
label: "sibling temp prefix",
|
|
44
|
+
});
|
|
45
|
+
const prefix = `${safePrefix}${id}-`;
|
|
46
|
+
const suffix = ".part";
|
|
47
|
+
const safeTail = fitFileNameToPortableComponent({
|
|
48
|
+
prefix,
|
|
49
|
+
fileName: sanitizeUntrustedFileName(path.basename(params.targetPath), params.fallbackFileName),
|
|
50
|
+
suffix,
|
|
51
|
+
});
|
|
52
|
+
return path.join(path.dirname(params.targetPath), `${prefix}${safeTail}${suffix}`);
|
|
53
|
+
}
|
|
54
|
+
export async function writeViaSiblingTempPath(params) {
|
|
55
|
+
const rootDir = await fs
|
|
56
|
+
.realpath(path.resolve(params.rootDir))
|
|
57
|
+
.catch(() => path.resolve(params.rootDir));
|
|
58
|
+
const requestedTargetPath = path.resolve(params.targetPath);
|
|
59
|
+
const targetPath = await fs
|
|
60
|
+
.realpath(path.dirname(requestedTargetPath))
|
|
61
|
+
.then((realDir) => path.join(realDir, path.basename(requestedTargetPath)))
|
|
62
|
+
.catch(() => requestedTargetPath);
|
|
63
|
+
const relativeTargetPath = path.relative(rootDir, targetPath);
|
|
64
|
+
if (!relativeTargetPath ||
|
|
65
|
+
relativeTargetPath === ".." ||
|
|
66
|
+
relativeTargetPath.startsWith(`..${path.sep}`) ||
|
|
67
|
+
path.isAbsolute(relativeTargetPath)) {
|
|
68
|
+
throw new Error("Target path is outside the allowed root");
|
|
69
|
+
}
|
|
70
|
+
const rootGuard = await createAsyncDirectoryGuard(rootDir);
|
|
71
|
+
const workspace = await tempFile({
|
|
72
|
+
rootDir: resolveSecureTempRoot({
|
|
73
|
+
fallbackPrefix: "fs-safe-output",
|
|
74
|
+
unsafeFallbackLabel: "sibling temp output dir",
|
|
75
|
+
warn: () => undefined,
|
|
76
|
+
}),
|
|
77
|
+
prefix: "fs-safe-output",
|
|
78
|
+
});
|
|
79
|
+
try {
|
|
80
|
+
const tempPath = buildSiblingTempPath({
|
|
81
|
+
targetPath: path.join(workspace.dir, path.basename(targetPath)),
|
|
82
|
+
fallbackFileName: params.fallbackFileName ?? "output.bin",
|
|
83
|
+
tempPrefix: params.tempPrefix ?? ".fs-safe-output-",
|
|
84
|
+
});
|
|
85
|
+
await getFsSafeTestHooks()?.beforeSiblingTempWrite?.(tempPath);
|
|
86
|
+
await params.writeTemp(tempPath);
|
|
87
|
+
await assertAsyncDirectoryGuard(rootGuard);
|
|
88
|
+
const targetRoot = await root(rootDir);
|
|
89
|
+
await targetRoot.copyIn(relativeTargetPath, tempPath, { mkdir: false });
|
|
90
|
+
await assertAsyncDirectoryGuard(rootGuard);
|
|
91
|
+
}
|
|
92
|
+
finally {
|
|
93
|
+
await workspace.cleanup();
|
|
94
|
+
}
|
|
95
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type NativeFileHandle } from "./native-operations.js";
|
|
2
|
+
import type { Root } from "./root-impl.js";
|
|
3
|
+
import { type SidecarLockSnapshot } from "./sidecar-lock-reclaim.js";
|
|
4
|
+
import type { SidecarLockAcquireOptions, SidecarLockHandle } from "./sidecar-lock-types.js";
|
|
5
|
+
type SidecarFileHandle = Pick<NativeFileHandle, "close" | "stat" | "writeFile">;
|
|
6
|
+
export type HeldSidecarLock = {
|
|
7
|
+
refCount: number;
|
|
8
|
+
reentrantOwner?: string;
|
|
9
|
+
handle: SidecarFileHandle;
|
|
10
|
+
lockPath: string;
|
|
11
|
+
snapshot: SidecarLockSnapshot;
|
|
12
|
+
acquiredAt: number;
|
|
13
|
+
metadata: Record<string, unknown>;
|
|
14
|
+
releasePromise?: Promise<void>;
|
|
15
|
+
lockRoot?: Root;
|
|
16
|
+
retainOnExit?: boolean;
|
|
17
|
+
parsePayload?: (raw: string) => unknown;
|
|
18
|
+
compromiseTimer?: NodeJS.Timeout;
|
|
19
|
+
};
|
|
20
|
+
type SidecarLockAcquisitionContext = {
|
|
21
|
+
held: Map<string, HeldSidecarLock>;
|
|
22
|
+
reclaimGuards: Set<string>;
|
|
23
|
+
ensureExitCleanupRegistered(): void;
|
|
24
|
+
handleForHeldLock(normalizedTargetPath: string, held: HeldSidecarLock): SidecarLockHandle;
|
|
25
|
+
releaseHeldLock(normalizedTargetPath: string, held: HeldSidecarLock, options?: {
|
|
26
|
+
force?: boolean;
|
|
27
|
+
}): Promise<boolean>;
|
|
28
|
+
};
|
|
29
|
+
export declare function acquireSidecarLock<TPayload extends Record<string, unknown>>(options: SidecarLockAcquireOptions<TPayload>, context: SidecarLockAcquisitionContext): Promise<SidecarLockHandle>;
|
|
30
|
+
export {};
|
|
31
|
+
//# sourceMappingURL=sidecar-lock-acquire.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sidecar-lock-acquire.d.ts","sourceRoot":"","sources":["../src/sidecar-lock-acquire.ts"],"names":[],"mappings":"AAOA,OAAO,EAA6B,KAAK,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1F,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAS3C,OAAO,EAWL,KAAK,mBAAmB,EACzB,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,yBAAyB,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAG5F,KAAK,iBAAiB,GAAG,IAAI,CAAC,gBAAgB,EAAE,OAAO,GAAG,MAAM,GAAG,WAAW,CAAC,CAAC;AAEhF,MAAM,MAAM,eAAe,GAAG;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,MAAM,EAAE,iBAAiB,CAAC;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,mBAAmB,CAAC;IAC9B,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,cAAc,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/B,QAAQ,CAAC,EAAE,IAAI,CAAC;IAChB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,YAAY,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC;IACxC,eAAe,CAAC,EAAE,MAAM,CAAC,OAAO,CAAC;CAClC,CAAC;AAEF,KAAK,6BAA6B,GAAG;IACnC,IAAI,EAAE,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IACnC,aAAa,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC3B,2BAA2B,IAAI,IAAI,CAAC;IACpC,iBAAiB,CAAC,oBAAoB,EAAE,MAAM,EAAE,IAAI,EAAE,eAAe,GAAG,iBAAiB,CAAC;IAC1F,eAAe,CACb,oBAAoB,EAAE,MAAM,EAC5B,IAAI,EAAE,eAAe,EACrB,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE,GAC5B,OAAO,CAAC,OAAO,CAAC,CAAC;CACrB,CAAC;AAqBF,wBAAsB,kBAAkB,CAAC,QAAQ,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/E,OAAO,EAAE,yBAAyB,CAAC,QAAQ,CAAC,EAC5C,OAAO,EAAE,6BAA6B,GACrC,OAAO,CAAC,iBAAiB,CAAC,CAqT5B"}
|
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
import fs from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { canonicalPathFromExistingAncestor } from "./absolute-path.js";
|
|
4
|
+
import { FsSafeError } from "./errors.js";
|
|
5
|
+
import { fileObservation } from "./file-observation.js";
|
|
6
|
+
import { readFileHandleBounded } from "./bounded-read.js";
|
|
7
|
+
import { openSidecarRoot } from "./sidecar-lock-root.js";
|
|
8
|
+
import { createNativeExclusiveFile } from "./native-operations.js";
|
|
9
|
+
import { computeSidecarLockDelayMs, defaultSidecarLockShouldReclaim, isTransientLockFileDenial, maxTransientLockDenials, validateSidecarLockRetryOptions, validateSidecarLockTimeoutMs, } from "./sidecar-lock-policy.js";
|
|
10
|
+
import { readSidecarLockRawSnapshot, parseSidecarLockSnapshot, relativeSidecarLockPath, releaseSidecarReclaimGuard, removeSidecarLockIfUnchanged, removeStaleSidecarLockIfAllowed, serializeSidecarLockPayload, sidecarLockSnapshotStillPresent, sidecarReclaimGuardExists, tryAcquireSidecarReclaimGuard, } from "./sidecar-lock-reclaim.js";
|
|
11
|
+
import { createSuppressedError } from "./suppressed-error.js";
|
|
12
|
+
async function resolveNormalizedTargetPath(targetPath, lockRoot) {
|
|
13
|
+
const resolved = path.resolve(targetPath);
|
|
14
|
+
const dir = path.dirname(resolved);
|
|
15
|
+
if (lockRoot) {
|
|
16
|
+
// The target is an arbitration key, not necessarily inside the lock Root.
|
|
17
|
+
// Leave parent creation to the Root-backed sidecar write.
|
|
18
|
+
await lockRoot.resolve(".");
|
|
19
|
+
const parent = await canonicalPathFromExistingAncestor(dir);
|
|
20
|
+
await lockRoot.resolve(".");
|
|
21
|
+
return path.join(parent, path.basename(resolved));
|
|
22
|
+
}
|
|
23
|
+
await fs.mkdir(dir, { recursive: true });
|
|
24
|
+
try {
|
|
25
|
+
return path.join(await fs.realpath(dir), path.basename(resolved));
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
return resolved;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
export async function acquireSidecarLock(options, context) {
|
|
32
|
+
const retry = options.retry ?? {};
|
|
33
|
+
validateSidecarLockRetryOptions(retry);
|
|
34
|
+
validateSidecarLockTimeoutMs(options.timeoutMs);
|
|
35
|
+
context.ensureExitCleanupRegistered();
|
|
36
|
+
const normalizedTargetPath = await resolveNormalizedTargetPath(options.targetPath, options.lockRoot);
|
|
37
|
+
const lockPath = options.lockPath ?? `${normalizedTargetPath}.lock`;
|
|
38
|
+
let held = context.held.get(normalizedTargetPath);
|
|
39
|
+
if (held &&
|
|
40
|
+
options.reentrantOwner !== undefined &&
|
|
41
|
+
held.reentrantOwner !== undefined &&
|
|
42
|
+
options.reentrantOwner === held.reentrantOwner) {
|
|
43
|
+
// A final release may already have decremented the count to zero and be
|
|
44
|
+
// removing the sidecar. Do not admit a new reentrant handle until that
|
|
45
|
+
// cleanup settles: successful cleanup requires a fresh acquisition, while
|
|
46
|
+
// failed cleanup leaves the existing sidecar held for a retry.
|
|
47
|
+
if (held.releasePromise) {
|
|
48
|
+
await held.releasePromise.catch(() => undefined);
|
|
49
|
+
held = context.held.get(normalizedTargetPath);
|
|
50
|
+
}
|
|
51
|
+
if (held &&
|
|
52
|
+
options.reentrantOwner !== undefined &&
|
|
53
|
+
held.reentrantOwner !== undefined &&
|
|
54
|
+
options.reentrantOwner === held.reentrantOwner) {
|
|
55
|
+
held.refCount += 1;
|
|
56
|
+
// Retention is monotonic: any same-owner request to keep the sidecar on
|
|
57
|
+
// exit upgrades the held lock; a later default acquisition never revokes it.
|
|
58
|
+
if (options.retainOnExit === true) {
|
|
59
|
+
held.retainOnExit = true;
|
|
60
|
+
}
|
|
61
|
+
return context.handleForHeldLock(normalizedTargetPath, held);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
const startedAt = Date.now();
|
|
65
|
+
const reclaimGuardPath = `${lockPath}.reclaim`;
|
|
66
|
+
let ownsReclaimGuard = false;
|
|
67
|
+
let attempt = 0;
|
|
68
|
+
// Bounded so a genuine denial still surfaces as EPERM, not a lock timeout.
|
|
69
|
+
let transientDenials = 0;
|
|
70
|
+
const withinDenialBudget = () => ++transientDenials <= maxTransientLockDenials;
|
|
71
|
+
const waitForRetry = async () => {
|
|
72
|
+
const elapsed = Date.now() - startedAt;
|
|
73
|
+
if ((options.timeoutMs !== undefined &&
|
|
74
|
+
options.timeoutMs !== Number.POSITIVE_INFINITY &&
|
|
75
|
+
elapsed >= options.timeoutMs) ||
|
|
76
|
+
(retry.retries !== undefined && attempt >= retry.retries)) {
|
|
77
|
+
throw Object.assign(new Error(`file lock timeout for ${normalizedTargetPath}`), {
|
|
78
|
+
code: "file_lock_timeout",
|
|
79
|
+
lockPath,
|
|
80
|
+
normalizedTargetPath,
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
const remaining = options.timeoutMs === undefined || options.timeoutMs === Number.POSITIVE_INFINITY
|
|
84
|
+
? Number.POSITIVE_INFINITY
|
|
85
|
+
: Math.max(0, options.timeoutMs - elapsed);
|
|
86
|
+
const delay = Math.min(computeSidecarLockDelayMs(retry, attempt), remaining);
|
|
87
|
+
attempt += 1;
|
|
88
|
+
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
89
|
+
};
|
|
90
|
+
// Waiting can fail on the caller's own retry or deadline limits. Classifying
|
|
91
|
+
// a denial as contention must not cost them the original diagnosis, so hand
|
|
92
|
+
// the denial back when no further attempt can be scheduled.
|
|
93
|
+
const retryOrRethrowDenial = async (denial) => {
|
|
94
|
+
try {
|
|
95
|
+
await waitForRetry();
|
|
96
|
+
}
|
|
97
|
+
catch (waitError) {
|
|
98
|
+
if (waitError.code === "file_lock_timeout")
|
|
99
|
+
throw denial;
|
|
100
|
+
throw waitError;
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
try {
|
|
104
|
+
while (true) {
|
|
105
|
+
if (!ownsReclaimGuard && (await sidecarReclaimGuardExists(reclaimGuardPath))) {
|
|
106
|
+
await waitForRetry();
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
let handle = null;
|
|
110
|
+
let createdSnapshot = null;
|
|
111
|
+
let lockFileCreateDenied = false;
|
|
112
|
+
const payload = await options.payload();
|
|
113
|
+
const { raw, ownershipToken } = serializeSidecarLockPayload(payload);
|
|
114
|
+
try {
|
|
115
|
+
if (options.lockRoot) {
|
|
116
|
+
const lockRoot = options.lockRoot;
|
|
117
|
+
const relativeLockPath = relativeSidecarLockPath(lockRoot, lockPath);
|
|
118
|
+
const observation = fileObservation();
|
|
119
|
+
try {
|
|
120
|
+
await observation.run(() => lockRoot.create(relativeLockPath, raw, { mkdir: true, mode: 0o600 }));
|
|
121
|
+
}
|
|
122
|
+
catch (error) {
|
|
123
|
+
// Only this invocation's failed exclusive open grants denial retry authority.
|
|
124
|
+
lockFileCreateDenied = observation.has(error, `exclusive-create:${lockPath}`) &&
|
|
125
|
+
isTransientLockFileDenial(error, lockPath);
|
|
126
|
+
if (error instanceof FsSafeError && error.code === "already-exists") {
|
|
127
|
+
throw Object.assign(new Error("sidecar lock exists"), { code: "EEXIST" });
|
|
128
|
+
}
|
|
129
|
+
throw error;
|
|
130
|
+
}
|
|
131
|
+
createdSnapshot = { raw, payload, ownershipToken };
|
|
132
|
+
const opened = await openSidecarRoot(lockRoot, relativeLockPath, "unlinked");
|
|
133
|
+
if (!opened) {
|
|
134
|
+
await waitForRetry();
|
|
135
|
+
continue;
|
|
136
|
+
}
|
|
137
|
+
try {
|
|
138
|
+
// Root.open admits the current file, not necessarily the one we created.
|
|
139
|
+
const currentRaw = await readFileHandleBounded(opened.handle, Buffer.byteLength(raw));
|
|
140
|
+
if (!currentRaw.equals(Buffer.from(raw))) {
|
|
141
|
+
throw new FsSafeError("path-mismatch", "created sidecar lock changed before admission");
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
catch (error) {
|
|
145
|
+
await opened.handle.close().catch(() => undefined);
|
|
146
|
+
throw error;
|
|
147
|
+
}
|
|
148
|
+
handle = opened.handle;
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
try {
|
|
152
|
+
handle =
|
|
153
|
+
(await createNativeExclusiveFile(lockPath, 0o600)) ??
|
|
154
|
+
(await fs.open(lockPath, "wx"));
|
|
155
|
+
}
|
|
156
|
+
catch (createError) {
|
|
157
|
+
lockFileCreateDenied = isTransientLockFileDenial(createError, lockPath);
|
|
158
|
+
throw createError;
|
|
159
|
+
}
|
|
160
|
+
await handle.writeFile(raw, "utf8");
|
|
161
|
+
}
|
|
162
|
+
const snapshot = { raw, payload, stat: await handle.stat(), ownershipToken };
|
|
163
|
+
if (snapshot.stat.nlink === 0) {
|
|
164
|
+
await handle.close();
|
|
165
|
+
handle = null;
|
|
166
|
+
await waitForRetry();
|
|
167
|
+
continue;
|
|
168
|
+
}
|
|
169
|
+
const createdHeld = {
|
|
170
|
+
refCount: 1,
|
|
171
|
+
reentrantOwner: options.reentrantOwner,
|
|
172
|
+
handle,
|
|
173
|
+
lockPath,
|
|
174
|
+
snapshot,
|
|
175
|
+
acquiredAt: Date.now(),
|
|
176
|
+
metadata: options.metadata ?? {},
|
|
177
|
+
lockRoot: options.lockRoot,
|
|
178
|
+
retainOnExit: options.retainOnExit,
|
|
179
|
+
parsePayload: options.parsePayload,
|
|
180
|
+
};
|
|
181
|
+
context.held.set(normalizedTargetPath, createdHeld);
|
|
182
|
+
if (ownsReclaimGuard) {
|
|
183
|
+
try {
|
|
184
|
+
await releaseSidecarReclaimGuard(context.reclaimGuards, reclaimGuardPath);
|
|
185
|
+
ownsReclaimGuard = false;
|
|
186
|
+
}
|
|
187
|
+
catch (err) {
|
|
188
|
+
await context.releaseHeldLock(normalizedTargetPath, createdHeld, { force: true });
|
|
189
|
+
throw err;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
const returnedHandle = context.handleForHeldLock(normalizedTargetPath, createdHeld);
|
|
193
|
+
const interval = options.compromiseCheckIntervalMs;
|
|
194
|
+
if (options.onCompromised && interval !== undefined && interval > 0) {
|
|
195
|
+
createdHeld.compromiseTimer = setInterval(() => {
|
|
196
|
+
void returnedHandle
|
|
197
|
+
.verifyStillHeld()
|
|
198
|
+
.catch(() => false)
|
|
199
|
+
.then((stillHeld) => {
|
|
200
|
+
if (!stillHeld && createdHeld.compromiseTimer) {
|
|
201
|
+
clearInterval(createdHeld.compromiseTimer);
|
|
202
|
+
createdHeld.compromiseTimer = undefined;
|
|
203
|
+
options.onCompromised?.({ lockPath, normalizedTargetPath });
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
}, interval);
|
|
207
|
+
createdHeld.compromiseTimer.unref();
|
|
208
|
+
}
|
|
209
|
+
return returnedHandle;
|
|
210
|
+
}
|
|
211
|
+
catch (err) {
|
|
212
|
+
try {
|
|
213
|
+
if (handle) {
|
|
214
|
+
const failedSnapshot = createdSnapshot ?? { payload: null };
|
|
215
|
+
try {
|
|
216
|
+
failedSnapshot.stat = await handle.stat();
|
|
217
|
+
}
|
|
218
|
+
catch {
|
|
219
|
+
// Best-effort cleanup of a failed exclusive create.
|
|
220
|
+
}
|
|
221
|
+
const current = context.held.get(normalizedTargetPath);
|
|
222
|
+
if (current?.handle === handle) {
|
|
223
|
+
context.held.delete(normalizedTargetPath);
|
|
224
|
+
}
|
|
225
|
+
await handle.close().catch(() => undefined);
|
|
226
|
+
// Root-created records retain the creator's byte/token receipt;
|
|
227
|
+
// partial direct writes use the exclusive descriptor's identity.
|
|
228
|
+
await removeSidecarLockIfUnchanged(lockPath, failedSnapshot, {
|
|
229
|
+
lockRoot: options.lockRoot,
|
|
230
|
+
parsePayload: options.parsePayload,
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
else if (createdSnapshot) {
|
|
234
|
+
await removeSidecarLockIfUnchanged(lockPath, createdSnapshot, {
|
|
235
|
+
lockRoot: options.lockRoot,
|
|
236
|
+
parsePayload: options.parsePayload,
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
catch (cleanupError) {
|
|
241
|
+
throw createSuppressedError(cleanupError, err, "file lock acquisition and cleanup both failed");
|
|
242
|
+
}
|
|
243
|
+
if (lockFileCreateDenied && withinDenialBudget()) {
|
|
244
|
+
await retryOrRethrowDenial(err);
|
|
245
|
+
continue;
|
|
246
|
+
}
|
|
247
|
+
if (err.code !== "EEXIST") {
|
|
248
|
+
throw err;
|
|
249
|
+
}
|
|
250
|
+
if (ownsReclaimGuard) {
|
|
251
|
+
await releaseSidecarReclaimGuard(context.reclaimGuards, reclaimGuardPath);
|
|
252
|
+
ownsReclaimGuard = false;
|
|
253
|
+
await waitForRetry();
|
|
254
|
+
continue;
|
|
255
|
+
}
|
|
256
|
+
const nowMs = Date.now();
|
|
257
|
+
let rawSnapshot;
|
|
258
|
+
let lockFileOpenDenied = false;
|
|
259
|
+
try {
|
|
260
|
+
rawSnapshot = await readSidecarLockRawSnapshot(lockPath, {
|
|
261
|
+
lockRoot: options.lockRoot,
|
|
262
|
+
rejectNonFile: true,
|
|
263
|
+
discardObservation: "changed",
|
|
264
|
+
onOpenFailure: (error) => { lockFileOpenDenied = isTransientLockFileDenial(error, lockPath); },
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
catch (readErr) {
|
|
268
|
+
if (!lockFileOpenDenied || !withinDenialBudget())
|
|
269
|
+
throw readErr;
|
|
270
|
+
await retryOrRethrowDenial(readErr);
|
|
271
|
+
continue;
|
|
272
|
+
}
|
|
273
|
+
const snapshot = parseSidecarLockSnapshot(rawSnapshot, options.parsePayload);
|
|
274
|
+
if (!snapshot) {
|
|
275
|
+
await waitForRetry();
|
|
276
|
+
continue;
|
|
277
|
+
}
|
|
278
|
+
if (context.held.has(normalizedTargetPath)) {
|
|
279
|
+
await waitForRetry();
|
|
280
|
+
continue;
|
|
281
|
+
}
|
|
282
|
+
const shouldReclaim = options.shouldReclaim ?? defaultSidecarLockShouldReclaim;
|
|
283
|
+
if (await shouldReclaim({
|
|
284
|
+
lockPath,
|
|
285
|
+
normalizedTargetPath,
|
|
286
|
+
payload: snapshot?.payload ?? null,
|
|
287
|
+
staleMs: options.staleMs,
|
|
288
|
+
nowMs,
|
|
289
|
+
heldByThisProcess: context.held.has(normalizedTargetPath),
|
|
290
|
+
})) {
|
|
291
|
+
if (!(await sidecarLockSnapshotStillPresent(lockPath, snapshot, {
|
|
292
|
+
lockRoot: options.lockRoot,
|
|
293
|
+
parsePayload: options.parsePayload,
|
|
294
|
+
}))) {
|
|
295
|
+
await waitForRetry();
|
|
296
|
+
continue;
|
|
297
|
+
}
|
|
298
|
+
const staleRecovery = options.staleRecovery ?? "fail-closed";
|
|
299
|
+
if (staleRecovery === "remove-if-unchanged") {
|
|
300
|
+
if (!(await tryAcquireSidecarReclaimGuard(context.reclaimGuards, reclaimGuardPath))) {
|
|
301
|
+
await waitForRetry();
|
|
302
|
+
continue;
|
|
303
|
+
}
|
|
304
|
+
ownsReclaimGuard = true;
|
|
305
|
+
const removal = await removeStaleSidecarLockIfAllowed({
|
|
306
|
+
lockPath,
|
|
307
|
+
normalizedTargetPath,
|
|
308
|
+
snapshot,
|
|
309
|
+
shouldRemoveStaleLock: options.shouldRemoveStaleLock,
|
|
310
|
+
lockRoot: options.lockRoot,
|
|
311
|
+
parsePayload: options.parsePayload,
|
|
312
|
+
});
|
|
313
|
+
if (removal === "removed" || removal === "changed") {
|
|
314
|
+
if (removal === "changed")
|
|
315
|
+
await waitForRetry();
|
|
316
|
+
continue;
|
|
317
|
+
}
|
|
318
|
+
await releaseSidecarReclaimGuard(context.reclaimGuards, reclaimGuardPath);
|
|
319
|
+
ownsReclaimGuard = false;
|
|
320
|
+
}
|
|
321
|
+
throw Object.assign(new Error(`file lock stale for ${normalizedTargetPath}`), {
|
|
322
|
+
code: "file_lock_stale",
|
|
323
|
+
lockPath,
|
|
324
|
+
normalizedTargetPath,
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
await waitForRetry();
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
finally {
|
|
332
|
+
if (ownsReclaimGuard) {
|
|
333
|
+
await releaseSidecarReclaimGuard(context.reclaimGuards, reclaimGuardPath).catch(() => undefined);
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Root } from "./root-impl.js";
|
|
2
|
+
import { type SidecarLockSnapshot } from "./sidecar-lock-reclaim.js";
|
|
3
|
+
import type { SidecarLockHandle } from "./sidecar-lock-types.js";
|
|
4
|
+
export declare function createSidecarLockHandle(params: {
|
|
5
|
+
lockPath: string;
|
|
6
|
+
normalizedTargetPath: string;
|
|
7
|
+
verifyStillHeld: () => Promise<boolean>;
|
|
8
|
+
release: (options?: {
|
|
9
|
+
retry?: boolean;
|
|
10
|
+
}) => Promise<unknown>;
|
|
11
|
+
}): SidecarLockHandle;
|
|
12
|
+
export declare function createHeldSidecarLockHandle(params: {
|
|
13
|
+
normalizedTargetPath: string;
|
|
14
|
+
held: {
|
|
15
|
+
lockPath: string;
|
|
16
|
+
snapshot: SidecarLockSnapshot;
|
|
17
|
+
lockRoot?: Root;
|
|
18
|
+
parsePayload?: (raw: string) => unknown;
|
|
19
|
+
};
|
|
20
|
+
release: (options?: {
|
|
21
|
+
retry?: boolean;
|
|
22
|
+
}) => Promise<unknown>;
|
|
23
|
+
}): SidecarLockHandle;
|
|
24
|
+
//# sourceMappingURL=sidecar-lock-handle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sidecar-lock-handle.d.ts","sourceRoot":"","sources":["../src/sidecar-lock-handle.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAEL,KAAK,mBAAmB,EACzB,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAEjE,wBAAgB,uBAAuB,CAAC,MAAM,EAAE;IAC9C,QAAQ,EAAE,MAAM,CAAC;IACjB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,eAAe,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;IACxC,OAAO,EAAE,CAAC,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;CAC9D,GAAG,iBAAiB,CA2BpB;AAED,wBAAgB,2BAA2B,CAAC,MAAM,EAAE;IAClD,oBAAoB,EAAE,MAAM,CAAC;IAC7B,IAAI,EAAE;QACJ,QAAQ,EAAE,MAAM,CAAC;QACjB,QAAQ,EAAE,mBAAmB,CAAC;QAC9B,QAAQ,CAAC,EAAE,IAAI,CAAC;QAChB,YAAY,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC;KACzC,CAAC;IACF,OAAO,EAAE,CAAC,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;CAC9D,GAAG,iBAAiB,CAWpB"}
|