@openclaw/feishu 2026.10.1-beta.2 → 2026.10.5-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (151) hide show
  1. package/dist/.setup/{app-registration-BB6TubaW.mjs → app-registration-DQOq5urV.mjs} +13 -32
  2. package/dist/.setup/{channel-CX62T71S.mjs → channel-CjGGyrdx.mjs} +87 -174
  3. package/dist/.setup/{channel.runtime-COiaq-Rv.mjs → channel.runtime-SaC_uTPM.mjs} +57 -74
  4. package/dist/.setup/{chat-BdyvImsY.mjs → chat-fC3dvxFs.mjs} +16 -28
  5. package/dist/.setup/{client-BsBVWJzN.mjs → client-wwr8PGPH.mjs} +24 -30
  6. package/dist/.setup/{conversation-id-C1ofUfU8.mjs → conversation-id-D00i9uy5.mjs} +5 -10
  7. package/dist/.setup/{doctor-contract-B1B9ogdd.mjs → doctor-contract-oIpUWtNO.mjs} +23 -20
  8. package/dist/.setup/{monitor-7DvwUs4Y.mjs → monitor-Yt__BUki.mjs} +33 -54
  9. package/dist/.setup/{monitor.account-7xVu7XWY.mjs → monitor.account-CVz16781.mjs} +377 -664
  10. package/dist/.setup/{probe-B9o7iey6.mjs → probe-DXnFxq5j.mjs} +14 -17
  11. package/dist/.setup/{reply-delivery-result-Bt-BWBEA.mjs → reply-delivery-result-iCCrdxE1.mjs} +153 -181
  12. package/dist/.setup/{session-conversation-C53IEUWt.mjs → session-conversation-BSBNK5Mq.mjs} +1 -1
  13. package/dist/.setup/{setup-api-DmzX9S01.mjs → setup-api-B_LFQQ-Q.mjs} +1 -1
  14. package/dist/.setup/{subagent-hooks-CUXg0pC-.mjs → subagent-hooks-9Pc1-k37.mjs} +7 -17
  15. package/dist/.setup/{thread-bindings-jW2x5VuN.mjs → thread-bindings-DdNLxoL3.mjs} +21 -44
  16. package/dist/api.js +218 -326
  17. package/dist/channel-plugin-api.js +1 -1
  18. package/dist/contract-api.js +1 -1
  19. package/dist/doctor-contract-api.js +2 -2
  20. package/dist/session-binding-contract-api.js +1 -1
  21. package/dist/session-key-api.js +1 -1
  22. package/dist/setup-api.js +1 -1
  23. package/dist/setup-entry.js +1 -1
  24. package/dist/subagent-hooks-api.js +1 -1
  25. package/node_modules/@openclaw/fs-safe/CHANGELOG.md +91 -0
  26. package/node_modules/@openclaw/fs-safe/README.md +1 -1
  27. package/node_modules/@openclaw/fs-safe/dist/advanced.d.ts +1 -0
  28. package/node_modules/@openclaw/fs-safe/dist/advanced.js +1 -0
  29. package/node_modules/@openclaw/fs-safe/dist/archive-durability.js +1 -1
  30. package/node_modules/@openclaw/fs-safe/dist/archive-entry.js +7 -3
  31. package/node_modules/@openclaw/fs-safe/dist/archive-merge.js +4 -4
  32. package/node_modules/@openclaw/fs-safe/dist/archive-parser.wasm +0 -0
  33. package/node_modules/@openclaw/fs-safe/dist/archive-read.js +5 -4
  34. package/node_modules/@openclaw/fs-safe/dist/archive-staging.d.ts +1 -1
  35. package/node_modules/@openclaw/fs-safe/dist/archive-staging.js +22 -38
  36. package/node_modules/@openclaw/fs-safe/dist/copy-path-admission.d.ts +17 -0
  37. package/node_modules/@openclaw/fs-safe/dist/copy-path-admission.js +117 -0
  38. package/node_modules/@openclaw/fs-safe/dist/copy-root-file-sync.d.ts +38 -0
  39. package/node_modules/@openclaw/fs-safe/dist/copy-root-file-sync.js +195 -0
  40. package/node_modules/@openclaw/fs-safe/dist/create.d.ts +1 -0
  41. package/node_modules/@openclaw/fs-safe/dist/create.js +4 -1
  42. package/node_modules/@openclaw/fs-safe/dist/entry-publication.js +3 -1
  43. package/node_modules/@openclaw/fs-safe/dist/errors.d.ts +2 -0
  44. package/node_modules/@openclaw/fs-safe/dist/errors.js +5 -0
  45. package/node_modules/@openclaw/fs-safe/dist/file-lock-sync-root-acquire.d.ts +3 -0
  46. package/node_modules/@openclaw/fs-safe/dist/file-lock-sync-root-acquire.js +57 -11
  47. package/node_modules/@openclaw/fs-safe/dist/guarded-mutation.js +5 -5
  48. package/node_modules/@openclaw/fs-safe/dist/guest-native-python.js +52 -5
  49. package/node_modules/@openclaw/fs-safe/dist/guest.js +1 -1
  50. package/node_modules/@openclaw/fs-safe/dist/index.d.ts +1 -1
  51. package/node_modules/@openclaw/fs-safe/dist/index.js +1 -1
  52. package/node_modules/@openclaw/fs-safe/dist/native-binding.d.ts +4 -0
  53. package/node_modules/@openclaw/fs-safe/dist/native-move-fallback.d.ts +3 -0
  54. package/node_modules/@openclaw/fs-safe/dist/native-move-fallback.js +54 -0
  55. package/node_modules/@openclaw/fs-safe/dist/native-noreplace.d.ts +8 -0
  56. package/node_modules/@openclaw/fs-safe/dist/native-noreplace.js +55 -0
  57. package/node_modules/@openclaw/fs-safe/dist/native-operations.d.ts +0 -1
  58. package/node_modules/@openclaw/fs-safe/dist/native-operations.js +22 -26
  59. package/node_modules/@openclaw/fs-safe/dist/native-pinned-write-windows.js +5 -1
  60. package/node_modules/@openclaw/fs-safe/dist/native-pinned-write.d.ts +1 -1
  61. package/node_modules/@openclaw/fs-safe/dist/native-pinned-write.js +12 -2
  62. package/node_modules/@openclaw/fs-safe/dist/native-rename-outcome.js +3 -1
  63. package/node_modules/@openclaw/fs-safe/dist/native-staged-file.d.ts +1 -1
  64. package/node_modules/@openclaw/fs-safe/dist/native-staged-file.js +52 -6
  65. package/node_modules/@openclaw/fs-safe/dist/permission-exec.js +2 -1
  66. package/node_modules/@openclaw/fs-safe/dist/pinned-write-input.d.ts +2 -0
  67. package/node_modules/@openclaw/fs-safe/dist/pinned-write-input.js +17 -0
  68. package/node_modules/@openclaw/fs-safe/dist/pinned-write-types.d.ts +6 -1
  69. package/node_modules/@openclaw/fs-safe/dist/pinned-write.js +1 -1
  70. package/node_modules/@openclaw/fs-safe/dist/private-temp-workspace.js +2 -2
  71. package/node_modules/@openclaw/fs-safe/dist/publish-file-failure.d.ts +5 -0
  72. package/node_modules/@openclaw/fs-safe/dist/publish-file-failure.js +1 -0
  73. package/node_modules/@openclaw/fs-safe/dist/publish-file.d.ts +2 -0
  74. package/node_modules/@openclaw/fs-safe/dist/publish-file.js +35 -2
  75. package/node_modules/@openclaw/fs-safe/dist/replace-directory.js +6 -5
  76. package/node_modules/@openclaw/fs-safe/dist/replace-file-copy-fallback.js +1 -4
  77. package/node_modules/@openclaw/fs-safe/dist/replace-file-descriptor.js +6 -0
  78. package/node_modules/@openclaw/fs-safe/dist/root-create-input.d.ts +15 -1
  79. package/node_modules/@openclaw/fs-safe/dist/root-create-input.js +4 -0
  80. package/node_modules/@openclaw/fs-safe/dist/root-directory-entry.js +1 -1
  81. package/node_modules/@openclaw/fs-safe/dist/root-directory-list.d.ts +0 -1
  82. package/node_modules/@openclaw/fs-safe/dist/root-directory-list.js +6 -12
  83. package/node_modules/@openclaw/fs-safe/dist/root-errors.js +25 -4
  84. package/node_modules/@openclaw/fs-safe/dist/root-impl.js +18 -18
  85. package/node_modules/@openclaw/fs-safe/dist/root-move-noreplace.d.ts +4 -2
  86. package/node_modules/@openclaw/fs-safe/dist/root-move-noreplace.js +13 -17
  87. package/node_modules/@openclaw/fs-safe/dist/root-paths.js +1 -1
  88. package/node_modules/@openclaw/fs-safe/dist/root-walk.js +4 -4
  89. package/node_modules/@openclaw/fs-safe/dist/root-write-verification.d.ts +10 -1
  90. package/node_modules/@openclaw/fs-safe/dist/root-write-verification.js +20 -0
  91. package/node_modules/@openclaw/fs-safe/dist/secure-temp-dir.js +19 -7
  92. package/node_modules/@openclaw/fs-safe/dist/sibling-staged-file.js +18 -3
  93. package/node_modules/@openclaw/fs-safe/dist/sidecar-lock-acquire.js +25 -3
  94. package/node_modules/@openclaw/fs-safe/dist/sidecar-lock-admission.d.ts +2 -0
  95. package/node_modules/@openclaw/fs-safe/dist/sidecar-lock-retained.d.ts +14 -0
  96. package/node_modules/@openclaw/fs-safe/dist/sidecar-lock-retained.js +187 -0
  97. package/node_modules/@openclaw/fs-safe/dist/sidecar-lock.js +15 -1
  98. package/node_modules/@openclaw/fs-safe/dist/staged-file-settlement.js +4 -1
  99. package/node_modules/@openclaw/fs-safe/dist/temp-directory-diagnostics.d.ts +10 -0
  100. package/node_modules/@openclaw/fs-safe/dist/temp-directory-diagnostics.js +29 -0
  101. package/node_modules/@openclaw/fs-safe/dist/temp-target.js +1 -1
  102. package/node_modules/@openclaw/fs-safe/dist/temp-workspace-admission.js +6 -6
  103. package/node_modules/@openclaw/fs-safe/dist/temp-workspace-child-admission.d.ts +4 -4
  104. package/node_modules/@openclaw/fs-safe/dist/temp-workspace-child-admission.js +17 -16
  105. package/node_modules/@openclaw/fs-safe/dist/temp-workspace-descriptor.js +20 -28
  106. package/node_modules/@openclaw/fs-safe/dist/temp-workspace-owner.d.ts +1 -0
  107. package/node_modules/@openclaw/fs-safe/dist/temp-workspace-owner.js +27 -4
  108. package/node_modules/@openclaw/fs-safe/dist/walk.js +2 -13
  109. package/node_modules/@openclaw/fs-safe/dist/watch-native.d.ts +2 -2
  110. package/node_modules/@openclaw/fs-safe/dist/watch-native.js +3 -1
  111. package/node_modules/@openclaw/fs-safe/dist/watch-rescan.js +3 -9
  112. package/node_modules/@openclaw/fs-safe/dist/watch.js +2 -3
  113. package/node_modules/@openclaw/fs-safe/docs/advanced.md +1 -0
  114. package/node_modules/@openclaw/fs-safe/docs/archive.md +5 -1
  115. package/node_modules/@openclaw/fs-safe/docs/atomic.md +11 -3
  116. package/node_modules/@openclaw/fs-safe/docs/contributing.md +1 -1
  117. package/node_modules/@openclaw/fs-safe/docs/copy.md +109 -1
  118. package/node_modules/@openclaw/fs-safe/docs/durability.md +50 -5
  119. package/node_modules/@openclaw/fs-safe/docs/errors.md +37 -0
  120. package/node_modules/@openclaw/fs-safe/docs/guest.md +21 -4
  121. package/node_modules/@openclaw/fs-safe/docs/native-helper.md +5 -3
  122. package/node_modules/@openclaw/fs-safe/docs/native.md +39 -6
  123. package/node_modules/@openclaw/fs-safe/docs/path-scope.md +4 -0
  124. package/node_modules/@openclaw/fs-safe/docs/public-api.md +3 -1
  125. package/node_modules/@openclaw/fs-safe/docs/sidecar-lock.md +46 -8
  126. package/node_modules/@openclaw/fs-safe/docs/staged-file.md +10 -3
  127. package/node_modules/@openclaw/fs-safe/docs/temp.md +12 -0
  128. package/node_modules/@openclaw/fs-safe/docs/watch.md +6 -3
  129. package/node_modules/@openclaw/fs-safe/docs/writing.md +40 -11
  130. package/node_modules/@openclaw/fs-safe/package.json +16 -16
  131. package/node_modules/@openclaw/fs-safe-darwin-arm64/fs-safe-native.node +0 -0
  132. package/node_modules/@openclaw/fs-safe-darwin-arm64/package.json +1 -1
  133. package/node_modules/@openclaw/fs-safe-darwin-x64/fs-safe-native.node +0 -0
  134. package/node_modules/@openclaw/fs-safe-darwin-x64/package.json +1 -1
  135. package/node_modules/@openclaw/fs-safe-linux-arm64-gnu/fs-safe-native.node +0 -0
  136. package/node_modules/@openclaw/fs-safe-linux-arm64-gnu/package.json +1 -1
  137. package/node_modules/@openclaw/fs-safe-linux-arm64-musl/fs-safe-native.node +0 -0
  138. package/node_modules/@openclaw/fs-safe-linux-arm64-musl/package.json +1 -1
  139. package/node_modules/@openclaw/fs-safe-linux-x64-gnu/fs-safe-native.node +0 -0
  140. package/node_modules/@openclaw/fs-safe-linux-x64-gnu/package.json +1 -1
  141. package/node_modules/@openclaw/fs-safe-linux-x64-musl/fs-safe-native.node +0 -0
  142. package/node_modules/@openclaw/fs-safe-linux-x64-musl/package.json +1 -1
  143. package/node_modules/@openclaw/fs-safe-win32-x64-msvc/fs-safe-native.node +0 -0
  144. package/node_modules/@openclaw/fs-safe-win32-x64-msvc/package.json +1 -1
  145. package/node_modules/follow-redirects/index.js +10 -1
  146. package/node_modules/follow-redirects/package.json +1 -1
  147. package/package.json +5 -5
  148. package/node_modules/@openclaw/fs-safe/dist/file-lock-sync-root-arbitration.d.ts +0 -17
  149. package/node_modules/@openclaw/fs-safe/dist/file-lock-sync-root-arbitration.js +0 -66
  150. package/node_modules/@openclaw/fs-safe/dist/root-move-preflight.d.ts +0 -7
  151. package/node_modules/@openclaw/fs-safe/dist/root-move-preflight.js +0 -16
@@ -1,2 +1,2 @@
1
- import { t as feishuPlugin } from "./.setup/channel-CX62T71S.mjs";
1
+ import { t as feishuPlugin } from "./.setup/channel-CjGGyrdx.mjs";
2
2
  export { feishuPlugin };
@@ -1,4 +1,4 @@
1
- import { a as parseFeishuTargetId, i as parseFeishuDirectConversationId, r as parseFeishuConversationId, t as buildFeishuConversationId } from "./.setup/conversation-id-C1ofUfU8.mjs";
1
+ import { a as parseFeishuTargetId, i as parseFeishuDirectConversationId, r as parseFeishuConversationId, t as buildFeishuConversationId } from "./.setup/conversation-id-D00i9uy5.mjs";
2
2
  import { t as messageActionTargetAliases } from "./.setup/message-action-contract-Bhxj8Zrf.mjs";
3
3
  import { t as collectFeishuSecurityAuditFindings } from "./.setup/security-audit-b86aSgH2.mjs";
4
4
  export { buildFeishuConversationId, collectFeishuSecurityAuditFindings, messageActionTargetAliases, parseFeishuConversationId, parseFeishuDirectConversationId, parseFeishuTargetId };
@@ -1,2 +1,2 @@
1
- import { n as legacyConfigRules, r as normalizeCompatibilityConfig, t as historicalWebhookListener } from "./.setup/doctor-contract-B1B9ogdd.mjs";
2
- export { historicalWebhookListener, legacyConfigRules, normalizeCompatibilityConfig };
1
+ import { i as normalizeHistoricalWebhookConfig, n as legacyConfigRules, r as normalizeCompatibilityConfig, t as historicalWebhookListener } from "./.setup/doctor-contract-oIpUWtNO.mjs";
2
+ export { historicalWebhookListener, legacyConfigRules, normalizeCompatibilityConfig, normalizeHistoricalWebhookConfig };
@@ -1,2 +1,2 @@
1
- import { t as createFeishuThreadBindingManager } from "./.setup/thread-bindings-jW2x5VuN.mjs";
1
+ import { t as createFeishuThreadBindingManager } from "./.setup/thread-bindings-DdNLxoL3.mjs";
2
2
  export { createFeishuThreadBindingManager };
@@ -1,2 +1,2 @@
1
- import { t as resolveFeishuSessionConversation } from "./.setup/session-conversation-C53IEUWt.mjs";
1
+ import { t as resolveFeishuSessionConversation } from "./.setup/session-conversation-BSBNK5Mq.mjs";
2
2
  export { resolveFeishuSessionConversation as resolveSessionConversation };
package/dist/setup-api.js CHANGED
@@ -1,2 +1,2 @@
1
- import { i as feishuSetupAdapter, n as feishuSetupWizard, t as feishuPlugin } from "./.setup/channel-CX62T71S.mjs";
1
+ import { i as feishuSetupAdapter, n as feishuSetupWizard, t as feishuPlugin } from "./.setup/channel-CjGGyrdx.mjs";
2
2
  export { feishuPlugin, feishuSetupAdapter, feishuSetupWizard };
@@ -4,7 +4,7 @@ import { fileURLToPath } from "node:url";
4
4
  var setup_entry_default = defineBundledChannelSetupEntry({
5
5
  importMetaUrl: import.meta.url,
6
6
  plugin: {
7
- specifier: fileURLToPath(new URL(".setup/setup-api-DmzX9S01.mjs", import.meta.url).href),
7
+ specifier: fileURLToPath(new URL(".setup/setup-api-B_LFQQ-Q.mjs", import.meta.url).href),
8
8
  exportName: "feishuPlugin"
9
9
  },
10
10
  secrets: {
@@ -1,6 +1,6 @@
1
1
  import { createLazyRuntimeModule } from "openclaw/plugin-sdk/lazy-runtime";
2
2
  //#region extensions/feishu/subagent-hooks-api.ts
3
- const loadFeishuSubagentHooksModule = createLazyRuntimeModule(() => import("./.setup/subagent-hooks-CUXg0pC-.mjs").then((n) => n.r));
3
+ const loadFeishuSubagentHooksModule = createLazyRuntimeModule(() => import("./.setup/subagent-hooks-9Pc1-k37.mjs").then((n) => n.r));
4
4
  function registerFeishuSubagentHooks(api) {
5
5
  api.on("subagent_delivery_target", async (event) => {
6
6
  const { handleFeishuSubagentDeliveryTarget } = await loadFeishuSubagentHooksModule();
@@ -2,6 +2,97 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 0.25.0 - 2026-10-08
6
+
7
+ ### Highlights
8
+
9
+ - **Faster synchronous plugin captures:** 16% faster than pre-change main on a measured 6,000-file tree; the new `createRootFileCopyBatchSync` API on `advanced` also reuses directory admissions across copies. ([#878](https://github.com/openclaw/fs-safe/pull/878), [#849](https://github.com/openclaw/fs-safe/pull/849))
10
+ - **Guest workspace publication:** works on gVisor and other Linux filesystems that reject `RENAME_NOREPLACE`. ([#876](https://github.com/openclaw/fs-safe/pull/876))
11
+ - **Root-backed sidecar locks:** native asynchronous release and exit cleanup no longer strand locks after their Root moves. ([#879](https://github.com/openclaw/fs-safe/pull/879))
12
+ - **Guest cross-device moves:** preserve the admitted file permissions. ([#869](https://github.com/openclaw/fs-safe/pull/869))
13
+
14
+ ### Features
15
+
16
+ - **Guarded copy batches:** `createRootFileCopyBatchSync` on `advanced` reuses directory admissions across synchronous copies on canonical POSIX paths while rechecking ancestor and file identities for every copy; single-file copies also reuse admission within the operation. ([#849](https://github.com/openclaw/fs-safe/pull/849))
17
+
18
+ ### Fixes
19
+
20
+ - **Root-backed file locks:** native asynchronous release and exit cleanup follow the created lock's retained identity after its Root moves, preserving replacement files and reporting ownership mismatches. ([#879](https://github.com/openclaw/fs-safe/pull/879)) Thanks @axiom-ncis.
21
+ - **Temp directory diagnostics:** name rejected roots and ancestors, explain ownership, mode, or symlink failures, and provide safe recovery guidance, including for root-run appliances. Thanks @joequant. ([#877](https://github.com/openclaw/fs-safe/pull/877))
22
+ - **Guest directory publication:** publish staged workspaces when Linux filesystems reject `RENAME_NOREPLACE`, with checked file link/unlink fallback and directory rename that can only replace a concurrently created empty directory. ([#876](https://github.com/openclaw/fs-safe/pull/876)) Thanks @valkyriweb.
23
+ - **Guest cross-device moves:** preserve the admitted source file's permissions instead of leaving the destination with a broader default mode. ([#869](https://github.com/openclaw/fs-safe/pull/869))
24
+ - **Move receipts:** publication receipts capture the source identity after synchronous authorization callbacks return, so a source replaced during authorization is reported accurately. ([#868](https://github.com/openclaw/fs-safe/pull/868))
25
+ - **Atomic copy fallback:** report a failed restoration as a failure even when the underlying error carries a restored receipt. ([#851](https://github.com/openclaw/fs-safe/pull/851))
26
+ - **Archive read limits:** keep the validated entry-read byte limit fixed when callers mutate the options during a read. ([#852](https://github.com/openclaw/fs-safe/pull/852))
27
+ - **Watch on macOS:** reconcile notifications for changes to the watched Root itself immediately instead of waiting for the periodic scan. ([#858](https://github.com/openclaw/fs-safe/pull/858))
28
+ - **`pathScope` tilde names:** keep literal `~` directory names inside scoped file and existing-path lookups instead of expanding them. ([#856](https://github.com/openclaw/fs-safe/pull/856))
29
+
30
+ ### Performance
31
+
32
+ - **Guarded file copies:** reuse checked canonical POSIX roots during initial path admission, reducing repeated path-resolution work in synchronous plugin source captures without changing per-file identity or race checks.
33
+ - **Root walks:** reuse normalized directory prefixes, cutting a 50k-file walk by 5.6% and its sampled allocation by about 9% while keeping every filesystem and identity check. ([#870](https://github.com/openclaw/fs-safe/pull/870))
34
+ - **Atomic writes:** non-durable async POSIX writes skip a redundant mode change when the staged file already has the requested permissions. ([#871](https://github.com/openclaw/fs-safe/pull/871))
35
+ - **Guarded mutations:** fewer promise allocations around synchronous guard checks, with directory identity checks unchanged. ([#857](https://github.com/openclaw/fs-safe/pull/857))
36
+ - **Archive publication:** fewer promise allocations in archive guard checks, without removing identity or containment checks. ([#864](https://github.com/openclaw/fs-safe/pull/864))
37
+ - **Watch:** Linux and Windows watch passes skip macOS stream-path preparation. ([#860](https://github.com/openclaw/fs-safe/pull/860))
38
+ - **Permission diagnostics:** bound escaping work for large error messages without changing the displayed excerpts. ([#859](https://github.com/openclaw/fs-safe/pull/859))
39
+
40
+ ## 0.24.2 - 2026-10-07
41
+
42
+ ### Fixes
43
+
44
+ - **Linux exclusive publication:** `publishFileExclusive` with `rename-noreplace` uses the identity-checked link/unlink move fallback in native `auto` when `RENAME_NOREPLACE` is unsupported, consumes the source on success, and reports `fallback: "link-unlink"` plus precise partial-failure receipts; native `require` stays fail-closed. Link/unlink is not crash-atomic. ([#843](https://github.com/openclaw/fs-safe/pull/843), [openclaw#166246](https://github.com/openclaw/openclaw/issues/166246)) Thanks @MertBasar0.
45
+ - **Native clone descriptors:** native file copies return read-write descriptors, so Linux clones can be read immediately and macOS clones can be written while preserving read-only source modes. ([#844](https://github.com/openclaw/fs-safe/pull/844))
46
+
47
+ ## 0.24.1 - 2026-10-06
48
+
49
+ ### Features
50
+
51
+ - **Pinned source copies:** `copyRootFileSync` accepts `expectedSourceIdentity` to reject a replaced source before destination creation and returns the verified `sourceIdentity` for every copy method. This refines the `copyRootFileSync` API introduced in 0.24.0. ([#841](https://github.com/openclaw/fs-safe/pull/841))
52
+
53
+ ## 0.24.0 - 2026-10-06
54
+
55
+ ### Highlights
56
+
57
+ - **No-replace moves on more Linux filesystems:** when filesystems reject `renameat2` with `RENAME_NOREPLACE`, including reported QNAP ZFS shares and some overlay mounts, `auto` falls back safely: directories use plain rename that can at most replace an empty directory, and files use identity-checked link/unlink that cannot overwrite a target. Native `require` fails closed. ([#838](https://github.com/openclaw/fs-safe/pull/838), fixes [openclaw#165617](https://github.com/openclaw/openclaw/issues/165617)) Thanks @StarGazer1995, original reporter @bbs2i58, and @MertBasar0.
58
+ - **Synchronous guarded copies:** new `copyRootFileSync` on `advanced` supports APFS cloning, reflinks, `copy_file_range`, and guarded byte fallback, returning an owned destination descriptor for synchronous capture hashes. ([#839](https://github.com/openclaw/fs-safe/pull/839))
59
+ - **Public capability classification:** new `isNoReplaceUnsupported(error)` identifies unavailable no-replace rename support without matching internal native error codes. ([#838](https://github.com/openclaw/fs-safe/pull/838))
60
+
61
+ ### Features
62
+
63
+ - **Synchronous root-to-root copy:** `copyRootFileSync` exclusively creates an absent destination under its admitted root, bounds the copy with `maxBytes`, verifies source and destination identities, and returns a disposable descriptor with copy-method and byte-count receipts. ([#839](https://github.com/openclaw/fs-safe/pull/839))
64
+ - **No-replace error classifier:** export `isNoReplaceUnsupported(error)` from the root package and `errors` subpath for stable `helper-unavailable` capability diagnostics. ([#838](https://github.com/openclaw/fs-safe/pull/838))
65
+
66
+ ### Fixes
67
+
68
+ - **Linux no-replace moves:** `Root.move()` uses retained-parent file link/unlink or directory rename when `RENAME_NOREPLACE` is unsupported in `auto`, rejects file collisions, and preserves publication/source-removal details after partial failures. ([#838](https://github.com/openclaw/fs-safe/pull/838)) Thanks @StarGazer1995, @bbs2i58, and @MertBasar0.
69
+
70
+ ### Performance
71
+
72
+ - **Synchronous copy acceleration:** reuse the native bounded copy engine for APFS clones, Linux reflinks, and `copy_file_range` before byte copying when `copyRootFileSync` is called with `clone: "auto"`. ([#839](https://github.com/openclaw/fs-safe/pull/839))
73
+
74
+ ### Compatibility
75
+
76
+ - **Move fallback limits:** native `require` keeps refusing unsupported no-replace moves. In `auto`, the directory fallback can replace a concurrently created empty directory; nonempty directories and non-directory competitors reject. File fallback requires hard-link support and fails closed if links are denied or unsupported. ([#838](https://github.com/openclaw/fs-safe/pull/838))
77
+ - **Synchronous copy contract:** `copyRootFileSync` defaults to `clone: "never"`, requires existing parents and an absent destination, and performs direct exclusive creation. Use a private capture directory; it does not promise atomic publication, crash durability, or a coherent snapshot of concurrent in-place edits. ([#839](https://github.com/openclaw/fs-safe/pull/839))
78
+
79
+ ## 0.23.1 - 2026-10-04
80
+
81
+ ### Highlights
82
+
83
+ - **gVisor and 9p file creation:** `create()` and other no-replace publication fall back in `auto` mode on filesystems that reject `renameat2` with `RENAME_NOREPLACE`; `require` mode fails closed. ([#834](https://github.com/openclaw/fs-safe/pull/834), fixes [#828](https://github.com/openclaw/fs-safe/issues/828)) Thanks @vishnukool.
84
+ - **Container copy compatibility:** seccomp or LSM policies denying `FICLONE` no longer break `clone: "auto"` copies, for both single files and `copyTree`. ([#829](https://github.com/openclaw/fs-safe/pull/829), [#835](https://github.com/openclaw/fs-safe/pull/835)) Thanks @Mohl, with co-author credit to @foxsky.
85
+ - **macOS watching:** a FIFO at a watched name no longer freezes watching across the process. ([#830](https://github.com/openclaw/fs-safe/pull/830)) Thanks @SebTardif.
86
+
87
+ ### Fixes
88
+
89
+ - **gVisor file creation:** fall back safely when the filesystem rejects native no-replace publication, clean unpublished stages, and report the missing capability in native-required mode. ([#834](https://github.com/openclaw/fs-safe/pull/834)) Thanks @vishnukool.
90
+ - **ZIP collision checks:** reject directory and file names that differ only by case, Unicode normalization, or a trailing separator before extraction or bounded reads. ([#832](https://github.com/openclaw/fs-safe/pull/832)) Thanks @SebTardif.
91
+ - **macOS entry watch:** prevent a FIFO at a watched name from blocking every watcher in the process. ([#830](https://github.com/openclaw/fs-safe/pull/830)) Thanks @SebTardif.
92
+ - **Disk-full diagnostics:** preserve disk-full (`ENOSPC`) diagnostics and cleanup receipts through combined write and disposal failures instead of reporting a misleading file-type error. ([#833](https://github.com/openclaw/fs-safe/pull/833)) Thanks @steipete.
93
+ - **Linux clone fallback:** copies with `clone: "auto"` fall back to guarded byte copying when container seccomp or LSM policy denies `FICLONE`; `clone: "always"` reports `unsupported-platform` and removes its stage. ([#829](https://github.com/openclaw/fs-safe/pull/829)) Thanks @Mohl, with co-author credit to @foxsky.
94
+ - **Linux tree clone fallback:** `copyTree` with `clone: "auto"` copies bytes when XFS/ZFS file reflinks are unavailable or denied by container policy; `"always"` reports `unsupported-platform` after partial-tree cleanup. ([#835](https://github.com/openclaw/fs-safe/pull/835)) Thanks @steipete.
95
+
5
96
  ## 0.23.0 - 2026-10-02
6
97
 
7
98
  ### Highlights
@@ -22,7 +22,7 @@ await fs.write("../escape.txt", "x"); // throws FsSafeError("outside-
22
22
 
23
23
  That's the whole pitch. `root()` is the product; the rest of the package — JSON stores, atomic writes, secret files, archive extraction, temp workspaces — is supporting cast for the same boundary.
24
24
 
25
- Full docs and reference at **[fs-safe.io](https://fs-safe.io)**.
25
+ Full docs and reference at **[fs-safe.io](https://fs-safe.io)**. For synchronous plugin captures, [guarded file copies and batches](docs/copy.md#synchronous-guarded-file-copies) return owned destination descriptors while preserving per-file checks.
26
26
 
27
27
  ## Contents
28
28
 
@@ -1,3 +1,4 @@
1
+ export { copyRootFileSync, createRootFileCopyBatchSync, type RootFileCopyBatchSync, type CopyRootFileSyncOptions, type CopiedRootFileSync } from "./copy-root-file-sync.js";
1
2
  export { createAsyncLock } from "./async-lock.js";
2
3
  export { createDirectory, createDirectorySync, createFileSync, type CreateDirectoryOptions, type CreateFileOptions, type OwnedFileDescriptorSync, } from "./create.js";
3
4
  export { copyFileHandle, copyFileDescriptorSync, type CopyFileHandleOptions } from "./file-handle-transfer.js";
@@ -1,3 +1,4 @@
1
+ export { copyRootFileSync, createRootFileCopyBatchSync } from "./copy-root-file-sync.js";
1
2
  // Advanced composition surface. These exports are less stable than the focused
2
3
  // public subpaths; prefer root/json/store/temp/archive unless you are building a
3
4
  // higher-level primitive.
@@ -65,7 +65,7 @@ export async function finalizeArchivePublication(params) {
65
65
  const check = () => params.deadline?.check();
66
66
  const assertGuards = async (guards) => {
67
67
  for (const guard of [params.destinationGuard, ...guards, params.sourceGuard]) {
68
- await assertDirectoryIdentityGuard(guard);
68
+ assertDirectoryIdentityGuard(guard);
69
69
  check();
70
70
  }
71
71
  };
@@ -63,13 +63,17 @@ export function stripArchivePath(entryPath, stripComponents) {
63
63
  export function createArchiveOutputPathTracker() {
64
64
  const seen = new Set();
65
65
  return (entryPath, originalPath) => {
66
- const normalized = path.posix.normalize(normalizeArchiveEntryPath(entryPath));
66
+ // Extraction passes stripArchivePath output. Native manifests and physical
67
+ // admission pass raw names, and path.posix.normalize keeps a directory's
68
+ // trailing slash, so "A/" and "a" would not share a key.
69
+ const canonical = stripArchivePath(entryPath, 0)
70
+ ?? path.posix.normalize(normalizeArchiveEntryPath(entryPath));
67
71
  // Archive policy must not depend on the destination volume's case or
68
72
  // Unicode-normalization behavior. Otherwise the JavaScript and native
69
73
  // writers can disagree about which of two colliding entries wins.
70
- const collisionKey = lowerCaseNfc(normalized);
74
+ const collisionKey = lowerCaseNfc(canonical);
71
75
  if (seen.has(collisionKey)) {
72
- throw new ArchiveSecurityError("entry-path", `archive entries collide at output path ${formatErrorDetail(normalized)}: ${formatErrorDetail(originalPath)}`);
76
+ throw new ArchiveSecurityError("entry-path", `archive entries collide at output path ${formatErrorDetail(canonical)}: ${formatErrorDetail(originalPath)}`);
73
77
  }
74
78
  seen.add(collisionKey);
75
79
  };
@@ -98,15 +98,15 @@ async function mergeTree(params, publication, durable = true, entryUmask = 0) {
98
98
  assertSourceDirectory(ancestor);
99
99
  };
100
100
  const assertGuards = async () => {
101
- await assertDirectoryIdentityGuard(destinationGuard);
101
+ assertDirectoryIdentityGuard(destinationGuard);
102
102
  check();
103
103
  for (const ancestor of ancestors) {
104
- await assertDirectoryIdentityGuard(ancestor.guard);
104
+ assertDirectoryIdentityGuard(ancestor.guard);
105
105
  check();
106
106
  await ancestor.owner.verify(check);
107
107
  check();
108
108
  }
109
- await assertDirectoryIdentityGuard(sourceGuard);
109
+ assertDirectoryIdentityGuard(sourceGuard);
110
110
  check();
111
111
  };
112
112
  const walk = async (sourceDir) => {
@@ -184,7 +184,7 @@ async function mergeTree(params, publication, durable = true, entryUmask = 0) {
184
184
  await owner.apply(mode, { check, beforeChmod: async () => {
185
185
  await assertGuards();
186
186
  assertSourceAncestors();
187
- await assertDirectoryIdentityGuard(guard);
187
+ assertDirectoryIdentityGuard(guard);
188
188
  check();
189
189
  await assertResolvedInsideDestination({
190
190
  destinationRealDir, targetPath: destinationPath, originalPath,
@@ -213,7 +213,8 @@ async function readNativeBufferEntry(native, buffer, kind, requested, displayPat
213
213
  }
214
214
  }
215
215
  export async function readArchiveEntry(archivePath, entryPath, options) {
216
- if (!Number.isSafeInteger(options.maxBytes) || options.maxBytes < 0) {
216
+ const maxBytes = options.maxBytes;
217
+ if (!Number.isSafeInteger(maxBytes) || maxBytes < 0) {
217
218
  throw new RangeError("maxBytes must be a non-negative safe integer");
218
219
  }
219
220
  const kind = options.kind ?? resolveArchiveKind(archivePath);
@@ -228,7 +229,7 @@ export async function readArchiveEntry(archivePath, entryPath, options) {
228
229
  admitZipBuffer(buffer, resolveExtractLimits(), entry => { zipEntries.push(entry); });
229
230
  const native = getNativeBinding();
230
231
  if (native)
231
- return await readNativeBufferEntry(native, buffer, kind, requestedEntry, entryPath, options.maxBytes, zipEntries);
232
- return kind === "zip" ? await readZipEntry(buffer, requestedEntry, options.maxBytes, zipEntries)
233
- : await readTarEntry(buffer, requestedEntry, options.maxBytes, kind);
232
+ return await readNativeBufferEntry(native, buffer, kind, requestedEntry, entryPath, maxBytes, zipEntries);
233
+ return kind === "zip" ? await readZipEntry(buffer, requestedEntry, maxBytes, zipEntries)
234
+ : await readTarEntry(buffer, requestedEntry, maxBytes, kind);
234
235
  }
@@ -5,7 +5,7 @@ import { ArchiveSecurityError } from "./archive-errors.js";
5
5
  export type ArchiveDirectoryGuard = AsyncDirectoryGuard<BigIntStats>;
6
6
  export declare function createArchiveSymlinkTraversalError(originalPath: string): ArchiveSecurityError;
7
7
  export declare function createDirectoryIdentityGuard(dir: string): Promise<ArchiveDirectoryGuard>;
8
- export declare function assertDirectoryIdentityGuard(guard: ArchiveDirectoryGuard): Promise<void>;
8
+ export declare function assertDirectoryIdentityGuard(guard: ArchiveDirectoryGuard): void;
9
9
  export declare function prepareArchiveDestinationGuard(destDir: string): Promise<ArchiveDirectoryGuard>;
10
10
  export declare function prepareArchiveDestinationDir(destDir: string): Promise<string>;
11
11
  export declare function assertResolvedInsideDestination(params: {
@@ -1,7 +1,7 @@
1
1
  import fsSync, {} from "node:fs";
2
2
  import fs from "node:fs/promises";
3
3
  import path from "node:path";
4
- import { assertAsyncDirectoryGuard, createAsyncDirectoryGuard, } from "./directory-guard.js";
4
+ import { assertDirectoryGuard, createAsyncDirectoryGuard, } from "./directory-guard.js";
5
5
  import { ownExtractionDestinationMutation, } from "./archive-deadline.js";
6
6
  import { ArchiveSecurityError, } from "./archive-errors.js";
7
7
  import { FsSafeError } from "./errors.js";
@@ -38,9 +38,9 @@ export async function createDirectoryIdentityGuard(dir) {
38
38
  throw err;
39
39
  }
40
40
  }
41
- export async function assertDirectoryIdentityGuard(guard) {
41
+ export function assertDirectoryIdentityGuard(guard) {
42
42
  try {
43
- await assertAsyncDirectoryGuard(guard);
43
+ assertDirectoryGuard(guard, "native");
44
44
  }
45
45
  catch (err) {
46
46
  if (err instanceof FsSafeError || isNotFoundPathError(err)) {
@@ -200,7 +200,7 @@ async function prepareOutputPath(params, assertGuards, privateWorkingMode = fals
200
200
  if (existingDestinationGuard && assertGuards)
201
201
  await assertGuards();
202
202
  else {
203
- await assertDirectoryIdentityGuard(destinationGuard);
203
+ assertDirectoryIdentityGuard(destinationGuard);
204
204
  checkExtractionDeadline(params.deadline);
205
205
  await assertGuards?.();
206
206
  }
@@ -213,46 +213,30 @@ async function prepareOutputPath(params, assertGuards, privateWorkingMode = fals
213
213
  originalPath: params.originalPath,
214
214
  });
215
215
  checkExtractionDeadline(params.deadline);
216
- if (params.isDirectory) {
217
- await getFsSafeTestHooks()?.beforeArchiveOutputMutation?.("mkdir", params.outPath);
216
+ const relativePath = params.isDirectory ? relPath : path.posix.dirname(relPath);
217
+ if (params.isDirectory || relativePath !== ".") {
218
+ const directoryPath = params.isDirectory ? params.outPath : path.dirname(params.outPath);
219
+ await getFsSafeTestHooks()?.beforeArchiveOutputMutation?.("mkdir", directoryPath);
218
220
  checkExtractionDeadline(params.deadline);
219
221
  await ownExtractionDestinationMutation(params.deadline, async () => {
220
222
  await assertOutputGuards();
221
223
  checkExtractionDeadline(params.deadline);
222
- await mkdirArchiveOutput({
223
- targetRoot,
224
- relativePath: relPath,
225
- originalPath: params.originalPath,
226
- });
227
- checkExtractionDeadline(params.deadline);
228
- await assertDirectoryIdentityGuard(destinationGuard);
224
+ await mkdirArchiveOutput({ targetRoot, relativePath, originalPath: params.originalPath });
229
225
  checkExtractionDeadline(params.deadline);
230
- await assertResolvedInsideDestination({
231
- destinationRealDir: params.destinationRealDir,
232
- targetPath: params.outPath,
233
- originalPath: params.originalPath,
234
- });
235
- checkExtractionDeadline(params.deadline);
236
- });
237
- return;
238
- }
239
- const parentRel = path.posix.dirname(relPath);
240
- if (parentRel !== ".") {
241
- await getFsSafeTestHooks()?.beforeArchiveOutputMutation?.("mkdir", path.dirname(params.outPath));
242
- checkExtractionDeadline(params.deadline);
243
- await ownExtractionDestinationMutation(params.deadline, async () => {
244
- await assertOutputGuards();
245
- checkExtractionDeadline(params.deadline);
246
- await mkdirArchiveOutput({
247
- targetRoot,
248
- relativePath: parentRel,
249
- originalPath: params.originalPath,
250
- });
251
- checkExtractionDeadline(params.deadline);
252
- await assertDirectoryIdentityGuard(destinationGuard);
226
+ assertDirectoryIdentityGuard(destinationGuard);
253
227
  checkExtractionDeadline(params.deadline);
228
+ if (params.isDirectory) {
229
+ await assertResolvedInsideDestination({
230
+ destinationRealDir: params.destinationRealDir,
231
+ targetPath: params.outPath,
232
+ originalPath: params.originalPath,
233
+ });
234
+ checkExtractionDeadline(params.deadline);
235
+ }
254
236
  });
255
237
  }
238
+ if (params.isDirectory)
239
+ return;
256
240
  await assertResolvedInsideDestination({
257
241
  destinationRealDir: params.destinationRealDir,
258
242
  targetPath: path.dirname(params.outPath),
@@ -292,12 +276,12 @@ export async function withStagedArchiveDestination(params) {
292
276
  const stagingGuard = await createDirectoryIdentityGuard(stagingDir);
293
277
  try {
294
278
  await fs.chmod(stagingDir, ARCHIVE_STAGING_MODE).catch(() => undefined);
295
- await assertDirectoryIdentityGuard(stagingGuard);
279
+ assertDirectoryIdentityGuard(stagingGuard);
296
280
  return await params.run(stagingDir);
297
281
  }
298
282
  finally {
299
283
  try {
300
- await assertDirectoryIdentityGuard(stagingGuard);
284
+ assertDirectoryIdentityGuard(stagingGuard);
301
285
  await fs.rm(stagingDir, { recursive: true, force: true }).catch(() => undefined);
302
286
  }
303
287
  catch {
@@ -0,0 +1,17 @@
1
+ import { type AnyAsyncDirectoryGuard } from "./directory-guard.js";
2
+ export type CopyPath = {
3
+ rootPath: string;
4
+ absolutePath: string;
5
+ };
6
+ declare function admitUncachedCopyPath(input: CopyPath, create?: boolean, admittedRoot?: AnyAsyncDirectoryGuard): {
7
+ path: string;
8
+ parent: AnyAsyncDirectoryGuard;
9
+ assertCurrent: () => void;
10
+ rootCanonicalPath: string | undefined;
11
+ };
12
+ /** Metadata custody lasts only for the owning copy or explicit batch. */
13
+ export declare function createCopyPathAdmissionCache(): {
14
+ admit: (input: CopyPath, create?: boolean) => ReturnType<typeof admitUncachedCopyPath>;
15
+ clear(): void;
16
+ };
17
+ export {};
@@ -0,0 +1,117 @@
1
+ import fs from "node:fs";
2
+ import path from "node:path";
3
+ import { assertSyncDirectoryGuard, captureDirectoryGuard, inspectDirectoryIdentitySync } from "./directory-guard.js";
4
+ import { FsSafeError } from "./errors.js";
5
+ import { sameFileIdentity } from "./file-identity.js";
6
+ import { realpathSync } from "./realpath.js";
7
+ import { resolveRootPathSync, ROOT_PATH_ALIAS_POLICIES } from "./root-path.js";
8
+ function admitUncachedCopyPath(input, create = false, admittedRoot) {
9
+ if (!path.isAbsolute(input.rootPath) || !path.isAbsolute(input.absolutePath)) {
10
+ throw new FsSafeError("invalid-path", "copy roots and paths must be absolute");
11
+ }
12
+ const root = admittedRoot ?? captureDirectoryGuard(realpathSync(input.rootPath), "native", { bigint: true });
13
+ // Canonical POSIX callers already own a freshly checked root. Keep the
14
+ // resolver's lexical/symlink walk, but do not rediscover that root each time.
15
+ const rootCanonicalPath = admittedRoot?.realPath;
16
+ const resolve = () => {
17
+ const parent = create ? resolveRootPathSync({
18
+ ...input, rootCanonicalPath, absolutePath: path.dirname(input.absolutePath), boundaryLabel: "copy parent",
19
+ rejectSymlinks: true, rejectFinalSymlink: true,
20
+ }) : undefined;
21
+ const selected = resolveRootPathSync({
22
+ ...input, rootCanonicalPath, boundaryLabel: "copy", rejectSymlinks: !create, rejectFinalSymlink: !create,
23
+ policy: create ? ROOT_PATH_ALIAS_POLICIES.unlinkTarget : undefined,
24
+ });
25
+ if (parent && path.dirname(selected.canonicalPath) !== parent.canonicalPath) {
26
+ throw new FsSafeError("path-mismatch", "copy destination parent changed");
27
+ }
28
+ return selected;
29
+ };
30
+ const selected = resolve();
31
+ const parent = captureDirectoryGuard(path.dirname(selected.canonicalPath), "native", { bigint: true });
32
+ const assertCurrent = () => {
33
+ assertSyncDirectoryGuard(root);
34
+ assertSyncDirectoryGuard(parent);
35
+ const current = resolve();
36
+ if (current.rootCanonicalPath !== root.realPath || current.canonicalPath !== selected.canonicalPath) {
37
+ throw new FsSafeError("path-mismatch", "copy path changed during operation");
38
+ }
39
+ assertSyncDirectoryGuard(root);
40
+ assertSyncDirectoryGuard(parent);
41
+ };
42
+ assertCurrent();
43
+ return { path: selected.canonicalPath, parent, assertCurrent, rootCanonicalPath: undefined };
44
+ }
45
+ /** Metadata custody lasts only for the owning copy or explicit batch. */
46
+ export function createCopyPathAdmissionCache() {
47
+ const roots = new Map();
48
+ const parents = new Map();
49
+ const directories = new Map();
50
+ const assertParent = ({ root, parent, chain }) => {
51
+ assertSyncDirectoryGuard(root);
52
+ for (const guard of chain) {
53
+ inspectDirectoryIdentitySync(guard.dir, { dev: BigInt(guard.stat.dev), ino: BigInt(guard.stat.ino) });
54
+ }
55
+ assertSyncDirectoryGuard(parent);
56
+ assertSyncDirectoryGuard(root);
57
+ };
58
+ const admit = (input, create = false) => {
59
+ // Keep the public resolver for Windows aliases and noncanonical spellings,
60
+ // including raw dot segments whose traversal must not be normalized away.
61
+ if (process.platform === "win32" || !path.isAbsolute(input.rootPath) ||
62
+ !path.isAbsolute(input.absolutePath) || input.rootPath.includes("\0") || input.absolutePath.includes("\0") ||
63
+ path.resolve(input.rootPath) !== input.rootPath || path.resolve(input.absolutePath) !== input.absolutePath ||
64
+ !input.absolutePath.startsWith(input.rootPath.endsWith(path.sep) ? input.rootPath : `${input.rootPath}${path.sep}`)) {
65
+ return admitUncachedCopyPath(input, create);
66
+ }
67
+ let root = roots.get(input.rootPath);
68
+ if (!root) {
69
+ const canonical = realpathSync(input.rootPath);
70
+ if (canonical !== input.rootPath)
71
+ return admitUncachedCopyPath(input, create);
72
+ root = captureDirectoryGuard(canonical, "native", { bigint: true });
73
+ roots.set(input.rootPath, root);
74
+ }
75
+ assertSyncDirectoryGuard(root);
76
+ const parentPath = path.dirname(input.absolutePath);
77
+ let byParent = parents.get(input.rootPath);
78
+ let admitted = byParent?.get(parentPath);
79
+ if (!admitted) {
80
+ // The first file in each parent retains the existing lexical admission.
81
+ const selected = admitUncachedCopyPath(input, create, root);
82
+ const chain = [];
83
+ let cursor = input.rootPath;
84
+ const relative = path.relative(input.rootPath, parentPath);
85
+ for (const segment of relative ? relative.split(path.sep) : []) {
86
+ cursor = path.join(cursor, segment);
87
+ let guard = directories.get(cursor);
88
+ if (!guard) {
89
+ guard = captureDirectoryGuard(cursor, "native", { bigint: true });
90
+ directories.set(cursor, guard);
91
+ }
92
+ chain.push(guard);
93
+ }
94
+ admitted = { root, parent: chain.at(-1) ?? root, chain };
95
+ assertParent(admitted);
96
+ if (selected.path !== input.absolutePath || selected.parent.realPath !== parentPath ||
97
+ !sameFileIdentity(selected.parent.stat, admitted.parent.stat)) {
98
+ throw new FsSafeError("path-mismatch", "copy path changed during admission");
99
+ }
100
+ byParent ??= new Map();
101
+ byParent.set(parentPath, admitted);
102
+ parents.set(input.rootPath, byParent);
103
+ }
104
+ const selected = admitted;
105
+ const assertCurrent = () => {
106
+ assertParent(selected);
107
+ // No file observation is cached. Preserve the resolver's symlink errors.
108
+ if (!create && fs.lstatSync(input.absolutePath, { throwIfNoEntry: false })?.isSymbolicLink()) {
109
+ admitUncachedCopyPath(input, create);
110
+ throw new FsSafeError("symlink", "symlink not allowed");
111
+ }
112
+ };
113
+ assertCurrent();
114
+ return { path: input.absolutePath, parent: selected.parent, assertCurrent, rootCanonicalPath: selected.root.realPath };
115
+ };
116
+ return { admit, clear() { roots.clear(); parents.clear(); directories.clear(); } };
117
+ }
@@ -0,0 +1,38 @@
1
+ import { type CopyPath } from "./copy-path-admission.js";
2
+ import { type CopyCloneMode } from "./copy-policy.js";
3
+ import { type OwnedFileDescriptorSync } from "./create-owned-file.js";
4
+ export type CopyRootFileSyncOptions = {
5
+ source: CopyPath;
6
+ destination: CopyPath;
7
+ expectedSourceIdentity?: {
8
+ dev: bigint;
9
+ ino: bigint;
10
+ };
11
+ clone?: CopyCloneMode;
12
+ maxBytes?: number;
13
+ mode?: number;
14
+ preserveSourceMode?: boolean;
15
+ sourceHardlinks?: "reject" | "allow";
16
+ };
17
+ export type CopiedRootFileSync = OwnedFileDescriptorSync & Readonly<{
18
+ path: string;
19
+ bytes: number;
20
+ method: "clone" | "copy-file-range" | "copy";
21
+ identity: Readonly<{
22
+ dev: bigint;
23
+ ino: bigint;
24
+ }>;
25
+ sourceIdentity: Readonly<{
26
+ dev: bigint;
27
+ ino: bigint;
28
+ }>;
29
+ }>;
30
+ /** Exclusively copies an admitted source and transfers the owned destination fd. */
31
+ export declare function copyRootFileSync(options: CopyRootFileSyncOptions): CopiedRootFileSync;
32
+ export type RootFileCopyBatchSync = {
33
+ copyFile(options: CopyRootFileSyncOptions): CopiedRootFileSync;
34
+ close(): void;
35
+ [Symbol.dispose](): void;
36
+ };
37
+ /** Reuses directory admissions while retaining fresh checks for every copy. */
38
+ export declare function createRootFileCopyBatchSync(): RootFileCopyBatchSync;