@openclaw/matrix 2026.10.5-beta.4 → 2026.10.10-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.
Files changed (313) hide show
  1. package/dist/.setup/{approval-handler.runtime-rxLn8CbP.mjs → approval-handler.runtime-CsqMdj7h.mjs} +9 -9
  2. package/dist/.setup/{approval-reactions-DhB6gNPU.mjs → approval-reactions-D2pEUrFS.mjs} +1 -1
  3. package/dist/.setup/{channel-BcwGspPw.mjs → channel-Dw4_imdd.mjs} +132 -111
  4. package/dist/.setup/{channel.runtime-CUc6rbu1.mjs → channel.runtime-2EEtIlyu.mjs} +6 -6
  5. package/dist/.setup/{channel.setup-CwuYD_CT.mjs → channel.setup-Be8TYKMA.mjs} +8 -3
  6. package/dist/.setup/{cli-mbL9jCro.mjs → cli-CEmWh7wh.mjs} +99 -37
  7. package/dist/.setup/{cli-metadata-6MOGuyHq.mjs → cli-metadata-CBLGwJT6.mjs} +1 -1
  8. package/dist/.setup/{client-BlTvpEWC.mjs → client-BKiiI29H.mjs} +3 -3
  9. package/dist/.setup/{client-vPPbaxNp.mjs → client-C4Gibhzl.mjs} +94 -120
  10. package/dist/.setup/{client-bootstrap-D05xy1HB.mjs → client-bootstrap-kOIDV4z_.mjs} +3 -3
  11. package/dist/.setup/{create-client-CroC4BVc.mjs → create-client-BS8UYx6N.mjs} +23 -15
  12. package/dist/.setup/{credentials-Bf9PQ7xs.mjs → credentials-CPnJZaZB.mjs} +3 -5
  13. package/dist/.setup/{credentials-read-CqRiEAQa.mjs → credentials-read-D2ULV55A.mjs} +12 -4
  14. package/dist/.setup/{crypto-runtime-CpJ0b7vY.mjs → crypto-runtime-D8yY7kjD.mjs} +168 -290
  15. package/dist/.setup/crypto-state-store-D4wrCvFs.mjs +185 -0
  16. package/dist/.setup/crypto-store-ownership-Z_Y5WRKr.mjs +174 -0
  17. package/dist/.setup/crypto-unsafe-state-doctor-C8szCYmf.mjs +54 -0
  18. package/dist/.setup/{directory-live-B1WbfSHo.mjs → directory-live-BpSz-FQB.mjs} +1 -1
  19. package/dist/.setup/{draft-stream-Bdrh7dRt.mjs → draft-stream-DYf0th1n.mjs} +1 -1
  20. package/dist/.setup/{exec-approvals-BgNWWJg1.mjs → exec-approvals-DaM-5OA5.mjs} +33 -43
  21. package/dist/.setup/{file-sync-store-BdKx_gMi.mjs → file-sync-store-CUH8EAJq.mjs} +3 -3
  22. package/dist/.setup/idb-persistence-BHTYPRe_.mjs +233 -0
  23. package/dist/.setup/idb-persistence-lock-Bh3ZLIsE.mjs +14 -0
  24. package/dist/.setup/{messages-B1CZqU8u.mjs → messages-_XHVg3do.mjs} +3 -18
  25. package/dist/.setup/{monitor-Dk_fQL1k.mjs → monitor-DRUSJ_Ev.mjs} +31 -39
  26. package/dist/.setup/{onboarding-CrSexor_.mjs → onboarding-CK9Ksgio.mjs} +3 -3
  27. package/dist/.setup/{outbound-LR3SqPIq.mjs → outbound-D5Z_4FBg.mjs} +28 -36
  28. package/dist/.setup/{profile-update-C7bjaGR6.mjs → profile-update--Pf3jCXD.mjs} +2 -2
  29. package/dist/.setup/{reaction-events-CTSvOlXO.mjs → reaction-events-BG9spedG.mjs} +6 -6
  30. package/dist/.setup/{resolve-targets-BVVbbvP6.mjs → resolve-targets-BJ5sIKeM.mjs} +1 -1
  31. package/dist/.setup/{retired-state-DW5pLH05.mjs → retired-state-DOCruzWd.mjs} +10 -10
  32. package/dist/.setup/{room-info-9Uqlpt1V.mjs → room-info-BE7bbX_c.mjs} +3 -3
  33. package/dist/.setup/runtime-setter-api-i2MOXoT3.mjs +2 -0
  34. package/dist/.setup/{sdk-Cfc6m7fY.mjs → sdk-ByU8So5S.mjs} +242 -139
  35. package/dist/.setup/secret-contract-DxyzKSzf.mjs +90 -0
  36. package/dist/.setup/secret-contract-api-Dukgvike.mjs +2 -0
  37. package/dist/.setup/{send-LCOuTVc1.mjs → send-BprM-Wmx.mjs} +19 -42
  38. package/dist/.setup/{setup-bootstrap-CV-hHBXu.mjs → setup-bootstrap-DmznRqYe.mjs} +2 -6
  39. package/dist/.setup/{setup-core-CKnNTfgD.mjs → setup-core-DcCk1_Tv.mjs} +4 -7
  40. package/dist/.setup/setup-plugin-api-BU6UGksW.mjs +2 -0
  41. package/dist/.setup/{startup-verification-CgfUb4yJ.mjs → startup-verification-UU8DUvi4.mjs} +5 -13
  42. package/dist/.setup/state-layout-walk-BQMgMykU.mjs +27 -0
  43. package/dist/.setup/{storage-DkC6bHgA.mjs → storage-l8V0XsGM.mjs} +7 -166
  44. package/dist/.setup/{subagent-hooks-D8jyeQsO.mjs → subagent-hooks-CSY4iwa_.mjs} +7 -6
  45. package/dist/.setup/{sync-cache-state-D4G-fi3t.mjs → sync-cache-state-Cnm4TCEI.mjs} +1 -1
  46. package/dist/.setup/thread-bindings-rrwQAS6R.mjs +620 -0
  47. package/dist/.setup/{thread-bindings-shared-CbsFNbAY.mjs → thread-bindings-shared-CPjUA0Ib.mjs} +26 -5
  48. package/dist/.setup/{tool-actions-DAp6_XSJ.mjs → tool-actions-DBrk6Yei.mjs} +9 -11
  49. package/dist/.setup/{verification-B3VswneT.mjs → verification--qUbmRd-.mjs} +2 -2
  50. package/dist/api.js +6 -6
  51. package/dist/auth-presence.js +16 -2
  52. package/dist/channel-plugin-api.js +1 -2
  53. package/dist/cli-metadata.js +1 -2
  54. package/dist/contract-api.js +2 -2
  55. package/dist/doctor-contract-api.js +20 -27
  56. package/dist/index.js +38 -12
  57. package/dist/plugin-entry.handlers.runtime.js +32 -5
  58. package/dist/runtime-api.js +3 -3
  59. package/dist/runtime-setter-api.js +1 -2
  60. package/dist/secret-contract-api.js +1 -2
  61. package/dist/session-binding-contract-api.js +1 -1
  62. package/dist/setup-entry.js +3 -3
  63. package/dist/setup-plugin-api.js +1 -2
  64. package/dist/subagent-hooks-api.js +1 -1
  65. package/dist/thread-binding-api.js +1 -2
  66. package/dist/thread-bindings-runtime.js +1 -2
  67. package/node_modules/@openclaw/fs-safe/CHANGELOG.md +148 -0
  68. package/node_modules/@openclaw/fs-safe/README.md +20 -4
  69. package/node_modules/@openclaw/fs-safe/dist/advanced.d.ts +2 -1
  70. package/node_modules/@openclaw/fs-safe/dist/advanced.js +1 -0
  71. package/node_modules/@openclaw/fs-safe/dist/archive-merge.js +28 -3
  72. package/node_modules/@openclaw/fs-safe/dist/archive-parser.wasm +0 -0
  73. package/node_modules/@openclaw/fs-safe/dist/archive-read.js +11 -5
  74. package/node_modules/@openclaw/fs-safe/dist/archive-zip-loader.js +4 -2
  75. package/node_modules/@openclaw/fs-safe/dist/archive.js +2 -2
  76. package/node_modules/@openclaw/fs-safe/dist/atomic-io.js +2 -2
  77. package/node_modules/@openclaw/fs-safe/dist/bounded-read.d.ts +1 -0
  78. package/node_modules/@openclaw/fs-safe/dist/bounded-read.js +9 -2
  79. package/node_modules/@openclaw/fs-safe/dist/clone-metadata.d.ts +2 -0
  80. package/node_modules/@openclaw/fs-safe/dist/clone-metadata.js +2 -1
  81. package/node_modules/@openclaw/fs-safe/dist/config.d.ts +6 -0
  82. package/node_modules/@openclaw/fs-safe/dist/config.js +5 -0
  83. package/node_modules/@openclaw/fs-safe/dist/copy-file-input.d.ts +3 -1
  84. package/node_modules/@openclaw/fs-safe/dist/copy-file-input.js +8 -7
  85. package/node_modules/@openclaw/fs-safe/dist/copy-link.d.ts +26 -0
  86. package/node_modules/@openclaw/fs-safe/dist/copy-link.js +170 -0
  87. package/node_modules/@openclaw/fs-safe/dist/copy-metadata.d.ts +9 -0
  88. package/node_modules/@openclaw/fs-safe/dist/copy-metadata.js +39 -0
  89. package/node_modules/@openclaw/fs-safe/dist/copy-path-admission.js +11 -2
  90. package/node_modules/@openclaw/fs-safe/dist/copy-root-file-sync.d.ts +2 -4
  91. package/node_modules/@openclaw/fs-safe/dist/copy-root-file-sync.js +4 -2
  92. package/node_modules/@openclaw/fs-safe/dist/copy-tree-portable.js +3 -6
  93. package/node_modules/@openclaw/fs-safe/dist/copy.js +3 -3
  94. package/node_modules/@openclaw/fs-safe/dist/create.js +1 -1
  95. package/node_modules/@openclaw/fs-safe/dist/creation-boundary.js +7 -4
  96. package/node_modules/@openclaw/fs-safe/dist/darwin-acl.d.ts +12 -0
  97. package/node_modules/@openclaw/fs-safe/dist/darwin-acl.js +29 -0
  98. package/node_modules/@openclaw/fs-safe/dist/directory-durability.d.ts +7 -4
  99. package/node_modules/@openclaw/fs-safe/dist/directory-guard.js +20 -5
  100. package/node_modules/@openclaw/fs-safe/dist/directory-mode-node.d.ts +3 -0
  101. package/node_modules/@openclaw/fs-safe/dist/directory-mode-node.js +27 -2
  102. package/node_modules/@openclaw/fs-safe/dist/directory-receipt.d.ts +7 -7
  103. package/node_modules/@openclaw/fs-safe/dist/directory-receipt.js +9 -4
  104. package/node_modules/@openclaw/fs-safe/dist/durability.d.ts +2 -1
  105. package/node_modules/@openclaw/fs-safe/dist/entry-publication.js +2 -2
  106. package/node_modules/@openclaw/fs-safe/dist/exact-identity.d.ts +17 -0
  107. package/node_modules/@openclaw/fs-safe/dist/exact-identity.js +29 -0
  108. package/node_modules/@openclaw/fs-safe/dist/file-handle-transfer.js +4 -2
  109. package/node_modules/@openclaw/fs-safe/dist/file-hash.d.ts +1 -1
  110. package/node_modules/@openclaw/fs-safe/dist/file-hash.js +11 -9
  111. package/node_modules/@openclaw/fs-safe/dist/file-identity.d.ts +7 -1
  112. package/node_modules/@openclaw/fs-safe/dist/file-identity.js +27 -5
  113. package/node_modules/@openclaw/fs-safe/dist/file-lock-sync-admission.js +1 -2
  114. package/node_modules/@openclaw/fs-safe/dist/file-lock-sync.js +8 -1
  115. package/node_modules/@openclaw/fs-safe/dist/file-lock.d.ts +1 -0
  116. package/node_modules/@openclaw/fs-safe/dist/file-lock.js +1 -0
  117. package/node_modules/@openclaw/fs-safe/dist/file-write-lease.d.ts +9 -0
  118. package/node_modules/@openclaw/fs-safe/dist/file-write-lease.js +42 -0
  119. package/node_modules/@openclaw/fs-safe/dist/guarded-mkdir.d.ts +1 -0
  120. package/node_modules/@openclaw/fs-safe/dist/guarded-mkdir.js +22 -15
  121. package/node_modules/@openclaw/fs-safe/dist/guest-native-python.js +3 -0
  122. package/node_modules/@openclaw/fs-safe/dist/hardlink-fallback.d.ts +1 -0
  123. package/node_modules/@openclaw/fs-safe/dist/hardlink-fallback.js +5 -0
  124. package/node_modules/@openclaw/fs-safe/dist/index.d.ts +1 -0
  125. package/node_modules/@openclaw/fs-safe/dist/index.js +1 -0
  126. package/node_modules/@openclaw/fs-safe/dist/json-durable-queue-ownership.js +16 -3
  127. package/node_modules/@openclaw/fs-safe/dist/local-file-descriptor.js +24 -13
  128. package/node_modules/@openclaw/fs-safe/dist/native-binding.d.ts +85 -18
  129. package/node_modules/@openclaw/fs-safe/dist/native-config.d.ts +5 -0
  130. package/node_modules/@openclaw/fs-safe/dist/native-config.js +11 -0
  131. package/node_modules/@openclaw/fs-safe/dist/native-directory-observation.js +6 -4
  132. package/node_modules/@openclaw/fs-safe/dist/native-fallback-warning.d.ts +2 -1
  133. package/node_modules/@openclaw/fs-safe/dist/native-fallback-warning.js +26 -2
  134. package/node_modules/@openclaw/fs-safe/dist/native-guidance.d.ts +3 -0
  135. package/node_modules/@openclaw/fs-safe/dist/native-guidance.js +21 -0
  136. package/node_modules/@openclaw/fs-safe/dist/native-move-fallback.d.ts +1 -1
  137. package/node_modules/@openclaw/fs-safe/dist/native-move-fallback.js +2 -0
  138. package/node_modules/@openclaw/fs-safe/dist/native-operations.js +8 -6
  139. package/node_modules/@openclaw/fs-safe/dist/native-parent-admission.d.ts +44 -4
  140. package/node_modules/@openclaw/fs-safe/dist/native-parent-admission.js +85 -15
  141. package/node_modules/@openclaw/fs-safe/dist/native-pinned-write-windows.d.ts +3 -3
  142. package/node_modules/@openclaw/fs-safe/dist/native-pinned-write-windows.js +33 -6
  143. package/node_modules/@openclaw/fs-safe/dist/native-pinned-write.d.ts +4 -1
  144. package/node_modules/@openclaw/fs-safe/dist/native-pinned-write.js +22 -3
  145. package/node_modules/@openclaw/fs-safe/dist/native-policy-directory-observation.js +4 -3
  146. package/node_modules/@openclaw/fs-safe/dist/native-policy-parent.d.ts +1 -1
  147. package/node_modules/@openclaw/fs-safe/dist/native-policy-parent.js +3 -0
  148. package/node_modules/@openclaw/fs-safe/dist/native-staged-file-metadata.d.ts +3 -0
  149. package/node_modules/@openclaw/fs-safe/dist/native-staged-file-metadata.js +16 -0
  150. package/node_modules/@openclaw/fs-safe/dist/native-staged-file.d.ts +1 -1
  151. package/node_modules/@openclaw/fs-safe/dist/native-staged-file.js +15 -5
  152. package/node_modules/@openclaw/fs-safe/dist/native-stat-identity.d.ts +3 -0
  153. package/node_modules/@openclaw/fs-safe/dist/native-stat-identity.js +7 -0
  154. package/node_modules/@openclaw/fs-safe/dist/native-status.d.ts +17 -0
  155. package/node_modules/@openclaw/fs-safe/dist/native-status.js +30 -0
  156. package/node_modules/@openclaw/fs-safe/dist/native.d.ts +31 -4
  157. package/node_modules/@openclaw/fs-safe/dist/native.js +107 -9
  158. package/node_modules/@openclaw/fs-safe/dist/opened-realpath.js +9 -1
  159. package/node_modules/@openclaw/fs-safe/dist/overwrite-file-handle.js +4 -1
  160. package/node_modules/@openclaw/fs-safe/dist/owner-dacl-batch.js +1 -1
  161. package/node_modules/@openclaw/fs-safe/dist/owner-dacl.js +1 -1
  162. package/node_modules/@openclaw/fs-safe/dist/permission-exec.js +9 -1
  163. package/node_modules/@openclaw/fs-safe/dist/permissions-public.d.ts +1 -0
  164. package/node_modules/@openclaw/fs-safe/dist/permissions-public.js +1 -0
  165. package/node_modules/@openclaw/fs-safe/dist/permissions-windows.js +83 -47
  166. package/node_modules/@openclaw/fs-safe/dist/pinned-open.d.ts +2 -0
  167. package/node_modules/@openclaw/fs-safe/dist/pinned-open.js +8 -3
  168. package/node_modules/@openclaw/fs-safe/dist/pinned-write-input.js +13 -0
  169. package/node_modules/@openclaw/fs-safe/dist/pinned-write-staged.js +10 -8
  170. package/node_modules/@openclaw/fs-safe/dist/pinned-write-types.d.ts +2 -1
  171. package/node_modules/@openclaw/fs-safe/dist/pinned-write.js +7 -5
  172. package/node_modules/@openclaw/fs-safe/dist/pipe.d.ts +9 -0
  173. package/node_modules/@openclaw/fs-safe/dist/pipe.js +26 -0
  174. package/node_modules/@openclaw/fs-safe/dist/private-directory.js +1 -1
  175. package/node_modules/@openclaw/fs-safe/dist/private-producer-handoff.js +2 -5
  176. package/node_modules/@openclaw/fs-safe/dist/private-temp-workspace.d.ts +3 -2
  177. package/node_modules/@openclaw/fs-safe/dist/private-temp-workspace.js +38 -10
  178. package/node_modules/@openclaw/fs-safe/dist/publish-copy-stage.js +92 -10
  179. package/node_modules/@openclaw/fs-safe/dist/publish-file-failure.d.ts +3 -0
  180. package/node_modules/@openclaw/fs-safe/dist/publish-file-failure.js +3 -0
  181. package/node_modules/@openclaw/fs-safe/dist/publish-file.d.ts +5 -3
  182. package/node_modules/@openclaw/fs-safe/dist/publish-file.js +26 -20
  183. package/node_modules/@openclaw/fs-safe/dist/read-opened-file.d.ts +2 -0
  184. package/node_modules/@openclaw/fs-safe/dist/read-opened-file.js +3 -4
  185. package/node_modules/@openclaw/fs-safe/dist/realpath.js +32 -0
  186. package/node_modules/@openclaw/fs-safe/dist/regular-file.d.ts +4 -0
  187. package/node_modules/@openclaw/fs-safe/dist/regular-file.js +11 -15
  188. package/node_modules/@openclaw/fs-safe/dist/replace-file-descriptor.js +3 -2
  189. package/node_modules/@openclaw/fs-safe/dist/root-copy.d.ts +18 -0
  190. package/node_modules/@openclaw/fs-safe/dist/root-copy.js +128 -0
  191. package/node_modules/@openclaw/fs-safe/dist/root-create-native.d.ts +8 -13
  192. package/node_modules/@openclaw/fs-safe/dist/root-create-native.js +252 -27
  193. package/node_modules/@openclaw/fs-safe/dist/root-directory-creation.js +5 -1
  194. package/node_modules/@openclaw/fs-safe/dist/root-directory-list-types.d.ts +11 -8
  195. package/node_modules/@openclaw/fs-safe/dist/root-directory-list.js +35 -13
  196. package/node_modules/@openclaw/fs-safe/dist/root-file-open-batch-sync.d.ts +8 -0
  197. package/node_modules/@openclaw/fs-safe/dist/root-file-open-batch-sync.js +108 -0
  198. package/node_modules/@openclaw/fs-safe/dist/root-file.d.ts +7 -0
  199. package/node_modules/@openclaw/fs-safe/dist/root-file.js +15 -0
  200. package/node_modules/@openclaw/fs-safe/dist/root-impl.d.ts +2 -0
  201. package/node_modules/@openclaw/fs-safe/dist/root-impl.js +154 -175
  202. package/node_modules/@openclaw/fs-safe/dist/root-mkdir-native.d.ts +2 -0
  203. package/node_modules/@openclaw/fs-safe/dist/root-mkdir-native.js +239 -0
  204. package/node_modules/@openclaw/fs-safe/dist/root-move-noreplace.js +37 -15
  205. package/node_modules/@openclaw/fs-safe/dist/root-native-creation-path.d.ts +32 -0
  206. package/node_modules/@openclaw/fs-safe/dist/root-native-creation-path.js +56 -0
  207. package/node_modules/@openclaw/fs-safe/dist/root-options.d.ts +2 -0
  208. package/node_modules/@openclaw/fs-safe/dist/root-public-types.d.ts +1 -0
  209. package/node_modules/@openclaw/fs-safe/dist/root-remove-native.js +95 -16
  210. package/node_modules/@openclaw/fs-safe/dist/root-remove.js +6 -4
  211. package/node_modules/@openclaw/fs-safe/dist/root-walk.js +23 -19
  212. package/node_modules/@openclaw/fs-safe/dist/root-write-admission.js +8 -6
  213. package/node_modules/@openclaw/fs-safe/dist/root-write-publication.js +5 -1
  214. package/node_modules/@openclaw/fs-safe/dist/secure-file-windows.js +3 -1
  215. package/node_modules/@openclaw/fs-safe/dist/secure-file.d.ts +2 -0
  216. package/node_modules/@openclaw/fs-safe/dist/secure-file.js +10 -4
  217. package/node_modules/@openclaw/fs-safe/dist/sibling-staged-file.js +1 -1
  218. package/node_modules/@openclaw/fs-safe/dist/sidecar-lock-reclaim.js +2 -2
  219. package/node_modules/@openclaw/fs-safe/dist/sidecar-lock-retained.js +1 -1
  220. package/node_modules/@openclaw/fs-safe/dist/sidecar-lock-target.js +8 -1
  221. package/node_modules/@openclaw/fs-safe/dist/staged-directory.d.ts +13 -0
  222. package/node_modules/@openclaw/fs-safe/dist/staged-directory.js +29 -0
  223. package/node_modules/@openclaw/fs-safe/dist/temp-workspace-child-admission.js +5 -3
  224. package/node_modules/@openclaw/fs-safe/dist/temp-workspace-descriptor.d.ts +8 -0
  225. package/node_modules/@openclaw/fs-safe/dist/temp-workspace-descriptor.js +13 -2
  226. package/node_modules/@openclaw/fs-safe/dist/temp-workspace-owner.js +71 -3
  227. package/node_modules/@openclaw/fs-safe/dist/temp-workspace-ownership.d.ts +2 -1
  228. package/node_modules/@openclaw/fs-safe/dist/temp-workspace-ownership.js +22 -0
  229. package/node_modules/@openclaw/fs-safe/dist/temp-workspace-types.d.ts +3 -0
  230. package/node_modules/@openclaw/fs-safe/dist/test-hooks.d.ts +1 -0
  231. package/node_modules/@openclaw/fs-safe/dist/test-hooks.js +1 -0
  232. package/node_modules/@openclaw/fs-safe/dist/trash.js +2 -2
  233. package/node_modules/@openclaw/fs-safe/dist/types.d.ts +4 -0
  234. package/node_modules/@openclaw/fs-safe/dist/watch-native.js +2 -2
  235. package/node_modules/@openclaw/fs-safe/dist/windows-appcontainer.d.ts +5 -0
  236. package/node_modules/@openclaw/fs-safe/dist/windows-appcontainer.js +39 -0
  237. package/node_modules/@openclaw/fs-safe/dist/windows-owner.d.ts +1 -0
  238. package/node_modules/@openclaw/fs-safe/dist/windows-owner.js +25 -36
  239. package/node_modules/@openclaw/fs-safe/dist/windows-security-command.js +24 -5
  240. package/node_modules/@openclaw/fs-safe/dist/windows-security-facts.d.ts +2 -1
  241. package/node_modules/@openclaw/fs-safe/dist/windows-security-facts.js +4 -0
  242. package/node_modules/@openclaw/fs-safe/dist/windows-security-helper.d.ts +2 -0
  243. package/node_modules/@openclaw/fs-safe/dist/windows-security-helper.exe +0 -0
  244. package/node_modules/@openclaw/fs-safe/dist/windows-security-helper.js +7 -0
  245. package/node_modules/@openclaw/fs-safe/dist/windows-test-hooks.d.ts +16 -0
  246. package/node_modules/@openclaw/fs-safe/dist/windows-test-hooks.js +51 -0
  247. package/node_modules/@openclaw/fs-safe/dist/write-file-handle.d.ts +1 -0
  248. package/node_modules/@openclaw/fs-safe/dist/write-file-handle.js +12 -10
  249. package/node_modules/@openclaw/fs-safe/docs/advanced.md +2 -1
  250. package/node_modules/@openclaw/fs-safe/docs/archive.md +16 -0
  251. package/node_modules/@openclaw/fs-safe/docs/config.md +71 -1
  252. package/node_modules/@openclaw/fs-safe/docs/contributing.md +45 -5
  253. package/node_modules/@openclaw/fs-safe/docs/copy.md +45 -5
  254. package/node_modules/@openclaw/fs-safe/docs/durability.md +34 -7
  255. package/node_modules/@openclaw/fs-safe/docs/errors.md +8 -0
  256. package/node_modules/@openclaw/fs-safe/docs/guest.md +2 -0
  257. package/node_modules/@openclaw/fs-safe/docs/install.md +47 -27
  258. package/node_modules/@openclaw/fs-safe/docs/migrating-to-0.5.md +6 -6
  259. package/node_modules/@openclaw/fs-safe/docs/migrating-to-0.6.md +1 -1
  260. package/node_modules/@openclaw/fs-safe/docs/native-helper.md +79 -6
  261. package/node_modules/@openclaw/fs-safe/docs/native.md +279 -8
  262. package/node_modules/@openclaw/fs-safe/docs/permissions.md +64 -15
  263. package/node_modules/@openclaw/fs-safe/docs/pipe.md +81 -0
  264. package/node_modules/@openclaw/fs-safe/docs/platform-capabilities.md +63 -0
  265. package/node_modules/@openclaw/fs-safe/docs/public-api.md +10 -0
  266. package/node_modules/@openclaw/fs-safe/docs/queue-link-free-design.md +237 -0
  267. package/node_modules/@openclaw/fs-safe/docs/quickstart.md +23 -3
  268. package/node_modules/@openclaw/fs-safe/docs/reading.md +56 -2
  269. package/node_modules/@openclaw/fs-safe/docs/regular-file.md +2 -0
  270. package/node_modules/@openclaw/fs-safe/docs/secret-file.md +5 -5
  271. package/node_modules/@openclaw/fs-safe/docs/secure-file.md +1 -1
  272. package/node_modules/@openclaw/fs-safe/docs/security-model.md +35 -0
  273. package/node_modules/@openclaw/fs-safe/docs/sidecar-lock.md +31 -13
  274. package/node_modules/@openclaw/fs-safe/docs/staged-file.md +18 -0
  275. package/node_modules/@openclaw/fs-safe/docs/store.md +15 -0
  276. package/node_modules/@openclaw/fs-safe/docs/temp.md +39 -0
  277. package/node_modules/@openclaw/fs-safe/docs/testing.md +13 -0
  278. package/node_modules/@openclaw/fs-safe/docs/types.md +51 -81
  279. package/node_modules/@openclaw/fs-safe/docs/walk.md +4 -1
  280. package/node_modules/@openclaw/fs-safe/docs/watch.md +3 -2
  281. package/node_modules/@openclaw/fs-safe/docs/writing.md +121 -14
  282. package/node_modules/@openclaw/fs-safe/package.json +21 -12
  283. package/node_modules/@openclaw/fs-safe-darwin-arm64/fs-safe-native.node +0 -0
  284. package/node_modules/@openclaw/fs-safe-darwin-arm64/package.json +1 -1
  285. package/node_modules/@openclaw/fs-safe-darwin-x64/fs-safe-native.node +0 -0
  286. package/node_modules/@openclaw/fs-safe-darwin-x64/package.json +1 -1
  287. package/node_modules/@openclaw/fs-safe-freebsd-arm64/fs-safe-native.node +0 -0
  288. package/node_modules/@openclaw/fs-safe-freebsd-arm64/package.json +29 -0
  289. package/node_modules/@openclaw/fs-safe-freebsd-x64/fs-safe-native.node +0 -0
  290. package/node_modules/@openclaw/fs-safe-freebsd-x64/package.json +29 -0
  291. package/node_modules/@openclaw/fs-safe-linux-arm64-gnu/fs-safe-native.node +0 -0
  292. package/node_modules/@openclaw/fs-safe-linux-arm64-gnu/package.json +1 -1
  293. package/node_modules/@openclaw/fs-safe-linux-arm64-musl/fs-safe-native.node +0 -0
  294. package/node_modules/@openclaw/fs-safe-linux-arm64-musl/package.json +1 -1
  295. package/node_modules/@openclaw/fs-safe-linux-x64-gnu/fs-safe-native.node +0 -0
  296. package/node_modules/@openclaw/fs-safe-linux-x64-gnu/package.json +1 -1
  297. package/node_modules/@openclaw/fs-safe-linux-x64-musl/fs-safe-native.node +0 -0
  298. package/node_modules/@openclaw/fs-safe-linux-x64-musl/package.json +1 -1
  299. package/node_modules/@openclaw/fs-safe-win32-arm64-msvc/fs-safe-native.node +0 -0
  300. package/node_modules/@openclaw/fs-safe-win32-arm64-msvc/package.json +29 -0
  301. package/node_modules/@openclaw/fs-safe-win32-x64-msvc/fs-safe-native.node +0 -0
  302. package/node_modules/@openclaw/fs-safe-win32-x64-msvc/package.json +1 -1
  303. package/node_modules/typebox/build/value/clean/from_object.mjs +1 -1
  304. package/node_modules/typebox/package.json +1 -1
  305. package/openclaw.plugin.json +3 -0
  306. package/package.json +7 -6
  307. package/dist/.setup/runtime-setter-api-DtxDAM-x.mjs +0 -3
  308. package/dist/.setup/secret-contract-DSBRvhdZ.mjs +0 -95
  309. package/dist/.setup/secret-contract-api-DzEJ-X7n.mjs +0 -3
  310. package/dist/.setup/setup-plugin-api-BDAYk1a5.mjs +0 -3
  311. package/dist/.setup/thread-bindings-CT4P-OSZ.mjs +0 -365
  312. package/node_modules/@openclaw/fs-safe/dist/windows-security-bridge.cs +0 -336
  313. package/node_modules/@openclaw/fs-safe/dist/windows-security-bridge.ps1 +0 -90
@@ -0,0 +1,185 @@
1
+ import { t as getMatrixRuntime } from "./runtime-1kn1P6io.mjs";
2
+ import { c as updateMatrixKeyedState, d as writeMatrixStateChunks, l as chunkMatrixStateJson, o as resolveMatrixSqliteStateEnv, u as readMatrixStateChunks } from "./retired-state-DOCruzWd.mjs";
3
+ import { isRecord } from "openclaw/plugin-sdk/string-coerce-runtime";
4
+ import { createHash, randomUUID } from "node:crypto";
5
+ import path from "node:path";
6
+ import { asSafeIntegerInRange } from "openclaw/plugin-sdk/number-runtime";
7
+ import fs from "node:fs";
8
+ //#region extensions/matrix/src/matrix/crypto-state-store.ts
9
+ const STATE_KEY = "current";
10
+ const RECOVERY_KEY_NAMESPACE = "recovery-key";
11
+ const LEGACY_CRYPTO_MIGRATION_NAMESPACE = "legacy-crypto-migration";
12
+ const IDB_SNAPSHOT_NAMESPACE = "idb-snapshot";
13
+ const SMALL_STATE_MAX_ENTRIES = 10;
14
+ const IDB_SNAPSHOT_MAX_ENTRIES = 2e4;
15
+ const IDB_SNAPSHOT_MAX_CHUNKS = Math.floor(19999 / 2);
16
+ const IDB_SNAPSHOT_CHUNK_BYTES = 24e3;
17
+ const MATRIX_RECOVERY_KEY_FILENAME = "recovery-key.json";
18
+ const MATRIX_IDB_SNAPSHOT_FILENAME = "crypto-idb-snapshot.json";
19
+ var MatrixIdbSnapshotInvalidError = class extends Error {
20
+ constructor(reason) {
21
+ super(`Invalid Matrix crypto SQLite snapshot (${reason}); preserve the account state and restore a valid backup before retrying.`);
22
+ this.code = "matrix-idb-snapshot-invalid";
23
+ this.name = "MatrixIdbSnapshotInvalidError";
24
+ }
25
+ };
26
+ function openMatrixRecoveryKeyStoreOptions(storageRootDir) {
27
+ return {
28
+ namespace: RECOVERY_KEY_NAMESPACE,
29
+ maxEntries: SMALL_STATE_MAX_ENTRIES,
30
+ env: resolveMatrixSqliteStateEnv({ stateDir: storageRootDir })
31
+ };
32
+ }
33
+ function openMatrixLegacyCryptoMigrationStoreOptions(storageRootDir) {
34
+ return {
35
+ namespace: LEGACY_CRYPTO_MIGRATION_NAMESPACE,
36
+ maxEntries: SMALL_STATE_MAX_ENTRIES,
37
+ env: resolveMatrixSqliteStateEnv({ stateDir: storageRootDir })
38
+ };
39
+ }
40
+ function openMatrixIdbSnapshotStoreOptions(storageRootDir) {
41
+ return {
42
+ namespace: IDB_SNAPSHOT_NAMESPACE,
43
+ maxEntries: IDB_SNAPSHOT_MAX_ENTRIES,
44
+ env: resolveMatrixSqliteStateEnv({ stateDir: storageRootDir })
45
+ };
46
+ }
47
+ async function readMatrixRecoveryKeyStateForPathAsync(recoveryKeyPath, stateRuntime) {
48
+ return normalizeMatrixStoredRecoveryKey(await stateRuntime.openKeyedStoreV2(openMatrixRecoveryKeyStoreOptions(path.dirname(recoveryKeyPath))).lookup(resolveRecoveryKeyStateKeyForPath(recoveryKeyPath)));
49
+ }
50
+ async function writeMatrixRecoveryKeyStateForPathAsync(params) {
51
+ const payload = normalizeMatrixStoredRecoveryKey(params.payload);
52
+ if (!payload) throw new Error("Invalid Matrix recovery key state");
53
+ const store = params.stateRuntime.openKeyedStoreV2(openMatrixRecoveryKeyStoreOptions(path.dirname(params.recoveryKeyPath)));
54
+ const key = resolveRecoveryKeyStateKeyForPath(params.recoveryKeyPath);
55
+ if (params.preserveEncodedPrivateKey) {
56
+ const update = (current) => normalizeMatrixStoredRecoveryKey({
57
+ ...payload,
58
+ encodedPrivateKey: normalizeMatrixStoredRecoveryKey(current)?.encodedPrivateKey
59
+ }) ?? void 0;
60
+ await updateMatrixKeyedState(store, key, update);
61
+ return;
62
+ }
63
+ await store.register(key, payload);
64
+ }
65
+ async function readMatrixIdbSnapshotJson(storageRootDir, stateRuntime = getMatrixRuntime().state) {
66
+ const store = stateRuntime.openKeyedStoreV2(openMatrixIdbSnapshotStoreOptions(storageRootDir));
67
+ const meta = await store.lookup(idbMetaKey());
68
+ if (meta === void 0) {
69
+ if ((await store.entries()).length !== 0) throw new MatrixIdbSnapshotInvalidError("metadata is missing");
70
+ return null;
71
+ }
72
+ if (!isIdbSnapshotMeta(meta)) throw new MatrixIdbSnapshotInvalidError("metadata is malformed");
73
+ const chunks = await readMatrixStateChunks(store, Array.from({ length: meta.chunkCount }, (_, index) => idbChunkKey(meta.generation, index)), "snapshot-chunk");
74
+ if (!chunks) throw new MatrixIdbSnapshotInvalidError("snapshot chunks are missing or malformed");
75
+ const snapshotJson = chunks.join("");
76
+ if (meta.digest !== digestText(snapshotJson)) throw new MatrixIdbSnapshotInvalidError("checksum mismatch");
77
+ return snapshotJson;
78
+ }
79
+ async function readMatrixIdbSnapshotOwnerGeneration(storageRootDir, stateRuntime = getMatrixRuntime().state) {
80
+ const meta = await stateRuntime.openKeyedStoreV2(openMatrixIdbSnapshotStoreOptions(storageRootDir)).lookup(idbMetaKey());
81
+ if (meta === void 0) return;
82
+ if (!isIdbSnapshotMeta(meta)) throw new MatrixIdbSnapshotInvalidError("metadata is malformed");
83
+ return meta.cleanOwnerGeneration;
84
+ }
85
+ /** Publish last, after the final snapshot and clean sync cursor have settled. */
86
+ async function sealMatrixIdbSnapshotOwnerGeneration(storageRootDir, generation, stateRuntime = getMatrixRuntime().state) {
87
+ const store = stateRuntime.openKeyedStoreV2(openMatrixIdbSnapshotStoreOptions(storageRootDir));
88
+ const meta = await store.lookup(idbMetaKey());
89
+ if (!isIdbSnapshotMeta(meta)) throw new MatrixIdbSnapshotInvalidError("final metadata is missing or malformed");
90
+ await store.register(idbMetaKey(), {
91
+ ...meta,
92
+ cleanOwnerGeneration: generation
93
+ });
94
+ }
95
+ async function hasMatrixIdbSnapshotState(storageRootDir) {
96
+ return isIdbSnapshotMeta(await getMatrixRuntime().state.openKeyedStoreV2(openMatrixIdbSnapshotStoreOptions(storageRootDir)).lookup(idbMetaKey()));
97
+ }
98
+ async function writeMatrixIdbSnapshotJson(params) {
99
+ const store = (params.stateRuntime ?? getMatrixRuntime().state).openKeyedStoreV2(openMatrixIdbSnapshotStoreOptions(params.storageRootDir));
100
+ const rows = buildIdbSnapshotRows(params.snapshotJson, params.databaseCount);
101
+ await writeMatrixStateChunks(store, rows, idbChunkKeyPrefix());
102
+ }
103
+ async function scoreMatrixCryptoStateInStore(storageRootDir) {
104
+ if (!matrixCryptoStateDatabaseExists(storageRootDir)) return 0;
105
+ let score = 0;
106
+ try {
107
+ const migration = await getMatrixRuntime().state.openKeyedStoreV2(openMatrixLegacyCryptoMigrationStoreOptions(storageRootDir)).lookup(STATE_KEY);
108
+ if (isRecord(migration) && migration.version === 1 && typeof migration.accountId === "string" && (migration.restoreStatus === "pending" || migration.restoreStatus === "completed" || migration.restoreStatus === "manual-action-required")) score += 3;
109
+ } catch {}
110
+ try {
111
+ if (await readMatrixRecoveryKeyStateForPathAsync(path.join(storageRootDir, "recovery-key.json"), getMatrixRuntime().state)) score += 2;
112
+ } catch {}
113
+ try {
114
+ if (await hasMatrixIdbSnapshotState(storageRootDir)) score += 2;
115
+ } catch {}
116
+ return score;
117
+ }
118
+ function matrixCryptoStateDatabaseExists(storageRootDir) {
119
+ return fs.existsSync(path.join(storageRootDir, "state", "openclaw.sqlite"));
120
+ }
121
+ function resolveRecoveryKeyStateKeyForPath(recoveryKeyPath) {
122
+ const basename = path.basename(recoveryKeyPath);
123
+ if (basename === "recovery-key.json") return STATE_KEY;
124
+ return `file:${createHash("sha256").update(basename, "utf8").digest("hex").slice(0, 32)}`;
125
+ }
126
+ function normalizeMatrixStoredRecoveryKey(value) {
127
+ if (!isRecord(value) || value.version !== 1 || typeof value.createdAt !== "string" || typeof value.privateKeyBase64 !== "string" || !value.privateKeyBase64.trim()) return null;
128
+ return {
129
+ version: 1,
130
+ createdAt: value.createdAt,
131
+ keyId: typeof value.keyId === "string" ? value.keyId : null,
132
+ ...typeof value.encodedPrivateKey === "string" ? { encodedPrivateKey: value.encodedPrivateKey } : {},
133
+ privateKeyBase64: value.privateKeyBase64,
134
+ ...isRecord(value.keyInfo) ? { keyInfo: {
135
+ ...value.keyInfo.passphrase !== void 0 ? { passphrase: value.keyInfo.passphrase } : {},
136
+ ...typeof value.keyInfo.name === "string" ? { name: value.keyInfo.name } : {}
137
+ } } : {}
138
+ };
139
+ }
140
+ function buildIdbSnapshotRows(snapshotJson, databaseCount) {
141
+ const generation = randomUUID().replaceAll("-", "");
142
+ const chunks = chunkMatrixStateJson(snapshotJson, IDB_SNAPSHOT_CHUNK_BYTES, IDB_SNAPSHOT_MAX_CHUNKS, "Matrix IndexedDB snapshot exceeds SQLite chunk limit").map((data, index) => ({
143
+ key: idbChunkKey(generation, index),
144
+ value: {
145
+ kind: "snapshot-chunk",
146
+ index,
147
+ data
148
+ }
149
+ }));
150
+ return {
151
+ chunks,
152
+ meta: {
153
+ key: idbMetaKey(),
154
+ value: {
155
+ kind: "meta",
156
+ version: 1,
157
+ generation,
158
+ chunkCount: chunks.length,
159
+ digest: digestText(snapshotJson),
160
+ databaseCount,
161
+ persistedAt: (/* @__PURE__ */ new Date()).toISOString()
162
+ }
163
+ }
164
+ };
165
+ }
166
+ function idbMetaKey() {
167
+ return `${STATE_KEY}:meta`;
168
+ }
169
+ function idbChunkKeyPrefix() {
170
+ return `${STATE_KEY}:snapshot:`;
171
+ }
172
+ function idbChunkKey(generation, index) {
173
+ return `${idbChunkKeyPrefix()}${generation}:${index}`;
174
+ }
175
+ function digestText(value) {
176
+ return createHash("sha256").update(value, "utf8").digest("hex");
177
+ }
178
+ function isIdbSnapshotMeta(value) {
179
+ return isRecord(value) && value.kind === "meta" && value.version === 1 && typeof value.generation === "string" && value.generation.trim() !== "" && asSafeIntegerInRange(value.chunkCount, {
180
+ min: 0,
181
+ max: IDB_SNAPSHOT_MAX_CHUNKS
182
+ }) !== void 0 && typeof value.digest === "string" && asSafeIntegerInRange(value.databaseCount, { min: 0 }) !== void 0 && typeof value.persistedAt === "string" && (value.cleanOwnerGeneration === void 0 || typeof value.cleanOwnerGeneration === "string" && /^[a-f0-9]{32}$/.test(value.cleanOwnerGeneration));
183
+ }
184
+ //#endregion
185
+ export { readMatrixRecoveryKeyStateForPathAsync as a, writeMatrixIdbSnapshotJson as c, readMatrixIdbSnapshotOwnerGeneration as i, writeMatrixRecoveryKeyStateForPathAsync as l, MATRIX_RECOVERY_KEY_FILENAME as n, scoreMatrixCryptoStateInStore as o, readMatrixIdbSnapshotJson as r, sealMatrixIdbSnapshotOwnerGeneration as s, MATRIX_IDB_SNAPSHOT_FILENAME as t };
@@ -0,0 +1,174 @@
1
+ import { t as getMatrixRuntime } from "./runtime-1kn1P6io.mjs";
2
+ import { i as readMatrixIdbSnapshotOwnerGeneration, s as sealMatrixIdbSnapshotOwnerGeneration } from "./crypto-state-store-D4wrCvFs.mjs";
3
+ import { randomUUID } from "node:crypto";
4
+ import path from "node:path";
5
+ import { constants } from "node:fs";
6
+ import fs$1 from "node:fs/promises";
7
+ import { FILE_LOCK_STALE_ERROR_CODE, FILE_LOCK_TIMEOUT_ERROR_CODE, acquireFileLock } from "openclaw/plugin-sdk/file-lock";
8
+ import { syncDirectory } from "@openclaw/fs-safe/durability";
9
+ //#region extensions/matrix/src/matrix/sdk/crypto-store-ownership.ts
10
+ const MATRIX_CRYPTO_STORE_OWNER_ACTIVE_ERROR_CODE = "matrix_crypto_store_owner_active";
11
+ const GUARD_BYTES = 33;
12
+ var MatrixCryptoStoreOwnerActiveError = class extends Error {
13
+ constructor(cause) {
14
+ super("Timed out waiting for exclusive Matrix crypto state ownership", { cause });
15
+ this.code = MATRIX_CRYPTO_STORE_OWNER_ACTIVE_ERROR_CODE;
16
+ this.name = "MatrixCryptoStoreOwnerActiveError";
17
+ }
18
+ };
19
+ const LOCK_OPTIONS = {
20
+ retries: {
21
+ retries: 0,
22
+ factor: 1,
23
+ minTimeout: 0,
24
+ maxTimeout: 0
25
+ },
26
+ stale: 0,
27
+ staleRecovery: "remove-if-definitely-stale"
28
+ };
29
+ function isContention(error) {
30
+ return error !== null && typeof error === "object" && "code" in error && (error.code === FILE_LOCK_TIMEOUT_ERROR_CODE || error.code === FILE_LOCK_STALE_ERROR_CODE);
31
+ }
32
+ function filesystemErrorCode(error) {
33
+ return error !== null && typeof error === "object" && "code" in error ? error.code : void 0;
34
+ }
35
+ function poisonPath(snapshotPath) {
36
+ return `${snapshotPath}.owner.poisoned`;
37
+ }
38
+ /** Doctor-only lock: inspect and recover refusal state without entering crypto. */
39
+ async function withMatrixCryptoStoreRecoveryLock(snapshotPath, inspect) {
40
+ const lock = await acquireFileLock(`${snapshotPath}.owner`, LOCK_OPTIONS);
41
+ try {
42
+ return await inspect(poisonPath(snapshotPath));
43
+ } finally {
44
+ await lock.release();
45
+ }
46
+ }
47
+ async function syncParentDirectory(filePath) {
48
+ try {
49
+ await syncDirectory(path.dirname(filePath));
50
+ } catch (error) {
51
+ const code = filesystemErrorCode(error);
52
+ if (process.platform !== "win32" || ![
53
+ "EINVAL",
54
+ "ENOTSUP",
55
+ "ENOSYS",
56
+ "EISDIR",
57
+ "EPERM",
58
+ "EACCES"
59
+ ].includes(String(code))) throw error;
60
+ }
61
+ }
62
+ /** Null is a legacy/fresh store without a guard; empty means an invalid or old refusal marker. */
63
+ async function readOwnerGuard(snapshotPath) {
64
+ const marker = poisonPath(snapshotPath);
65
+ let stat;
66
+ try {
67
+ stat = await fs$1.lstat(marker);
68
+ } catch (error) {
69
+ if (filesystemErrorCode(error) === "ENOENT") return null;
70
+ throw error;
71
+ }
72
+ if (!stat.isFile() || stat.isSymbolicLink()) throw new Error("Matrix crypto owner guard must be a regular file");
73
+ if (stat.size !== GUARD_BYTES) return "";
74
+ const file = await fs$1.open(marker, constants.O_RDONLY | (constants.O_NOFOLLOW ?? 0));
75
+ try {
76
+ const bytes = Buffer.alloc(GUARD_BYTES);
77
+ const { bytesRead } = await file.read(bytes, 0, bytes.length, 0);
78
+ const value = bytes.toString("utf8");
79
+ return bytesRead === GUARD_BYTES && /^[a-f0-9]{32}\n$/.test(value) ? value.trimEnd() : "";
80
+ } finally {
81
+ await file.close();
82
+ }
83
+ }
84
+ /** Flush the guard before Rust mutates state; retain its inode across clean generations. */
85
+ async function writeOwnerGuard(snapshotPath, generation, create, onChanged = () => {}) {
86
+ const marker = poisonPath(snapshotPath);
87
+ const flags = constants.O_RDWR | (constants.O_NOFOLLOW ?? 0) | (create ? constants.O_CREAT | constants.O_EXCL : 0);
88
+ const file = await fs$1.open(marker, flags, 384);
89
+ try {
90
+ if (!(await file.stat()).isFile()) throw new Error("Matrix crypto owner guard must be a regular file");
91
+ onChanged();
92
+ await file.writeFile(`${generation}\n`, "ascii");
93
+ await file.truncate(GUARD_BYTES);
94
+ await file.sync();
95
+ } finally {
96
+ await file.close();
97
+ }
98
+ if (create) await syncParentDirectory(marker);
99
+ }
100
+ /** The caller holds custody. Snapshot checksum and schema validation remain the restore owner's job. */
101
+ async function isMatrixCryptoStoreUnsafe(snapshotPath, stateRuntime = getMatrixRuntime().state) {
102
+ const guard = await readOwnerGuard(snapshotPath);
103
+ if (guard === "") return true;
104
+ const cleanGeneration = await readMatrixIdbSnapshotOwnerGeneration(path.dirname(snapshotPath), stateRuntime);
105
+ return guard === null ? cleanGeneration !== void 0 : guard !== cleanGeneration;
106
+ }
107
+ /** Doctor has already validated the snapshot and obtained explicit rollback consent under custody. */
108
+ async function sealMatrixCryptoStoreRecovery(snapshotPath, stateRuntime = getMatrixRuntime().state) {
109
+ const guard = await readOwnerGuard(snapshotPath);
110
+ const generation = randomUUID().replaceAll("-", "");
111
+ await writeOwnerGuard(snapshotPath, generation, guard === null);
112
+ await sealMatrixIdbSnapshotOwnerGeneration(path.dirname(snapshotPath), generation, stateRuntime);
113
+ }
114
+ async function acquireMatrixCryptoStoreOwnership(snapshotPath, options = {}) {
115
+ const stateRuntime = options.stateRuntime ?? getMatrixRuntime().state;
116
+ let lock;
117
+ options.signal?.throwIfAborted();
118
+ try {
119
+ lock = await acquireFileLock(`${snapshotPath}.owner`, {
120
+ ...LOCK_OPTIONS,
121
+ retries: {
122
+ retries: 25,
123
+ factor: 1,
124
+ minTimeout: 200,
125
+ maxTimeout: 200
126
+ }
127
+ });
128
+ } catch (error) {
129
+ if (isContention(error)) throw new MatrixCryptoStoreOwnerActiveError(error);
130
+ throw error;
131
+ }
132
+ let previousGuard;
133
+ try {
134
+ options.signal?.throwIfAborted();
135
+ if (await isMatrixCryptoStoreUnsafe(snapshotPath, stateRuntime)) throw new Error("Matrix crypto state has an unresolved unsafe final state (discarded, failed, or lost save); refusing another owner. Preserve the account state and run \"openclaw matrix doctor inspect\". Recovery guidance: https://docs.openclaw.ai/channels/matrix/encryption");
136
+ previousGuard = await readOwnerGuard(snapshotPath);
137
+ } catch (error) {
138
+ await lock.release();
139
+ throw error;
140
+ }
141
+ const generation = randomUUID().replaceAll("-", "");
142
+ let guardChanged = false;
143
+ let armPromise;
144
+ return {
145
+ armUnsafeState: async () => {
146
+ armPromise ??= writeOwnerGuard(snapshotPath, generation, previousGuard === null, () => {
147
+ guardChanged = true;
148
+ });
149
+ await armPromise;
150
+ },
151
+ cancelUnsafeState: async () => {
152
+ if (!guardChanged) return;
153
+ if (previousGuard === null) {
154
+ await fs$1.unlink(poisonPath(snapshotPath));
155
+ await syncParentDirectory(poisonPath(snapshotPath));
156
+ } else await writeOwnerGuard(snapshotPath, previousGuard, false);
157
+ guardChanged = false;
158
+ armPromise = void 0;
159
+ },
160
+ sealSafeState: async () => {
161
+ if (!guardChanged) return;
162
+ await armPromise;
163
+ try {
164
+ await sealMatrixIdbSnapshotOwnerGeneration(path.dirname(snapshotPath), generation, stateRuntime);
165
+ } catch (error) {
166
+ if (await readMatrixIdbSnapshotOwnerGeneration(path.dirname(snapshotPath), stateRuntime).catch(() => void 0) !== generation) throw error;
167
+ }
168
+ guardChanged = false;
169
+ },
170
+ release: () => lock.release()
171
+ };
172
+ }
173
+ //#endregion
174
+ export { withMatrixCryptoStoreRecoveryLock as i, isMatrixCryptoStoreUnsafe as n, sealMatrixCryptoStoreRecovery as r, acquireMatrixCryptoStoreOwnership as t };
@@ -0,0 +1,54 @@
1
+ import { i as __exportAll } from "./doctor-contract-CsTNmbMa.mjs";
2
+ import { t as getMatrixRuntime } from "./runtime-1kn1P6io.mjs";
3
+ import { r as readMatrixIdbSnapshotJson, t as MATRIX_IDB_SNAPSHOT_FILENAME } from "./crypto-state-store-D4wrCvFs.mjs";
4
+ import { t as walkMatrixStateFiles } from "./state-layout-walk-BQMgMykU.mjs";
5
+ import { i as withMatrixCryptoStoreRecoveryLock, n as isMatrixCryptoStoreUnsafe, r as sealMatrixCryptoStoreRecovery } from "./crypto-store-ownership-Z_Y5WRKr.mjs";
6
+ import path from "node:path";
7
+ import fs from "node:fs/promises";
8
+ import { FILE_LOCK_TIMEOUT_ERROR_CODE } from "openclaw/plugin-sdk/file-lock";
9
+ //#region extensions/matrix/src/matrix/crypto-unsafe-state-doctor.ts
10
+ var crypto_unsafe_state_doctor_exports = /* @__PURE__ */ __exportAll({
11
+ listMatrixCryptoUnsafeState: () => listMatrixCryptoUnsafeState,
12
+ recoverMatrixCryptoUnsafeState: () => recoverMatrixCryptoUnsafeState
13
+ });
14
+ const MARKER_NAME = `${MATRIX_IDB_SNAPSHOT_FILENAME}.owner.poisoned`;
15
+ async function listMatrixCryptoUnsafeState(stateDir, stateRuntime) {
16
+ const { entries, failedDirs } = await walkMatrixStateFiles(stateDir, (name, depth) => (depth === 0 || depth === 4) && name === MARKER_NAME || depth === 5 && name === "openclaw.sqlite", [0, 4]);
17
+ if (failedDirs.length > 0) throw failedDirs[0].error;
18
+ const roots = new Set(entries.map((entry) => path.basename(entry.path) === MARKER_NAME ? path.dirname(entry.path) : path.dirname(path.dirname(entry.path))));
19
+ const abandoned = [];
20
+ for (const root of roots) {
21
+ const snapshotPath = path.join(root, MATRIX_IDB_SNAPSHOT_FILENAME);
22
+ try {
23
+ if (await withMatrixCryptoStoreRecoveryLock(snapshotPath, () => isMatrixCryptoStoreUnsafe(snapshotPath, stateRuntime ?? getMatrixRuntime().state))) abandoned.push(root);
24
+ } catch (error) {
25
+ if (error !== null && typeof error === "object" && "code" in error && error.code === FILE_LOCK_TIMEOUT_ERROR_CODE) continue;
26
+ throw error;
27
+ }
28
+ }
29
+ return abandoned.toSorted();
30
+ }
31
+ /** A valid snapshot is a rollback point, not proof that the failed owner's last keys were saved. */
32
+ async function recoverMatrixCryptoUnsafeState(params) {
33
+ if (!params.acceptSnapshotRollback) throw new Error("Matrix crypto recovery requires explicit --accept-snapshot-rollback.");
34
+ const snapshotPath = path.join(params.storageRootDir, MATRIX_IDB_SNAPSHOT_FILENAME);
35
+ await withMatrixCryptoStoreRecoveryLock(snapshotPath, async () => {
36
+ try {
37
+ await fs.access(path.join(params.storageRootDir, "state", "openclaw.sqlite"));
38
+ } catch (error) {
39
+ if (error !== null && typeof error === "object" && "code" in error && error.code === "ENOENT") throw new Error("Matrix crypto SQLite snapshot is absent; refusal remains in place.", { cause: error });
40
+ throw error;
41
+ }
42
+ const snapshot = await readMatrixIdbSnapshotJson(params.storageRootDir, getMatrixRuntime().state);
43
+ if (!snapshot) throw new Error("Matrix crypto SQLite snapshot is absent or invalid; refusal remains in place.");
44
+ const { validateMatrixIdbSnapshotJson } = await import("./idb-persistence-BHTYPRe_.mjs");
45
+ try {
46
+ await validateMatrixIdbSnapshotJson(snapshot);
47
+ } catch (error) {
48
+ throw new Error("Matrix crypto SQLite snapshot cannot be replayed; refusal remains in place.", { cause: error });
49
+ }
50
+ await sealMatrixCryptoStoreRecovery(snapshotPath, getMatrixRuntime().state);
51
+ });
52
+ }
53
+ //#endregion
54
+ export { listMatrixCryptoUnsafeState as n, recoverMatrixCryptoUnsafeState as r, crypto_unsafe_state_doctor_exports as t };
@@ -1,6 +1,6 @@
1
1
  import { i as __exportAll } from "./doctor-contract-CsTNmbMa.mjs";
2
2
  import { i as normalizeMatrixMessagingTarget, n as isMatrixQualifiedUserId } from "./target-ids-HhcaKX1n.mjs";
3
- import { u as resolveMatrixAuth } from "./client-vPPbaxNp.mjs";
3
+ import { u as resolveMatrixAuth } from "./client-C4Gibhzl.mjs";
4
4
  import { t as MatrixAuthedHttpClient } from "./http-client-ByR4STVQ.mjs";
5
5
  import { isRecord, normalizeLowercaseStringOrEmpty, normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
6
6
  //#region extensions/matrix/src/directory-live.ts
@@ -1,5 +1,5 @@
1
1
  import { _ as MsgType } from "./direct-management-B3wYhx_M.mjs";
2
- import { a as sendSingleTextMessageMatrix, f as prepareMatrixSingleText, t as editMessageMatrix } from "./send-LCOuTVc1.mjs";
2
+ import { a as sendSingleTextMessageMatrix, f as prepareMatrixSingleText, t as editMessageMatrix } from "./send-BprM-Wmx.mjs";
3
3
  import { createFinalizableDraftLifecycle } from "openclaw/plugin-sdk/channel-outbound";
4
4
  //#region extensions/matrix/src/matrix/draft-stream.ts
5
5
  const DEFAULT_THROTTLE_MS = 1e3;
@@ -1,9 +1,9 @@
1
1
  import { a as resolveMatrixAccountConfig } from "./account-config-CRsKoMqJ.mjs";
2
- import { _ as resolveMatrixAccount, g as resolveDefaultMatrixAccountId } from "./setup-core-CKnNTfgD.mjs";
3
- import { i as normalizeMatrixUserId } from "./channel.setup-CwuYD_CT.mjs";
4
- import { doesApprovalRequestSelectChannelAccount } from "openclaw/plugin-sdk/approval-native-runtime";
2
+ import { g as resolveDefaultMatrixAccountId, v as resolveMatrixAccountAsync } from "./setup-core-DcCk1_Tv.mjs";
3
+ import { i as normalizeMatrixUserId } from "./channel.setup-Be8TYKMA.mjs";
4
+ import { doesApprovalRequestSelectChannelAccountAsync } from "openclaw/plugin-sdk/approval-native-runtime";
5
5
  import { createChannelApprovalAuth, resolveApprovalApprovers } from "openclaw/plugin-sdk/approval-auth-runtime";
6
- import { createChannelExecApprovalProfile, getExecApprovalReplyMetadata, isChannelExecApprovalClientEnabledFromConfig, isChannelExecApprovalTargetRecipient, matchesApprovalRequestFilters } from "openclaw/plugin-sdk/approval-client-runtime";
6
+ import { createChannelExecApprovalProfileAsync, getExecApprovalReplyMetadata, isChannelExecApprovalClientEnabledFromConfig, isChannelExecApprovalTargetRecipient, matchesApprovalRequestFilters } from "openclaw/plugin-sdk/approval-client-runtime";
7
7
  //#region extensions/matrix/src/approval-ids.ts
8
8
  function normalizeMatrixApproverId(value) {
9
9
  return normalizeMatrixUserId(String(value)) || void 0;
@@ -29,18 +29,10 @@ function normalizeMatrixExecApproverId(value) {
29
29
  return normalized === "*" ? void 0 : normalized;
30
30
  }
31
31
  function resolveMatrixExecApprovalConfig(params) {
32
- const account = resolveMatrixAccount(params);
33
- const config = account.config.execApprovals;
34
- if (!config) return;
35
- return {
36
- ...config,
37
- enabled: account.enabled && account.configured ? config.enabled : false
38
- };
39
- }
40
- function isMatrixExecApprovalAccountEligible(params) {
41
- const account = resolveMatrixAccount(params);
42
- if (!account.enabled || !account.configured) return false;
43
- return matchesMatrixApprovalConfig(params);
32
+ return resolveMatrixAccountConfig({
33
+ cfg: params.cfg,
34
+ accountId: params.accountId ?? resolveDefaultMatrixAccountId(params.cfg)
35
+ }).execApprovals;
44
36
  }
45
37
  function matchesMatrixApprovalConfig(params) {
46
38
  const config = resolveMatrixExecApprovalConfig(params);
@@ -53,16 +45,17 @@ function matchesMatrixApprovalConfig(params) {
53
45
  sessionFilter: config?.sessionFilter
54
46
  });
55
47
  }
56
- function matchesMatrixRequestAccount(params) {
48
+ async function matchesMatrixRequestAccount(params) {
57
49
  const accountId = params.accountId ?? resolveDefaultMatrixAccountId(params.cfg);
58
- return doesApprovalRequestSelectChannelAccount({
50
+ const account = await resolveMatrixAccountAsync({
51
+ ...params,
52
+ accountId
53
+ });
54
+ return doesApprovalRequestSelectChannelAccountAsync({
59
55
  ...params,
60
56
  channel: "matrix",
61
57
  defaultAccountId: resolveDefaultMatrixAccountId(params.cfg),
62
- eligibleAccountIds: isMatrixExecApprovalAccountEligible({
63
- ...params,
64
- accountId
65
- }) ? [accountId] : []
58
+ eligibleAccountIds: account.enabled && account.configured && matchesMatrixApprovalConfig(params) ? [accountId] : []
66
59
  });
67
60
  }
68
61
  function getMatrixExecApprovalApprovers(params) {
@@ -91,39 +84,36 @@ function isMatrixExecApprovalTargetRecipient(params) {
91
84
  matchTarget: ({ target, normalizedSenderId }) => normalizeMatrixApproverId(target.to) === normalizedSenderId
92
85
  });
93
86
  }
94
- const matrixExecApprovalProfile = createChannelExecApprovalProfile({
87
+ const matrixExecApprovalProfile = createChannelExecApprovalProfileAsync({
95
88
  resolveConfig: resolveMatrixExecApprovalConfig,
96
89
  resolveApprovers: getMatrixExecApprovalApprovers,
97
90
  normalizeSenderId: normalizeMatrixApproverId,
98
- isTargetRecipient: isMatrixExecApprovalTargetRecipient,
99
- matchesRequestAccount: (params) => matchesMatrixRequestAccount({
100
- ...params,
101
- approvalKind: "exec"
102
- })
91
+ isTargetRecipient: isMatrixExecApprovalTargetRecipient
103
92
  });
104
- const isMatrixExecApprovalClientEnabled = matrixExecApprovalProfile.isClientEnabled;
105
93
  const isMatrixExecApprovalAuthorizedSender = matrixExecApprovalProfile.isAuthorizedSender;
106
94
  const resolveMatrixExecApprovalTarget = matrixExecApprovalProfile.resolveTarget;
107
- function isMatrixApprovalClientEnabled(params) {
108
- if (params.approvalKind === "exec" || params.approvalKind === "system-agent") return isMatrixExecApprovalClientEnabled(params);
109
- const config = resolveMatrixExecApprovalConfig(params);
95
+ async function isMatrixApprovalClientEnabled(params) {
96
+ const account = await resolveMatrixAccountAsync(params);
97
+ if (!account.enabled || !account.configured) return false;
98
+ const config = account.config.execApprovals;
110
99
  return isChannelExecApprovalClientEnabledFromConfig({
111
100
  enabled: config?.enabled,
112
101
  approverCount: getMatrixApprovalApprovers(params).length
113
102
  });
114
103
  }
115
- function isMatrixAnyApprovalClientEnabled(params) {
116
- return isMatrixApprovalClientEnabled({
117
- ...params,
118
- approvalKind: "exec"
119
- }) || isMatrixApprovalClientEnabled({
120
- ...params,
121
- approvalKind: "plugin"
104
+ async function isMatrixAnyApprovalClientEnabled(params) {
105
+ const account = await resolveMatrixAccountAsync(params);
106
+ return account.enabled && account.configured && isChannelExecApprovalClientEnabledFromConfig({
107
+ enabled: account.config.execApprovals?.enabled,
108
+ approverCount: getMatrixExecApprovalApprovers(params).length + getMatrixApprovalApprovers({
109
+ ...params,
110
+ approvalKind: "plugin"
111
+ }).length
122
112
  });
123
113
  }
124
- function shouldHandleMatrixApprovalRequest(params) {
114
+ async function shouldHandleMatrixApprovalRequest(params) {
125
115
  if (params.approvalKind !== "exec" && params.approvalKind !== "plugin" && params.approvalKind !== "system-agent") return false;
126
- if (!matchesMatrixRequestAccount(params)) return false;
116
+ if (!await matchesMatrixRequestAccount(params)) return false;
127
117
  return matchesMatrixApprovalConfig(params);
128
118
  }
129
119
  function buildFilterCheckRequest(params) {
@@ -151,7 +141,7 @@ function buildFilterCheckRequest(params) {
151
141
  expiresAtMs: 0
152
142
  };
153
143
  }
154
- function shouldSuppressLocalMatrixExecApprovalPrompt(params) {
144
+ async function shouldSuppressLocalMatrixExecApprovalPrompt(params) {
155
145
  if (!matrixExecApprovalProfile.shouldSuppressLocalPrompt(params)) return false;
156
146
  const metadata = getExecApprovalReplyMetadata(params.payload);
157
147
  if (!metadata) return false;
@@ -164,4 +154,4 @@ function shouldSuppressLocalMatrixExecApprovalPrompt(params) {
164
154
  });
165
155
  }
166
156
  //#endregion
167
- export { isMatrixExecApprovalAuthorizedSender as a, shouldHandleMatrixApprovalRequest as c, matrixApprovalAuth as d, normalizeMatrixApproverId as f, isMatrixApprovalClientEnabled as i, shouldSuppressLocalMatrixExecApprovalPrompt as l, getMatrixExecApprovalApprovers as n, isMatrixExecApprovalClientEnabled as o, isMatrixAnyApprovalClientEnabled as r, resolveMatrixExecApprovalTarget as s, getMatrixApprovalApprovers as t, getMatrixApprovalAuthApprovers as u };
157
+ export { isMatrixExecApprovalAuthorizedSender as a, shouldSuppressLocalMatrixExecApprovalPrompt as c, normalizeMatrixApproverId as d, isMatrixApprovalClientEnabled as i, getMatrixApprovalAuthApprovers as l, getMatrixExecApprovalApprovers as n, resolveMatrixExecApprovalTarget as o, isMatrixAnyApprovalClientEnabled as r, shouldHandleMatrixApprovalRequest as s, getMatrixApprovalApprovers as t, matrixApprovalAuth as u };
@@ -1,6 +1,6 @@
1
1
  import { t as getMatrixRuntime } from "./runtime-1kn1P6io.mjs";
2
- import { t as claimCurrentTokenStorageState } from "./storage-DkC6bHgA.mjs";
3
- import { a as readPersistedStoreFromStore, r as openMatrixSyncCacheStoreOptions, s as writeMatrixSyncCacheStateToStore, t as deleteMatrixSyncCacheStateFromStore } from "./sync-cache-state-D4G-fi3t.mjs";
2
+ import { t as claimCurrentTokenStorageState } from "./storage-l8V0XsGM.mjs";
3
+ import { a as readPersistedStoreFromStore, r as openMatrixSyncCacheStoreOptions, s as writeMatrixSyncCacheStateToStore, t as deleteMatrixSyncCacheStateFromStore } from "./sync-cache-state-Cnm4TCEI.mjs";
4
4
  import { t as LogService } from "./logger-CXQnpXCt.mjs";
5
5
  import { MemoryStore, SyncAccumulator } from "matrix-js-sdk/lib/matrix.js";
6
6
  import { createAsyncLock } from "openclaw/plugin-sdk/async-lock-runtime";
@@ -19,7 +19,7 @@ var SqliteBackedMatrixSyncStore = class SqliteBackedMatrixSyncStore extends Memo
19
19
  let persisted = null;
20
20
  let unavailableError;
21
21
  try {
22
- store = getMatrixRuntime().state.openKeyedStore(openMatrixSyncCacheStoreOptions(storageRootDir));
22
+ store = getMatrixRuntime().state.openKeyedStoreV2(openMatrixSyncCacheStoreOptions(storageRootDir));
23
23
  persisted = await readPersistedStoreFromStore({
24
24
  storageRootDir,
25
25
  store