@openclaw/feishu 2026.10.2 → 2026.10.5-beta.2
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/.setup/{app-registration-BB6TubaW.mjs → app-registration-DQOq5urV.mjs} +13 -32
- package/dist/.setup/{channel-DZakdZ3r.mjs → channel-CjGGyrdx.mjs} +87 -174
- package/dist/.setup/{channel.runtime-rXFuQXLL.mjs → channel.runtime-SaC_uTPM.mjs} +57 -74
- package/dist/.setup/{chat-mTBvMMvx.mjs → chat-fC3dvxFs.mjs} +16 -28
- package/dist/.setup/{client-CcxmEkoy.mjs → client-wwr8PGPH.mjs} +24 -30
- package/dist/.setup/{conversation-id-C1ofUfU8.mjs → conversation-id-D00i9uy5.mjs} +5 -10
- package/dist/.setup/{doctor-contract-DyOo8NvC.mjs → doctor-contract-oIpUWtNO.mjs} +8 -15
- package/dist/.setup/{monitor-CXaFHMmi.mjs → monitor-Yt__BUki.mjs} +33 -54
- package/dist/.setup/{monitor.account-cJ8gavqv.mjs → monitor.account-CVz16781.mjs} +359 -658
- package/dist/.setup/{probe-BjSykXB8.mjs → probe-DXnFxq5j.mjs} +14 -17
- package/dist/.setup/{reply-delivery-result-laBNOmBu.mjs → reply-delivery-result-iCCrdxE1.mjs} +153 -181
- package/dist/.setup/{session-conversation-C53IEUWt.mjs → session-conversation-BSBNK5Mq.mjs} +1 -1
- package/dist/.setup/{setup-api-fZcYXGxe.mjs → setup-api-B_LFQQ-Q.mjs} +1 -1
- package/dist/.setup/{subagent-hooks-C8Z_x3KJ.mjs → subagent-hooks-9Pc1-k37.mjs} +7 -17
- package/dist/.setup/{thread-bindings-jW2x5VuN.mjs → thread-bindings-DdNLxoL3.mjs} +21 -44
- package/dist/api.js +218 -326
- package/dist/channel-plugin-api.js +1 -1
- package/dist/contract-api.js +1 -1
- package/dist/doctor-contract-api.js +1 -1
- package/dist/session-binding-contract-api.js +1 -1
- package/dist/session-key-api.js +1 -1
- package/dist/setup-api.js +1 -1
- package/dist/setup-entry.js +1 -1
- package/dist/subagent-hooks-api.js +1 -1
- package/node_modules/@openclaw/fs-safe/CHANGELOG.md +35 -0
- package/node_modules/@openclaw/fs-safe/README.md +1 -1
- package/node_modules/@openclaw/fs-safe/dist/advanced.d.ts +1 -1
- package/node_modules/@openclaw/fs-safe/dist/advanced.js +1 -1
- package/node_modules/@openclaw/fs-safe/dist/archive-durability.js +1 -1
- package/node_modules/@openclaw/fs-safe/dist/archive-merge.js +4 -4
- package/node_modules/@openclaw/fs-safe/dist/archive-parser.wasm +0 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-read.js +5 -4
- package/node_modules/@openclaw/fs-safe/dist/archive-staging.d.ts +1 -1
- package/node_modules/@openclaw/fs-safe/dist/archive-staging.js +22 -38
- package/node_modules/@openclaw/fs-safe/dist/copy-path-admission.d.ts +17 -0
- package/node_modules/@openclaw/fs-safe/dist/copy-path-admission.js +117 -0
- package/node_modules/@openclaw/fs-safe/dist/copy-root-file-sync.d.ts +8 -5
- package/node_modules/@openclaw/fs-safe/dist/copy-root-file-sync.js +27 -50
- package/node_modules/@openclaw/fs-safe/dist/file-lock-sync-root-acquire.d.ts +3 -0
- package/node_modules/@openclaw/fs-safe/dist/file-lock-sync-root-acquire.js +57 -11
- package/node_modules/@openclaw/fs-safe/dist/guarded-mutation.js +5 -5
- package/node_modules/@openclaw/fs-safe/dist/guest-native-python.js +52 -5
- package/node_modules/@openclaw/fs-safe/dist/guest.js +1 -1
- package/node_modules/@openclaw/fs-safe/dist/native-binding.d.ts +1 -0
- package/node_modules/@openclaw/fs-safe/dist/native-operations.d.ts +0 -1
- package/node_modules/@openclaw/fs-safe/dist/native-operations.js +22 -26
- package/node_modules/@openclaw/fs-safe/dist/native-pinned-write-windows.js +5 -1
- package/node_modules/@openclaw/fs-safe/dist/native-staged-file.js +4 -1
- package/node_modules/@openclaw/fs-safe/dist/permission-exec.js +2 -1
- package/node_modules/@openclaw/fs-safe/dist/pinned-write-types.d.ts +6 -1
- package/node_modules/@openclaw/fs-safe/dist/private-temp-workspace.js +2 -2
- package/node_modules/@openclaw/fs-safe/dist/publish-file.js +34 -7
- package/node_modules/@openclaw/fs-safe/dist/replace-file-copy-fallback.js +1 -4
- package/node_modules/@openclaw/fs-safe/dist/replace-file-descriptor.js +6 -0
- package/node_modules/@openclaw/fs-safe/dist/root-create-input.d.ts +15 -1
- package/node_modules/@openclaw/fs-safe/dist/root-create-input.js +4 -0
- package/node_modules/@openclaw/fs-safe/dist/root-directory-entry.js +1 -1
- package/node_modules/@openclaw/fs-safe/dist/root-directory-list.d.ts +0 -1
- package/node_modules/@openclaw/fs-safe/dist/root-directory-list.js +6 -12
- package/node_modules/@openclaw/fs-safe/dist/root-impl.js +15 -15
- package/node_modules/@openclaw/fs-safe/dist/root-paths.js +1 -1
- package/node_modules/@openclaw/fs-safe/dist/root-walk.js +4 -4
- package/node_modules/@openclaw/fs-safe/dist/root-write-verification.d.ts +10 -1
- package/node_modules/@openclaw/fs-safe/dist/root-write-verification.js +20 -0
- package/node_modules/@openclaw/fs-safe/dist/secure-temp-dir.js +19 -7
- package/node_modules/@openclaw/fs-safe/dist/sidecar-lock-acquire.js +25 -3
- package/node_modules/@openclaw/fs-safe/dist/sidecar-lock-admission.d.ts +2 -0
- package/node_modules/@openclaw/fs-safe/dist/sidecar-lock-retained.d.ts +14 -0
- package/node_modules/@openclaw/fs-safe/dist/sidecar-lock-retained.js +187 -0
- package/node_modules/@openclaw/fs-safe/dist/sidecar-lock.js +15 -1
- package/node_modules/@openclaw/fs-safe/dist/temp-directory-diagnostics.d.ts +10 -0
- package/node_modules/@openclaw/fs-safe/dist/temp-directory-diagnostics.js +29 -0
- package/node_modules/@openclaw/fs-safe/dist/temp-target.js +1 -1
- package/node_modules/@openclaw/fs-safe/dist/temp-workspace-admission.js +6 -6
- package/node_modules/@openclaw/fs-safe/dist/temp-workspace-child-admission.d.ts +4 -4
- package/node_modules/@openclaw/fs-safe/dist/temp-workspace-child-admission.js +17 -16
- package/node_modules/@openclaw/fs-safe/dist/temp-workspace-descriptor.js +20 -28
- package/node_modules/@openclaw/fs-safe/dist/walk.js +2 -13
- package/node_modules/@openclaw/fs-safe/dist/watch-native.d.ts +2 -2
- package/node_modules/@openclaw/fs-safe/dist/watch-native.js +3 -1
- package/node_modules/@openclaw/fs-safe/dist/watch-rescan.js +3 -9
- package/node_modules/@openclaw/fs-safe/dist/watch.js +2 -3
- package/node_modules/@openclaw/fs-safe/docs/advanced.md +1 -1
- package/node_modules/@openclaw/fs-safe/docs/archive.md +3 -0
- package/node_modules/@openclaw/fs-safe/docs/atomic.md +11 -3
- package/node_modules/@openclaw/fs-safe/docs/contributing.md +1 -1
- package/node_modules/@openclaw/fs-safe/docs/copy.md +48 -0
- package/node_modules/@openclaw/fs-safe/docs/guest.md +21 -4
- package/node_modules/@openclaw/fs-safe/docs/path-scope.md +4 -0
- package/node_modules/@openclaw/fs-safe/docs/sidecar-lock.md +46 -8
- package/node_modules/@openclaw/fs-safe/docs/temp.md +12 -0
- package/node_modules/@openclaw/fs-safe/docs/watch.md +3 -2
- package/node_modules/@openclaw/fs-safe/package.json +15 -15
- package/node_modules/@openclaw/fs-safe-darwin-arm64/fs-safe-native.node +0 -0
- package/node_modules/@openclaw/fs-safe-darwin-arm64/package.json +1 -1
- package/node_modules/@openclaw/fs-safe-darwin-x64/fs-safe-native.node +0 -0
- package/node_modules/@openclaw/fs-safe-darwin-x64/package.json +1 -1
- 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 +1 -1
- 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 +1 -1
- 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 +1 -1
- 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 +1 -1
- 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 +1 -1
- package/node_modules/follow-redirects/index.js +10 -1
- package/node_modules/follow-redirects/package.json +1 -1
- package/node_modules/mdast-util-to-markdown/index.d.ts +2 -0
- package/node_modules/mdast-util-to-markdown/lib/configure.d.ts +5 -0
- package/node_modules/mdast-util-to-markdown/lib/configure.d.ts.map +1 -1
- package/node_modules/mdast-util-to-markdown/lib/configure.js +19 -0
- package/node_modules/mdast-util-to-markdown/lib/handle/blockquote.d.ts +7 -0
- package/node_modules/mdast-util-to-markdown/lib/handle/blockquote.d.ts.map +1 -1
- package/node_modules/mdast-util-to-markdown/lib/handle/blockquote.js +12 -1
- package/node_modules/mdast-util-to-markdown/lib/handle/break.d.ts +7 -0
- package/node_modules/mdast-util-to-markdown/lib/handle/break.d.ts.map +1 -1
- package/node_modules/mdast-util-to-markdown/lib/handle/break.js +16 -5
- package/node_modules/mdast-util-to-markdown/lib/handle/code.d.ts +7 -0
- package/node_modules/mdast-util-to-markdown/lib/handle/code.d.ts.map +1 -1
- package/node_modules/mdast-util-to-markdown/lib/handle/code.js +13 -2
- package/node_modules/mdast-util-to-markdown/lib/handle/definition.d.ts +7 -0
- package/node_modules/mdast-util-to-markdown/lib/handle/definition.d.ts.map +1 -1
- package/node_modules/mdast-util-to-markdown/lib/handle/definition.js +7 -0
- package/node_modules/mdast-util-to-markdown/lib/handle/emphasis.d.ts +30 -2
- package/node_modules/mdast-util-to-markdown/lib/handle/emphasis.d.ts.map +1 -1
- package/node_modules/mdast-util-to-markdown/lib/handle/emphasis.js +39 -41
- package/node_modules/mdast-util-to-markdown/lib/handle/heading.d.ts +7 -0
- package/node_modules/mdast-util-to-markdown/lib/handle/heading.d.ts.map +1 -1
- package/node_modules/mdast-util-to-markdown/lib/handle/heading.js +11 -2
- package/node_modules/mdast-util-to-markdown/lib/handle/html.d.ts +7 -0
- package/node_modules/mdast-util-to-markdown/lib/handle/html.d.ts.map +1 -1
- package/node_modules/mdast-util-to-markdown/lib/handle/html.js +7 -0
- package/node_modules/mdast-util-to-markdown/lib/handle/image-reference.d.ts +10 -0
- package/node_modules/mdast-util-to-markdown/lib/handle/image-reference.d.ts.map +1 -1
- package/node_modules/mdast-util-to-markdown/lib/handle/image-reference.js +17 -2
- package/node_modules/mdast-util-to-markdown/lib/handle/image.d.ts +10 -0
- package/node_modules/mdast-util-to-markdown/lib/handle/image.d.ts.map +1 -1
- package/node_modules/mdast-util-to-markdown/lib/handle/image.js +10 -0
- package/node_modules/mdast-util-to-markdown/lib/handle/inline-code.d.ts +9 -0
- package/node_modules/mdast-util-to-markdown/lib/handle/inline-code.d.ts.map +1 -1
- package/node_modules/mdast-util-to-markdown/lib/handle/inline-code.js +14 -4
- package/node_modules/mdast-util-to-markdown/lib/handle/link-reference.d.ts +10 -0
- package/node_modules/mdast-util-to-markdown/lib/handle/link-reference.d.ts.map +1 -1
- package/node_modules/mdast-util-to-markdown/lib/handle/link-reference.js +17 -2
- package/node_modules/mdast-util-to-markdown/lib/handle/link.d.ts +13 -0
- package/node_modules/mdast-util-to-markdown/lib/handle/link.d.ts.map +1 -1
- package/node_modules/mdast-util-to-markdown/lib/handle/link.js +24 -9
- package/node_modules/mdast-util-to-markdown/lib/handle/list-item.d.ts +7 -0
- package/node_modules/mdast-util-to-markdown/lib/handle/list-item.d.ts.map +1 -1
- package/node_modules/mdast-util-to-markdown/lib/handle/list-item.js +12 -1
- package/node_modules/mdast-util-to-markdown/lib/handle/list.d.ts +7 -0
- package/node_modules/mdast-util-to-markdown/lib/handle/list.d.ts.map +1 -1
- package/node_modules/mdast-util-to-markdown/lib/handle/list.js +7 -0
- package/node_modules/mdast-util-to-markdown/lib/handle/paragraph.d.ts +7 -0
- package/node_modules/mdast-util-to-markdown/lib/handle/paragraph.d.ts.map +1 -1
- package/node_modules/mdast-util-to-markdown/lib/handle/paragraph.js +7 -0
- package/node_modules/mdast-util-to-markdown/lib/handle/root.d.ts +7 -0
- package/node_modules/mdast-util-to-markdown/lib/handle/root.d.ts.map +1 -1
- package/node_modules/mdast-util-to-markdown/lib/handle/root.js +13 -2
- package/node_modules/mdast-util-to-markdown/lib/handle/strong.d.ts +30 -2
- package/node_modules/mdast-util-to-markdown/lib/handle/strong.d.ts.map +1 -1
- package/node_modules/mdast-util-to-markdown/lib/handle/strong.js +39 -41
- package/node_modules/mdast-util-to-markdown/lib/handle/text.d.ts +7 -0
- package/node_modules/mdast-util-to-markdown/lib/handle/text.d.ts.map +1 -1
- package/node_modules/mdast-util-to-markdown/lib/handle/text.js +7 -0
- package/node_modules/mdast-util-to-markdown/lib/handle/thematic-break.d.ts +6 -0
- package/node_modules/mdast-util-to-markdown/lib/handle/thematic-break.d.ts.map +1 -1
- package/node_modules/mdast-util-to-markdown/lib/handle/thematic-break.js +6 -0
- package/node_modules/mdast-util-to-markdown/lib/index.d.ts.map +1 -1
- package/node_modules/mdast-util-to-markdown/lib/index.js +34 -8
- package/node_modules/mdast-util-to-markdown/lib/join.d.ts.map +1 -1
- package/node_modules/mdast-util-to-markdown/lib/join.js +18 -1
- package/node_modules/mdast-util-to-markdown/lib/types.d.ts +50 -30
- package/node_modules/mdast-util-to-markdown/lib/unsafe.d.ts.map +1 -1
- package/node_modules/mdast-util-to-markdown/lib/unsafe.js +15 -1
- package/node_modules/mdast-util-to-markdown/lib/util/character.d.ts +23 -0
- package/node_modules/mdast-util-to-markdown/lib/util/character.d.ts.map +1 -0
- package/node_modules/mdast-util-to-markdown/lib/util/character.js +32 -0
- package/node_modules/mdast-util-to-markdown/lib/util/check-bullet-ordered.d.ts +4 -0
- package/node_modules/mdast-util-to-markdown/lib/util/check-bullet-ordered.d.ts.map +1 -1
- package/node_modules/mdast-util-to-markdown/lib/util/check-bullet-ordered.js +4 -0
- package/node_modules/mdast-util-to-markdown/lib/util/check-bullet-other.d.ts +4 -0
- package/node_modules/mdast-util-to-markdown/lib/util/check-bullet-other.d.ts.map +1 -1
- package/node_modules/mdast-util-to-markdown/lib/util/check-bullet-other.js +4 -0
- package/node_modules/mdast-util-to-markdown/lib/util/check-bullet.d.ts +4 -0
- package/node_modules/mdast-util-to-markdown/lib/util/check-bullet.d.ts.map +1 -1
- package/node_modules/mdast-util-to-markdown/lib/util/check-bullet.js +4 -0
- package/node_modules/mdast-util-to-markdown/lib/util/check-emphasis.d.ts +4 -0
- package/node_modules/mdast-util-to-markdown/lib/util/check-emphasis.d.ts.map +1 -1
- package/node_modules/mdast-util-to-markdown/lib/util/check-emphasis.js +4 -0
- package/node_modules/mdast-util-to-markdown/lib/util/check-fence.d.ts +4 -0
- package/node_modules/mdast-util-to-markdown/lib/util/check-fence.d.ts.map +1 -1
- package/node_modules/mdast-util-to-markdown/lib/util/check-fence.js +4 -0
- package/node_modules/mdast-util-to-markdown/lib/util/check-list-item-indent.d.ts +4 -0
- package/node_modules/mdast-util-to-markdown/lib/util/check-list-item-indent.d.ts.map +1 -1
- package/node_modules/mdast-util-to-markdown/lib/util/check-list-item-indent.js +4 -0
- package/node_modules/mdast-util-to-markdown/lib/util/check-quote.d.ts +4 -0
- package/node_modules/mdast-util-to-markdown/lib/util/check-quote.d.ts.map +1 -1
- package/node_modules/mdast-util-to-markdown/lib/util/check-quote.js +4 -0
- package/node_modules/mdast-util-to-markdown/lib/util/check-rule-repetition.d.ts +4 -0
- package/node_modules/mdast-util-to-markdown/lib/util/check-rule-repetition.d.ts.map +1 -1
- package/node_modules/mdast-util-to-markdown/lib/util/check-rule-repetition.js +4 -0
- package/node_modules/mdast-util-to-markdown/lib/util/check-rule.d.ts +4 -0
- package/node_modules/mdast-util-to-markdown/lib/util/check-rule.d.ts.map +1 -1
- package/node_modules/mdast-util-to-markdown/lib/util/check-rule.js +4 -0
- package/node_modules/mdast-util-to-markdown/lib/util/check-strong.d.ts +4 -0
- package/node_modules/mdast-util-to-markdown/lib/util/check-strong.d.ts.map +1 -1
- package/node_modules/mdast-util-to-markdown/lib/util/check-strong.js +4 -0
- package/node_modules/mdast-util-to-markdown/lib/util/compile-pattern.js +3 -1
- package/node_modules/mdast-util-to-markdown/lib/util/container-flow.d.ts +2 -0
- package/node_modules/mdast-util-to-markdown/lib/util/container-flow.d.ts.map +1 -1
- package/node_modules/mdast-util-to-markdown/lib/util/container-flow.js +9 -0
- package/node_modules/mdast-util-to-markdown/lib/util/container-phrasing.d.ts +95 -4
- package/node_modules/mdast-util-to-markdown/lib/util/container-phrasing.d.ts.map +1 -1
- package/node_modules/mdast-util-to-markdown/lib/util/container-phrasing.js +636 -57
- package/node_modules/mdast-util-to-markdown/lib/util/encode-info.d.ts +2 -2
- package/node_modules/mdast-util-to-markdown/lib/util/encode-info.d.ts.map +1 -1
- package/node_modules/mdast-util-to-markdown/lib/util/encode-info.js +1 -1
- package/node_modules/mdast-util-to-markdown/lib/util/format-code-as-indented.d.ts +5 -0
- package/node_modules/mdast-util-to-markdown/lib/util/format-code-as-indented.d.ts.map +1 -1
- package/node_modules/mdast-util-to-markdown/lib/util/format-code-as-indented.js +12 -7
- package/node_modules/mdast-util-to-markdown/lib/util/format-heading-as-setext.d.ts +5 -0
- package/node_modules/mdast-util-to-markdown/lib/util/format-heading-as-setext.d.ts.map +1 -1
- package/node_modules/mdast-util-to-markdown/lib/util/format-heading-as-setext.js +7 -2
- package/node_modules/mdast-util-to-markdown/lib/util/format-link-as-autolink.d.ts +5 -0
- package/node_modules/mdast-util-to-markdown/lib/util/format-link-as-autolink.d.ts.map +1 -1
- package/node_modules/mdast-util-to-markdown/lib/util/format-link-as-autolink.js +20 -15
- package/node_modules/mdast-util-to-markdown/lib/util/html-kind.d.ts +31 -0
- package/node_modules/mdast-util-to-markdown/lib/util/html-kind.d.ts.map +1 -0
- package/node_modules/mdast-util-to-markdown/lib/util/html-kind.js +63 -0
- package/node_modules/mdast-util-to-markdown/lib/util/indent-lines.js +5 -0
- package/node_modules/mdast-util-to-markdown/lib/util/pattern-in-scope.d.ts +5 -0
- package/node_modules/mdast-util-to-markdown/lib/util/pattern-in-scope.d.ts.map +1 -1
- package/node_modules/mdast-util-to-markdown/lib/util/pattern-in-scope.js +11 -0
- package/node_modules/mdast-util-to-markdown/lib/util/safe.d.ts +2 -2
- package/node_modules/mdast-util-to-markdown/lib/util/safe.d.ts.map +1 -1
- package/node_modules/mdast-util-to-markdown/lib/util/safe.js +71 -7
- package/node_modules/mdast-util-to-markdown/package.json +13 -57
- package/node_modules/mdast-util-to-markdown/readme.md +139 -84
- package/node_modules/micromark/dev/lib/compile.d.ts.map +1 -1
- package/node_modules/micromark/dev/lib/compile.js +14 -4
- package/node_modules/micromark/dev/lib/create-tokenizer.d.ts.map +1 -1
- package/node_modules/micromark/dev/lib/create-tokenizer.js +7 -6
- package/node_modules/micromark/dev/lib/initialize/document.js +25 -21
- package/node_modules/micromark/dev/lib/initialize/text.d.ts.map +1 -1
- package/node_modules/micromark/dev/lib/initialize/text.js +10 -6
- package/node_modules/micromark/dev/lib/preprocess.d.ts.map +1 -1
- package/node_modules/micromark/dev/lib/preprocess.js +19 -21
- package/node_modules/micromark/lib/compile.d.ts.map +1 -1
- package/node_modules/micromark/lib/compile.js +37 -29
- package/node_modules/micromark/lib/create-tokenizer.d.ts.map +1 -1
- package/node_modules/micromark/lib/create-tokenizer.js +37 -35
- package/node_modules/micromark/lib/initialize/document.js +21 -13
- package/node_modules/micromark/lib/initialize/text.d.ts.map +1 -1
- package/node_modules/micromark/lib/initialize/text.js +7 -3
- package/node_modules/micromark/lib/preprocess.d.ts.map +1 -1
- package/node_modules/micromark/lib/preprocess.js +16 -19
- package/node_modules/micromark/package.json +2 -15
- package/node_modules/micromark-core-commonmark/dev/lib/attention.js +18 -24
- package/node_modules/micromark-core-commonmark/dev/lib/code-fenced.d.ts.map +1 -1
- package/node_modules/micromark-core-commonmark/dev/lib/code-fenced.js +1 -43
- package/node_modules/micromark-core-commonmark/dev/lib/code-indented.js +19 -43
- package/node_modules/micromark-core-commonmark/dev/lib/heading-atx.js +2 -6
- package/node_modules/micromark-core-commonmark/dev/lib/html-flow.d.ts.map +1 -1
- package/node_modules/micromark-core-commonmark/dev/lib/html-flow.js +2 -53
- package/node_modules/micromark-core-commonmark/dev/lib/label-end.js +14 -12
- package/node_modules/micromark-core-commonmark/dev/lib/label-start-image.d.ts.map +1 -1
- package/node_modules/micromark-core-commonmark/dev/lib/label-start-image.js +14 -5
- package/node_modules/micromark-core-commonmark/dev/lib/label-start-link.d.ts.map +1 -1
- package/node_modules/micromark-core-commonmark/dev/lib/label-start-link.js +14 -5
- package/node_modules/micromark-core-commonmark/dev/lib/partial-non-lazy-continuation.d.ts +4 -0
- package/node_modules/micromark-core-commonmark/dev/lib/partial-non-lazy-continuation.d.ts.map +1 -0
- package/node_modules/micromark-core-commonmark/dev/lib/partial-non-lazy-continuation.js +67 -0
- package/node_modules/micromark-core-commonmark/dev/lib/setext-underline.d.ts.map +1 -1
- package/node_modules/micromark-core-commonmark/dev/lib/setext-underline.js +8 -5
- package/node_modules/micromark-core-commonmark/lib/attention.js +14 -24
- package/node_modules/micromark-core-commonmark/lib/code-fenced.d.ts.map +1 -1
- package/node_modules/micromark-core-commonmark/lib/code-fenced.js +1 -39
- package/node_modules/micromark-core-commonmark/lib/code-indented.js +11 -29
- package/node_modules/micromark-core-commonmark/lib/heading-atx.js +2 -6
- package/node_modules/micromark-core-commonmark/lib/html-flow.d.ts.map +1 -1
- package/node_modules/micromark-core-commonmark/lib/html-flow.js +2 -51
- package/node_modules/micromark-core-commonmark/lib/label-end.js +11 -10
- package/node_modules/micromark-core-commonmark/lib/label-start-image.d.ts.map +1 -1
- package/node_modules/micromark-core-commonmark/lib/label-start-image.js +11 -3
- package/node_modules/micromark-core-commonmark/lib/label-start-link.d.ts.map +1 -1
- package/node_modules/micromark-core-commonmark/lib/label-start-link.js +11 -3
- package/node_modules/micromark-core-commonmark/lib/partial-non-lazy-continuation.d.ts +4 -0
- package/node_modules/micromark-core-commonmark/lib/partial-non-lazy-continuation.d.ts.map +1 -0
- package/node_modules/micromark-core-commonmark/lib/partial-non-lazy-continuation.js +61 -0
- package/node_modules/micromark-core-commonmark/lib/setext-underline.d.ts.map +1 -1
- package/node_modules/micromark-core-commonmark/lib/setext-underline.js +7 -5
- package/node_modules/micromark-core-commonmark/package.json +4 -16
- package/node_modules/micromark-factory-space/dev/index.d.ts +24 -1
- package/node_modules/micromark-factory-space/dev/index.d.ts.map +1 -1
- package/node_modules/micromark-factory-space/dev/index.js +58 -3
- package/node_modules/micromark-factory-space/index.d.ts +24 -1
- package/node_modules/micromark-factory-space/index.d.ts.map +1 -1
- package/node_modules/micromark-factory-space/index.js +55 -3
- package/node_modules/micromark-factory-space/package.json +1 -10
- package/node_modules/micromark-factory-space/readme.md +25 -25
- package/node_modules/micromark-util-edit-map/dev/index.d.ts +78 -0
- package/node_modules/micromark-util-edit-map/dev/index.d.ts.map +1 -0
- package/node_modules/micromark-util-edit-map/dev/index.js +237 -0
- package/node_modules/micromark-util-edit-map/index.d.ts +78 -0
- package/node_modules/micromark-util-edit-map/index.d.ts.map +1 -0
- package/node_modules/micromark-util-edit-map/index.js +225 -0
- package/node_modules/micromark-util-edit-map/license +22 -0
- package/node_modules/micromark-util-edit-map/package.json +48 -0
- package/node_modules/micromark-util-edit-map/readme.md +234 -0
- package/node_modules/micromark-util-types/index.d.ts +6 -3
- package/node_modules/micromark-util-types/package.json +2 -36
- package/node_modules/ws/lib/websocket.js +17 -3
- package/node_modules/ws/package.json +1 -1
- package/package.json +5 -5
- package/node_modules/@openclaw/fs-safe/dist/file-lock-sync-root-arbitration.d.ts +0 -17
- package/node_modules/@openclaw/fs-safe/dist/file-lock-sync-root-arbitration.js +0 -66
- package/node_modules/@openclaw/fs-safe/dist/publish-file-native.d.ts +0 -4
- package/node_modules/@openclaw/fs-safe/dist/publish-file-native.js +0 -35
- package/node_modules/@openclaw/fs-safe/dist/root-move-preflight.d.ts +0 -7
- package/node_modules/@openclaw/fs-safe/dist/root-move-preflight.js +0 -16
- package/node_modules/mdast-util-to-markdown/lib/util/emphasis-strong-marker.d.ts +0 -7
- package/node_modules/mdast-util-to-markdown/lib/util/emphasis-strong-marker.d.ts.map +0 -1
|
@@ -86,7 +86,6 @@ import { admitPathInsideRoot } from "./root-boundary.js";
|
|
|
86
86
|
import { listDirectoryPath, openRootDirectoryListing } from "./root-directory-list.js";
|
|
87
87
|
import { statResolvedPathInRoot } from "./root-path-stat.js";
|
|
88
88
|
import { entriesInRoot } from "./root-entries.js";
|
|
89
|
-
import { assertMoveMutationAllowed } from "./root-move-preflight.js";
|
|
90
89
|
import { assertRootIdentityCurrent, assertRootIdentityCurrentSync, assertValidRootDestinationPath, assertValidRootRelativePath, createRootObservationGuard, ensureTrailingSep, expandRelativePathWithHome, resolvePathInRoot, resolveRootContext, rootRelativeReadPath, } from "./root-context.js";
|
|
91
90
|
import { errorCauseOptions, fileNotFoundError, hardlinkedPathNotAllowedError, isAlreadyExistsError, normalizePinnedPathError, normalizePinnedWriteError, outsideWorkspaceError, } from "./root-errors.js";
|
|
92
91
|
import { getFsSafeTestHooks } from "./test-hooks.js";
|
|
@@ -96,7 +95,7 @@ import { registerTempPathForExit } from "./temp-cleanup.js";
|
|
|
96
95
|
import { removePathInRootFallback, validateRemoveOptions } from "./root-remove.js";
|
|
97
96
|
import { removePathInRootNative } from "./root-remove-native.js";
|
|
98
97
|
import { serializePathWrite } from "./write-queue.js";
|
|
99
|
-
import { verifyAtomicWriteResult } from "./root-write-verification.js";
|
|
98
|
+
import { verifyAtomicWriteResult, verifyRootWritePublication } from "./root-write-verification.js";
|
|
100
99
|
import { assertRootWritePathSelectionSync, assertRootWriteSelectionSync, createRootWriteSelectionForFd, prepareGuardedRootWritePathSelection, resolveGuardedWritePathInRoot, resolveGuardedWriteTargetInRoot, resolvePinnedWriteTargetInRoot, refreshRetainedRootWriteAdmission, refreshRootWritePathSelection, } from "./root-write-admission.js";
|
|
101
100
|
import { prepareSharedRootWriteTarget } from "./root-write-complete-parent.js";
|
|
102
101
|
import { finishRootFallbackWrite } from "./root-write-publication.js";
|
|
@@ -107,7 +106,7 @@ import { admitMoveSourceStat, movePathNative } from "./root-move-noreplace.js";
|
|
|
107
106
|
import { admitRootReadHandle, inspectOpenedPathIdentitySync } from "./root-read-admission.js";
|
|
108
107
|
import { createCopyPublicationObserver, onCopyPublication, onCopySourceAdmission } from "./copy-publication.js";
|
|
109
108
|
import { writeAllToFile } from "./write-file-handle.js";
|
|
110
|
-
import { createInputOptions, rethrowCreateInputError, rootWriteInput } from "./root-create-input.js";
|
|
109
|
+
import { createInputOptions, rethrowCreateInputError, rootWriteInput, retainSidecarCreated } from "./root-create-input.js";
|
|
111
110
|
import { assertFinalSymlinkRejected, mutationSymlinkResolution, readSymlinkResolution } from "./root-symlink-policy.js";
|
|
112
111
|
import { assertExclusiveCreateLeaf } from "./exclusive-create.js";
|
|
113
112
|
import { assertNoWindowsPathAlias, resolvePathPreservingWindowsRoot } from "./windows-path-alias.js";
|
|
@@ -390,11 +389,14 @@ export class RootHandle {
|
|
|
390
389
|
const { denyMutations, mutationSymlinks } = snapshotPinnedMutationPolicy(mutationOptions.denyMutations, mutationOptions.mutationSymlinks) ?? {};
|
|
391
390
|
const overwrite = options.overwrite ?? false;
|
|
392
391
|
const requireNative = isFsSafeNativeRequired();
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
392
|
+
// Deny both routes before source alias or identity admission.
|
|
393
|
+
for (const relativePath of [fromRelative, toRelative]) {
|
|
394
|
+
const { resolved } = await resolvePathInRoot(this.context, relativePath, {
|
|
395
|
+
aliasErrorCode: "path-alias",
|
|
396
|
+
allowFinalSymlink: true,
|
|
397
|
+
});
|
|
398
|
+
await assertMutationNotDenied(resolved, denyMutations, { protectAncestors: true });
|
|
399
|
+
}
|
|
398
400
|
await movePathFallback(this.context, {
|
|
399
401
|
requireNative,
|
|
400
402
|
fromRelative,
|
|
@@ -934,15 +936,13 @@ async function commitPinnedWriteInRoot(root, pinned, params, input) {
|
|
|
934
936
|
rootIdentity: root.rootIdentity,
|
|
935
937
|
mutationAdmission: pinned.mutationAdmission,
|
|
936
938
|
assertBeforeMutation: params.assertBeforeMutation,
|
|
937
|
-
verifyPublished: async (fd, expectedIdentity, parentGuard) => {
|
|
939
|
+
verifyPublished: async (fd, expectedIdentity, parentGuard, nativeParent) => {
|
|
938
940
|
verifyingPublication = true;
|
|
939
941
|
try {
|
|
940
|
-
await
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
fd,
|
|
944
|
-
expectedIdentity,
|
|
945
|
-
parentGuard,
|
|
942
|
+
await verifyRootWritePublication({
|
|
943
|
+
fd, expectedIdentity, parentGuard,
|
|
944
|
+
nativeParent, retention: params[retainSidecarCreated],
|
|
945
|
+
verify: () => verifyAtomicWriteResult({ root, targetPath: pinned.targetPath, fd, expectedIdentity, parentGuard }),
|
|
946
946
|
});
|
|
947
947
|
}
|
|
948
948
|
catch (error) {
|
|
@@ -244,7 +244,7 @@ async function resolveCheckedPathsWithinRoot(params, allowMissingFallback) {
|
|
|
244
244
|
if (!root) {
|
|
245
245
|
throw new FsSafeError("not-found", "root dir not found");
|
|
246
246
|
}
|
|
247
|
-
opened = await root.open(pathResult.relativePath);
|
|
247
|
+
opened = await root.open(`./${pathResult.relativePath}`);
|
|
248
248
|
resolvedPaths.push(opened.realPath);
|
|
249
249
|
}
|
|
250
250
|
catch (err) {
|
|
@@ -136,7 +136,9 @@ export async function* walkRoot(root, relativePath, options) {
|
|
|
136
136
|
let failed = false;
|
|
137
137
|
let operationError;
|
|
138
138
|
try {
|
|
139
|
-
const relativeDirectory = directory.split(path.sep).join(path.posix.sep);
|
|
139
|
+
const relativeDirectory = path.posix.normalize(directory.split(path.sep).join(path.posix.sep));
|
|
140
|
+
const childPrefix = relativeDirectory === "." || relativeDirectory === "./" ? ""
|
|
141
|
+
: relativeDirectory.endsWith("/") ? relativeDirectory : `${relativeDirectory}/`;
|
|
140
142
|
while (true) {
|
|
141
143
|
let next;
|
|
142
144
|
try {
|
|
@@ -150,9 +152,7 @@ export async function* walkRoot(root, relativePath, options) {
|
|
|
150
152
|
if (next === undefined)
|
|
151
153
|
return;
|
|
152
154
|
const name = next.kind === "entry" ? next.entry.name : next.name;
|
|
153
|
-
const child =
|
|
154
|
-
? path.posix.join(relativeDirectory, name)
|
|
155
|
-
: name;
|
|
155
|
+
const child = childPrefix + name;
|
|
156
156
|
if (next.kind === "limit") {
|
|
157
157
|
yield onLimit(child);
|
|
158
158
|
return;
|
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
import { type AnyAsyncDirectoryGuard } from "./directory-guard.js";
|
|
2
|
-
import type { PublishedWriteIdentity } from "./pinned-write-types.js";
|
|
2
|
+
import type { NativeWriteParent, PublishedWriteIdentity } from "./pinned-write-types.js";
|
|
3
|
+
import type { SidecarCreationRetention } from "./root-create-input.js";
|
|
3
4
|
import { type RootContext } from "./root-context.js";
|
|
5
|
+
export declare function verifyRootWritePublication(params: {
|
|
6
|
+
fd: number;
|
|
7
|
+
expectedIdentity: PublishedWriteIdentity;
|
|
8
|
+
parentGuard: AnyAsyncDirectoryGuard;
|
|
9
|
+
nativeParent?: NativeWriteParent;
|
|
10
|
+
retention?: SidecarCreationRetention;
|
|
11
|
+
verify(): Promise<void>;
|
|
12
|
+
}): Promise<void>;
|
|
4
13
|
export declare function verifyAtomicWriteResult(params: {
|
|
5
14
|
root: RootContext;
|
|
6
15
|
targetPath: string;
|
|
@@ -5,10 +5,30 @@ import { FsSafeError } from "./errors.js";
|
|
|
5
5
|
import { sameFileIdentity } from "./file-identity.js";
|
|
6
6
|
import { resolveOpenedFileRealPathForFd } from "./opened-realpath.js";
|
|
7
7
|
import { assertNoUnsafeDeviceReadPath, hasNodeErrorCode, isNotFoundPathError, isSymlinkOpenError } from "./path.js";
|
|
8
|
+
import { createSuppressedError } from "./suppressed-error.js";
|
|
8
9
|
import { resolveReadOpenFlags } from "./read-open-flags.js";
|
|
9
10
|
import { assertRootIdentityCurrent } from "./root-context.js";
|
|
10
11
|
import { fileNotFoundError, hardlinkedPathNotAllowedError, outsideWorkspaceError } from "./root-errors.js";
|
|
11
12
|
import { admitPathInsideRoot } from "./root-boundary.js";
|
|
13
|
+
export async function verifyRootWritePublication(params) {
|
|
14
|
+
try {
|
|
15
|
+
await params.verify();
|
|
16
|
+
params.retention?.retain(params.fd, params.parentGuard, params.nativeParent);
|
|
17
|
+
}
|
|
18
|
+
catch (error) {
|
|
19
|
+
if (params.retention && params.nativeParent) {
|
|
20
|
+
// Publication already happened. The creator still owns these descriptors
|
|
21
|
+
// even if opening an additional retained handle failed.
|
|
22
|
+
try {
|
|
23
|
+
params.retention.cleanup(params.fd, params.nativeParent, params.expectedIdentity);
|
|
24
|
+
}
|
|
25
|
+
catch (cleanupError) {
|
|
26
|
+
throw createSuppressedError(cleanupError, error, "sidecar retention and creator cleanup both failed");
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
throw error;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
12
32
|
export async function verifyAtomicWriteResult(params) {
|
|
13
33
|
let needsPathOpen = false;
|
|
14
34
|
const assertFile = (stat) => {
|
|
@@ -6,6 +6,7 @@ import { recursiveMkdirPath } from "./recursive-mkdir-path.js";
|
|
|
6
6
|
import { hasNodeErrorCode } from "./path.js";
|
|
7
7
|
import { assertSafePathSegment } from "./safe-path-segment.js";
|
|
8
8
|
import { assertNoWindowsPathAlias, pathForWindowsFilesystem } from "./windows-path-alias.js";
|
|
9
|
+
import { privateTempDirectoryFix, secureTempDirectoryFailure } from "./temp-directory-diagnostics.js";
|
|
9
10
|
import { captureSecureTempRepairAdapter, repairSecureTempDirectory, secureTempDirectoryReceipt, } from "./secure-temp-repair.js";
|
|
10
11
|
export function resolveSecureTempRoot(options) {
|
|
11
12
|
const { fallbackPrefix: prefix, accessSync: suppliedAccess, lstatSync: suppliedLstat, mkdirSync: suppliedMkdir, descriptor: suppliedDescriptor, getuid: suppliedGetuid, tmpdir: suppliedTmpdir, platform: suppliedPlatform, preferredDir, skipPreferredOnWindows, warn: suppliedWarn, warningPrefix: suppliedWarningPrefix, unsafeFallbackLabel: suppliedFallbackLabel, } = options;
|
|
@@ -82,8 +83,17 @@ export function resolveSecureTempRoot(options) {
|
|
|
82
83
|
candidate = lstatSync(candidatePath);
|
|
83
84
|
}
|
|
84
85
|
catch (error) {
|
|
85
|
-
return { kind: hasNodeErrorCode(error, "ENOENT") ? "missing" : "invalid", error
|
|
86
|
+
return { kind: hasNodeErrorCode(error, "ENOENT") ? "missing" : "invalid", error,
|
|
87
|
+
detail: `directory metadata could not be read; check path traversal/access permissions; ${privateTempDirectoryFix(uid)}` };
|
|
86
88
|
}
|
|
89
|
+
const failureDetail = () => {
|
|
90
|
+
try {
|
|
91
|
+
return secureTempDirectoryFailure(candidate, uid, windows);
|
|
92
|
+
}
|
|
93
|
+
catch {
|
|
94
|
+
return `directory security facts could not be read; ${privateTempDirectoryFix(uid)}`;
|
|
95
|
+
}
|
|
96
|
+
};
|
|
87
97
|
let receipt;
|
|
88
98
|
try {
|
|
89
99
|
if (descriptor && uid !== undefined) {
|
|
@@ -91,26 +101,28 @@ export function resolveSecureTempRoot(options) {
|
|
|
91
101
|
}
|
|
92
102
|
if (receipt ? (receipt.mode & 18n) !== 0n :
|
|
93
103
|
candidate.isDirectory() !== true || candidate.isSymbolicLink() !== false || !isSecureDirForUser(candidate)) {
|
|
94
|
-
return { kind: "invalid", receipt };
|
|
104
|
+
return { kind: "invalid", receipt, detail: failureDetail() };
|
|
95
105
|
}
|
|
96
106
|
accessSync(candidatePath, TMP_DIR_ACCESS_MODE);
|
|
97
107
|
return { kind: "available", receipt };
|
|
98
108
|
}
|
|
99
109
|
catch (error) {
|
|
100
|
-
return { kind: "invalid", receipt, error };
|
|
110
|
+
return { kind: "invalid", receipt, error, detail: failureDetail() };
|
|
101
111
|
}
|
|
102
112
|
};
|
|
103
113
|
const tryRepair = (candidatePath, state, finalize = false) => {
|
|
104
114
|
assertNoWindowsPathAlias(candidatePath, "filesystem", "temp directory uses a Windows filesystem namespace alias", admissionPlatform);
|
|
105
115
|
if (!descriptor || uid === undefined || !state.receipt) {
|
|
106
|
-
return finalize ? { kind: "invalid", error: new Error("Secure temp descriptor finalization is unavailable.")
|
|
116
|
+
return finalize ? { ...state, kind: "invalid", error: new Error("Secure temp descriptor finalization is unavailable."),
|
|
117
|
+
detail: `descriptor finalization is unavailable; ${privateTempDirectoryFix(uid)}` } : state;
|
|
107
118
|
}
|
|
108
119
|
try {
|
|
109
120
|
repairSecureTempDirectory(candidatePath, state.receipt, uid, descriptor, () => accessSync(candidatePath, TMP_DIR_ACCESS_MODE), () => warn(`${warningPrefix} tightened permissions on temp dir: ${candidatePath}`), finalize);
|
|
110
121
|
return { kind: "available" };
|
|
111
122
|
}
|
|
112
123
|
catch (error) {
|
|
113
|
-
return { kind: "invalid", error
|
|
124
|
+
return { kind: "invalid", error,
|
|
125
|
+
detail: state.detail ?? `descriptor identity, permissions, or access could not be verified during repair; ${privateTempDirectoryFix(uid)}` };
|
|
114
126
|
}
|
|
115
127
|
};
|
|
116
128
|
const ensureTrustedFallbackDir = () => {
|
|
@@ -128,7 +140,7 @@ export function resolveSecureTempRoot(options) {
|
|
|
128
140
|
finalize = !windows && (suppliedMkdir !== undefined || created !== undefined);
|
|
129
141
|
}
|
|
130
142
|
catch (cause) {
|
|
131
|
-
throw new Error(`Unable to create fallback ${unsafeFallbackLabel}: ${fallbackPath}`, { cause });
|
|
143
|
+
throw new Error(`Unable to create fallback ${unsafeFallbackLabel}: ${JSON.stringify(fallbackPath)}; check parent directory write/search access; ${privateTempDirectoryFix(uid)}`, { cause });
|
|
132
144
|
}
|
|
133
145
|
// A concurrent mkdir winner has no implicit ownership or mode authority.
|
|
134
146
|
state = resolveDirState(entryPath);
|
|
@@ -137,7 +149,7 @@ export function resolveSecureTempRoot(options) {
|
|
|
137
149
|
}
|
|
138
150
|
state = tryRepair(entryPath, state, finalize);
|
|
139
151
|
if (state.kind !== "available") {
|
|
140
|
-
throw new Error(`Unsafe fallback ${unsafeFallbackLabel}: ${fallbackPath}`, { cause: state.error });
|
|
152
|
+
throw new Error(`Unsafe fallback ${unsafeFallbackLabel}: ${JSON.stringify(fallbackPath)}; ${state.detail}`, { cause: state.error });
|
|
141
153
|
}
|
|
142
154
|
return fallbackPath;
|
|
143
155
|
};
|
|
@@ -2,6 +2,7 @@ import fsSync from "node:fs";
|
|
|
2
2
|
import fs from "node:fs/promises";
|
|
3
3
|
import { FsSafeError } from "./errors.js";
|
|
4
4
|
import { fileObservation } from "./file-observation.js";
|
|
5
|
+
import { sameFileIdentityForCleanup } from "./file-identity.js";
|
|
5
6
|
import { readFileHandleBounded } from "./bounded-read.js";
|
|
6
7
|
import { openSidecarRoot } from "./sidecar-lock-root.js";
|
|
7
8
|
import { createNativeExclusiveFile } from "./native-operations.js";
|
|
@@ -14,7 +15,8 @@ import { ancestryHasSidecarAdmission, captureSidecarAdmissionAncestry, createSid
|
|
|
14
15
|
import { resolveSidecarLockPaths } from "./sidecar-lock-target.js";
|
|
15
16
|
import { createSuppressedError } from "./suppressed-error.js";
|
|
16
17
|
import { sleep } from "./timing.js";
|
|
17
|
-
import {
|
|
18
|
+
import { sidecarRetainedCreate } from "./root-create-input.js";
|
|
19
|
+
import { cleanupCreatedSidecar, retainCreatedSidecar } from "./sidecar-lock-retained.js";
|
|
18
20
|
import { stopSidecarLockMonitoring } from "./sidecar-lock-handle.js";
|
|
19
21
|
export async function acquireSidecarLock(options, context) {
|
|
20
22
|
const admissionAncestry = captureSidecarAdmissionAncestry();
|
|
@@ -166,6 +168,7 @@ export async function acquireSidecarLock(options, context) {
|
|
|
166
168
|
continue;
|
|
167
169
|
}
|
|
168
170
|
let handle = null;
|
|
171
|
+
let retainedSidecar;
|
|
169
172
|
let createdSnapshot = null, createdHeld;
|
|
170
173
|
let admissionConflict = false;
|
|
171
174
|
let exclusiveCreateConflict = false;
|
|
@@ -247,7 +250,13 @@ export async function acquireSidecarLock(options, context) {
|
|
|
247
250
|
const relativeLockPath = relativeSidecarLockPath(lockRoot, lockPath);
|
|
248
251
|
const observation = fileObservation();
|
|
249
252
|
try {
|
|
250
|
-
await observation.run(() => lockRoot.create(relativeLockPath, raw, {
|
|
253
|
+
await observation.run(() => lockRoot.create(relativeLockPath, raw, {
|
|
254
|
+
mkdir: true, mode: 0o600,
|
|
255
|
+
...sidecarRetainedCreate({
|
|
256
|
+
retain(fd, parent, nativeParent) { retainedSidecar = retainCreatedSidecar(lockPath, raw, fd, parent, nativeParent); },
|
|
257
|
+
cleanup(fd, parent, identity) { cleanupCreatedSidecar(lockPath, raw, fd, parent, identity); },
|
|
258
|
+
}),
|
|
259
|
+
}));
|
|
251
260
|
}
|
|
252
261
|
catch (error) {
|
|
253
262
|
// Only this invocation's failed exclusive open grants denial retry authority.
|
|
@@ -262,6 +271,7 @@ export async function acquireSidecarLock(options, context) {
|
|
|
262
271
|
createdSnapshot = { raw, payload, ownershipToken };
|
|
263
272
|
const opened = await openSidecarRoot(lockRoot, relativeLockPath, "unlinked");
|
|
264
273
|
if (!opened) {
|
|
274
|
+
retainedSidecar?.settle(true, false);
|
|
265
275
|
await waitForRetry();
|
|
266
276
|
continue;
|
|
267
277
|
}
|
|
@@ -299,7 +309,11 @@ export async function acquireSidecarLock(options, context) {
|
|
|
299
309
|
}
|
|
300
310
|
const snapshot = { raw, payload, stat: fsSync.fstatSync(handle.fd, { bigint: true }), ownershipToken };
|
|
301
311
|
createdSnapshot = snapshot;
|
|
312
|
+
if (retainedSidecar && !sameFileIdentityForCleanup(retainedSidecar.identity, snapshot.stat)) {
|
|
313
|
+
throw new FsSafeError("path-mismatch", "created sidecar lock identity changed before admission");
|
|
314
|
+
}
|
|
302
315
|
if (snapshot.stat.nlink === 0n) {
|
|
316
|
+
retainedSidecar?.settle(true, false);
|
|
303
317
|
await handle.close();
|
|
304
318
|
handle = null;
|
|
305
319
|
await waitForRetry();
|
|
@@ -310,10 +324,15 @@ export async function acquireSidecarLock(options, context) {
|
|
|
310
324
|
admissionConflict = true;
|
|
311
325
|
throw Object.assign(new Error("sidecar lock admission changed"), { code: "EEXIST" });
|
|
312
326
|
}
|
|
327
|
+
// An open descendant file prevents Windows directory relocation. The
|
|
328
|
+
// native receipt retains its parent and verifies the leaf at settlement.
|
|
329
|
+
if (retainedSidecar && process.platform === "win32")
|
|
330
|
+
await handle.close();
|
|
313
331
|
createdHeld = {
|
|
314
332
|
refCount: 1,
|
|
315
333
|
reentrantOwner: requestedReentrantOwner,
|
|
316
334
|
handle,
|
|
335
|
+
retainedSidecar,
|
|
317
336
|
lockPath,
|
|
318
337
|
snapshot,
|
|
319
338
|
acquiredAt: Date.now(),
|
|
@@ -380,7 +399,10 @@ export async function acquireSidecarLock(options, context) {
|
|
|
380
399
|
await handle.close().catch(() => undefined);
|
|
381
400
|
}
|
|
382
401
|
// Root records use the creator receipt; partial raw writes use fd identity.
|
|
383
|
-
if (
|
|
402
|
+
if (retainedSidecar) {
|
|
403
|
+
retainedSidecar.settle(true, false);
|
|
404
|
+
}
|
|
405
|
+
else if (failedSnapshot) {
|
|
384
406
|
await removeSidecarLockIfUnchanged(lockPath, failedSnapshot, {
|
|
385
407
|
lockRoot,
|
|
386
408
|
parsePayload: conditionalSidecarLockParser(parserState, admission, () => admission.hasToken() && !context.held.has(normalizedTargetPath)),
|
|
@@ -2,10 +2,12 @@ import type { NativeFileHandle } from "./native-operations.js";
|
|
|
2
2
|
import type { Root } from "./root-impl.js";
|
|
3
3
|
import type { SidecarLockSnapshot } from "./sidecar-lock-reclaim.js";
|
|
4
4
|
import type { SidecarLockHandle } from "./sidecar-lock-types.js";
|
|
5
|
+
import type { RetainedSidecar } from "./sidecar-lock-retained.js";
|
|
5
6
|
export type HeldSidecarLock = {
|
|
6
7
|
refCount: number;
|
|
7
8
|
reentrantOwner?: string;
|
|
8
9
|
handle: NativeFileHandle;
|
|
10
|
+
retainedSidecar?: RetainedSidecar;
|
|
9
11
|
lockPath: string;
|
|
10
12
|
snapshot: SidecarLockSnapshot;
|
|
11
13
|
acquiredAt: number;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { AnyAsyncDirectoryGuard } from "./directory-guard.js";
|
|
2
|
+
import type { NativeWriteParent, PublishedWriteIdentity } from "./pinned-write-types.js";
|
|
3
|
+
export interface RetainedSidecar {
|
|
4
|
+
readonly identity: Readonly<{
|
|
5
|
+
dev: bigint;
|
|
6
|
+
ino: bigint;
|
|
7
|
+
}>;
|
|
8
|
+
/** Synchronous settlement also works in the process exit handler. Always closes. */
|
|
9
|
+
settle(remove: boolean, reportMismatch?: boolean): void;
|
|
10
|
+
}
|
|
11
|
+
/** Borrowed creation authority: never reopens a path or closes the writer's fds. */
|
|
12
|
+
export declare function cleanupCreatedSidecar(lockPath: string, raw: string, fd: number, parent: NativeWriteParent, identity: PublishedWriteIdentity): void;
|
|
13
|
+
/** Called only by the exclusive creator while its verified descriptor is alive. */
|
|
14
|
+
export declare function retainCreatedSidecar(lockPath: string, raw: string, createdFd: number, guard: AnyAsyncDirectoryGuard, nativeParent?: NativeWriteParent): RetainedSidecar | undefined;
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { FsSafeError } from "./errors.js";
|
|
4
|
+
import { hasErrorCode } from "./file-cleanup.js";
|
|
5
|
+
import { captureNativeFdClose } from "./native-binding.js";
|
|
6
|
+
import { nativeOpenFlags } from "./native-operations.js";
|
|
7
|
+
import { sameFileIdentityForCleanup, sha256Hex } from "./file-identity.js";
|
|
8
|
+
function mismatch(check) {
|
|
9
|
+
return new FsSafeError("path-mismatch", `created sidecar lock ${check} changed; replacement preserved`);
|
|
10
|
+
}
|
|
11
|
+
function assertOwnerRecord(fd, expected) {
|
|
12
|
+
if (fs.fstatSync(fd, { bigint: true }).size !== BigInt(expected.length))
|
|
13
|
+
throw mismatch("owner record");
|
|
14
|
+
const bytes = Buffer.alloc(expected.length);
|
|
15
|
+
let offset = 0;
|
|
16
|
+
while (offset < bytes.length) {
|
|
17
|
+
const read = fs.readSync(fd, bytes, offset, bytes.length - offset, offset);
|
|
18
|
+
if (read === 0)
|
|
19
|
+
throw mismatch("owner record");
|
|
20
|
+
offset += read;
|
|
21
|
+
}
|
|
22
|
+
if (!bytes.equals(expected))
|
|
23
|
+
throw mismatch("owner record");
|
|
24
|
+
}
|
|
25
|
+
/** Borrowed creation authority: never reopens a path or closes the writer's fds. */
|
|
26
|
+
export function cleanupCreatedSidecar(lockPath, raw, fd, parent, identity) {
|
|
27
|
+
const name = path.basename(lockPath);
|
|
28
|
+
const windows = process.platform === "win32";
|
|
29
|
+
try {
|
|
30
|
+
if (windows) {
|
|
31
|
+
if (!parent.binding.rootRemovalStat || !parent.binding.rootRemovalUnlink) {
|
|
32
|
+
throw new FsSafeError("helper-unavailable", "creator cleanup is unavailable");
|
|
33
|
+
}
|
|
34
|
+
const entry = parent.binding.rootRemovalStat(parent.fd, name);
|
|
35
|
+
if (entry.directory || entry.symlink || !sameFileIdentityForCleanup(identity, entry))
|
|
36
|
+
throw mismatch("identity");
|
|
37
|
+
}
|
|
38
|
+
else if (!parent.binding.stagedFileMatches || !parent.binding.removeStagedFile) {
|
|
39
|
+
throw new FsSafeError("helper-unavailable", "creator cleanup is unavailable");
|
|
40
|
+
}
|
|
41
|
+
else if (!parent.binding.stagedFileMatches(parent.fd, name, fd)) {
|
|
42
|
+
throw mismatch("identity");
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
if (hasErrorCode(error, "ENOENT"))
|
|
47
|
+
return;
|
|
48
|
+
throw error;
|
|
49
|
+
}
|
|
50
|
+
const stat = fs.fstatSync(fd, { bigint: true });
|
|
51
|
+
if (!stat.isFile() || stat.nlink !== 1n || !sameFileIdentityForCleanup(identity, stat))
|
|
52
|
+
throw mismatch("identity");
|
|
53
|
+
assertOwnerRecord(fd, Buffer.from(raw));
|
|
54
|
+
if (windows) {
|
|
55
|
+
try {
|
|
56
|
+
parent.binding.rootRemovalUnlink(parent.fd, name, identity.dev, identity.ino, false);
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
if (!hasErrorCode(error, "ENOENT"))
|
|
60
|
+
throw error;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
if (parent.binding.removeStagedFile(parent.fd, name, fd) === "preserved")
|
|
65
|
+
throw mismatch("identity");
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
/** Called only by the exclusive creator while its verified descriptor is alive. */
|
|
69
|
+
export function retainCreatedSidecar(lockPath, raw, createdFd, guard, nativeParent) {
|
|
70
|
+
const binding = nativeParent?.binding;
|
|
71
|
+
if (!binding)
|
|
72
|
+
return undefined;
|
|
73
|
+
const created = fs.fstatSync(createdFd, { bigint: true });
|
|
74
|
+
if (!created.isFile() || created.nlink !== 1n)
|
|
75
|
+
throw mismatch("identity");
|
|
76
|
+
const identity = Object.freeze({ dev: created.dev, ino: created.ino });
|
|
77
|
+
const name = path.basename(lockPath);
|
|
78
|
+
if (process.platform === "win32") {
|
|
79
|
+
if (!binding.retainWindowsSidecar)
|
|
80
|
+
return undefined;
|
|
81
|
+
const native = binding.retainWindowsSidecar(nativeParent.fd, guard.realPath, name, BigInt(guard.stat.dev), BigInt(guard.stat.ino), created.dev, created.ino, BigInt(Buffer.byteLength(raw)), sha256Hex(raw), 1024 * 1024);
|
|
82
|
+
const admitted = native.admission;
|
|
83
|
+
if (admitted.status === "unsupported" && admitted.resources === "closed")
|
|
84
|
+
return undefined;
|
|
85
|
+
if (admitted.status !== "retained") {
|
|
86
|
+
throw new FsSafeError("helper-failed", "could not retain created sidecar lock", { details: { result: admitted } });
|
|
87
|
+
}
|
|
88
|
+
return { identity, settle(remove, reportMismatch = true) {
|
|
89
|
+
const result = native.settle(remove);
|
|
90
|
+
if (result.status === "preserved-mismatch") {
|
|
91
|
+
if (reportMismatch || result.resources !== "closed") {
|
|
92
|
+
throw mismatch(result.errors.some(error => /digest|size changed/u.test(error.message)) ? "owner record" : "identity");
|
|
93
|
+
}
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
if (result.errors.length || result.resources !== "closed" ||
|
|
97
|
+
(remove && result.disposition !== "accepted" && result.namespace !== "absent")) {
|
|
98
|
+
throw new FsSafeError("helper-failed", "retained sidecar lock settlement failed", { details: { result } });
|
|
99
|
+
}
|
|
100
|
+
} };
|
|
101
|
+
}
|
|
102
|
+
if (!binding.stagedFileMatches || !binding.removeStagedFile)
|
|
103
|
+
return undefined;
|
|
104
|
+
const closeFile = captureNativeFdClose(binding);
|
|
105
|
+
const parentFd = binding.openBeneath(nativeParent.fd, "", nativeOpenFlags(fs.constants.O_RDONLY | fs.constants.O_DIRECTORY)).fd;
|
|
106
|
+
let fd;
|
|
107
|
+
try {
|
|
108
|
+
const parentStat = fs.fstatSync(parentFd, { bigint: true });
|
|
109
|
+
if (!parentStat.isDirectory() || !sameFileIdentityForCleanup(guard.stat, parentStat))
|
|
110
|
+
throw mismatch("identity");
|
|
111
|
+
fd = binding.openBeneath(parentFd, name, nativeOpenFlags(fs.constants.O_RDONLY | fs.constants.O_NONBLOCK)).fd;
|
|
112
|
+
const ownedFd = fd;
|
|
113
|
+
const assertIdentity = () => {
|
|
114
|
+
try {
|
|
115
|
+
if (!binding.stagedFileMatches(parentFd, name, ownedFd))
|
|
116
|
+
throw mismatch("identity");
|
|
117
|
+
}
|
|
118
|
+
catch (error) {
|
|
119
|
+
if (hasErrorCode(error, "ENOENT"))
|
|
120
|
+
return false;
|
|
121
|
+
throw error;
|
|
122
|
+
}
|
|
123
|
+
const current = fs.fstatSync(ownedFd, { bigint: true });
|
|
124
|
+
if (!current.isFile() || current.nlink !== 1n || !sameFileIdentityForCleanup(created, current))
|
|
125
|
+
throw mismatch("identity");
|
|
126
|
+
return true;
|
|
127
|
+
};
|
|
128
|
+
const expected = Buffer.from(raw);
|
|
129
|
+
const assertOwner = () => assertOwnerRecord(ownedFd, expected);
|
|
130
|
+
if (!assertIdentity())
|
|
131
|
+
throw mismatch("identity");
|
|
132
|
+
assertOwner();
|
|
133
|
+
let settled = false;
|
|
134
|
+
return { identity, settle(remove, reportMismatch = true) {
|
|
135
|
+
if (settled)
|
|
136
|
+
return;
|
|
137
|
+
settled = true;
|
|
138
|
+
const errors = [];
|
|
139
|
+
try {
|
|
140
|
+
if (remove && assertIdentity()) {
|
|
141
|
+
assertOwner();
|
|
142
|
+
if (assertIdentity() && binding.removeStagedFile(parentFd, name, ownedFd) === "preserved")
|
|
143
|
+
throw mismatch("identity");
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
catch (error) {
|
|
147
|
+
if (reportMismatch || !(error instanceof FsSafeError && error.code === "path-mismatch"))
|
|
148
|
+
errors.push(error);
|
|
149
|
+
}
|
|
150
|
+
try {
|
|
151
|
+
closeFile(ownedFd);
|
|
152
|
+
}
|
|
153
|
+
catch (error) {
|
|
154
|
+
errors.push(error);
|
|
155
|
+
}
|
|
156
|
+
try {
|
|
157
|
+
closeFile(parentFd);
|
|
158
|
+
}
|
|
159
|
+
catch (error) {
|
|
160
|
+
errors.push(error);
|
|
161
|
+
}
|
|
162
|
+
if (errors.length === 1)
|
|
163
|
+
throw errors[0];
|
|
164
|
+
if (errors.length)
|
|
165
|
+
throw new AggregateError(errors, "sidecar lock cleanup and close failed");
|
|
166
|
+
} };
|
|
167
|
+
}
|
|
168
|
+
catch (error) {
|
|
169
|
+
const errors = [error];
|
|
170
|
+
try {
|
|
171
|
+
if (fd !== undefined)
|
|
172
|
+
closeFile(fd);
|
|
173
|
+
}
|
|
174
|
+
catch (closeError) {
|
|
175
|
+
errors.push(closeError);
|
|
176
|
+
}
|
|
177
|
+
try {
|
|
178
|
+
closeFile(parentFd);
|
|
179
|
+
}
|
|
180
|
+
catch (closeError) {
|
|
181
|
+
errors.push(closeError);
|
|
182
|
+
}
|
|
183
|
+
if (errors.length > 1)
|
|
184
|
+
throw new AggregateError(errors, "sidecar retention and close failed");
|
|
185
|
+
throw error;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
@@ -108,7 +108,10 @@ function releaseAllLocksSync(state, options) {
|
|
|
108
108
|
void held.handle.close().catch(() => undefined);
|
|
109
109
|
try {
|
|
110
110
|
const retained = options?.preserveRetained === true && held.retainOnExit;
|
|
111
|
-
if (
|
|
111
|
+
if (held.retainedSidecar) {
|
|
112
|
+
held.retainedSidecar.settle(!retained);
|
|
113
|
+
}
|
|
114
|
+
else if (!retained && !held.lockRoot && snapshotMatchesSync(held.lockPath, held.snapshot)) {
|
|
112
115
|
fsSync.rmSync(held.lockPath, { force: true });
|
|
113
116
|
}
|
|
114
117
|
}
|
|
@@ -186,6 +189,17 @@ async function releaseHeldLock(state, normalizedTargetPath, held, options = {})
|
|
|
186
189
|
}
|
|
187
190
|
held.releasePromise = (async () => {
|
|
188
191
|
await held.handle.close().catch(() => undefined);
|
|
192
|
+
if (held.retainedSidecar) {
|
|
193
|
+
try {
|
|
194
|
+
held.retainedSidecar.settle(true);
|
|
195
|
+
}
|
|
196
|
+
finally {
|
|
197
|
+
if (state.held.get(normalizedTargetPath) === held)
|
|
198
|
+
state.held.delete(normalizedTargetPath);
|
|
199
|
+
stopSidecarLockMonitoring(held);
|
|
200
|
+
}
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
189
203
|
await removeSidecarLockIfUnchanged(held.lockPath, held.snapshot, {
|
|
190
204
|
lockRoot: held.lockRoot,
|
|
191
205
|
parsePayload: held.parsePayload,
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare function tempDirectoryMode(mode: number | bigint): string;
|
|
2
|
+
export declare function privateTempDirectoryFix(uid: number | undefined): string;
|
|
3
|
+
type TempDirectoryStat = {
|
|
4
|
+
isDirectory(): boolean;
|
|
5
|
+
isSymbolicLink(): boolean;
|
|
6
|
+
uid?: number | bigint;
|
|
7
|
+
mode?: number | bigint;
|
|
8
|
+
};
|
|
9
|
+
export declare function secureTempDirectoryFailure(stat: TempDirectoryStat, uid: number | undefined, windows: boolean): string;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export function tempDirectoryMode(mode) {
|
|
2
|
+
return (typeof mode === "bigint" ? mode & 4095n : mode & 0o7777).toString(8).padStart(4, "0");
|
|
3
|
+
}
|
|
4
|
+
export function privateTempDirectoryFix(uid) {
|
|
5
|
+
return `use a real private directory${uid === undefined ? "" : ` owned by uid ${uid}`} with mode 0700 under trusted ancestors (or use resolveSecureTempRoot()); do not chmod a shared temp directory to 0700`;
|
|
6
|
+
}
|
|
7
|
+
// Called only after failed admission; diagnostics never authorize repair.
|
|
8
|
+
export function secureTempDirectoryFailure(stat, uid, windows) {
|
|
9
|
+
if (stat.isSymbolicLink())
|
|
10
|
+
return "is a symbolic link; choose a real directory, not a symlink";
|
|
11
|
+
if (!stat.isDirectory())
|
|
12
|
+
return "is not a directory; choose a real directory";
|
|
13
|
+
if (!windows && uid !== undefined) {
|
|
14
|
+
if (stat.uid !== undefined && stat.uid !== uid && stat.uid !== BigInt(uid)) {
|
|
15
|
+
return `has owner uid ${stat.uid}, expected uid ${uid}; ${privateTempDirectoryFix(uid)}`;
|
|
16
|
+
}
|
|
17
|
+
const mode = stat.mode;
|
|
18
|
+
if (mode !== undefined) {
|
|
19
|
+
if ((typeof mode === "number" && (!Number.isSafeInteger(mode) || mode < 0)) ||
|
|
20
|
+
(typeof mode === "bigint" && mode < 0n)) {
|
|
21
|
+
return `has invalid mode bits; ${privateTempDirectoryFix(uid)}`;
|
|
22
|
+
}
|
|
23
|
+
if (typeof mode === "bigint" ? (mode & 18n) !== 0n : (mode & 0o022) !== 0) {
|
|
24
|
+
return `has group/world-writable mode ${tempDirectoryMode(mode)} (a sticky bit does not make a private root safe); ${privateTempDirectoryFix(uid)}`;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return `directory identity, permissions, or write/search access could not be verified; ${privateTempDirectoryFix(uid)}`;
|
|
29
|
+
}
|
|
@@ -143,7 +143,7 @@ export async function createOwnedTempFile(params) {
|
|
|
143
143
|
capability.assertCurrent();
|
|
144
144
|
const initial = inspectDirectoryIdentitySync(dir);
|
|
145
145
|
identity = Object.freeze({ dev: initial.dev, ino: initial.ino });
|
|
146
|
-
const needsModeInitialization = validateInitialTempWorkspaceChild(initial, admission.ownerUid, 0o700);
|
|
146
|
+
const needsModeInitialization = validateInitialTempWorkspaceChild(initial, admission.ownerUid, 0o700, dir);
|
|
147
147
|
retainedChild = TempWorkspaceRetainedChild.retain(dir, identity);
|
|
148
148
|
if (needsModeInitialization) {
|
|
149
149
|
await retainedChild.initializeMode(0o700, admission.ownerUid, admission.assertCurrent);
|