@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
@@ -1,16 +1,16 @@
1
1
  import { a as resolveMatrixAccountConfig } from "./account-config-CRsKoMqJ.mjs";
2
- import { a as resolveMatrixThreadRouting, i as resolveMatrixInboundRoute } from "./channel-BcwGspPw.mjs";
2
+ import { a as resolveMatrixThreadRouting, i as resolveMatrixInboundRouteAsync } from "./channel-Dw4_imdd.mjs";
3
3
  import { c as extractMatrixReactionAnnotation } from "./send-currentness-C2rMVVIQ.mjs";
4
4
  import { p as resolveMatrixThreadRootId } from "./direct-management-B3wYhx_M.mjs";
5
- import { i as resolveMatrixApprovalReactionTargetWithPersistence, o as unregisterMatrixApprovalReactionTargetsForApproval } from "./approval-reactions-DhB6gNPU.mjs";
5
+ import { i as resolveMatrixApprovalReactionTargetWithPersistence, o as unregisterMatrixApprovalReactionTargetsForApproval } from "./approval-reactions-D2pEUrFS.mjs";
6
6
  import { createLazyRuntimeModule } from "openclaw/plugin-sdk/lazy-runtime";
7
7
  import { isApprovalNotFoundError } from "openclaw/plugin-sdk/error-runtime";
8
8
  import { normalizeAccountId } from "openclaw/plugin-sdk/routing";
9
9
  import { getSessionBindingService } from "openclaw/plugin-sdk/session-binding-runtime";
10
10
  //#region extensions/matrix/src/matrix/monitor/reaction-events.ts
11
- const loadApprovalReactionAuth = createLazyRuntimeModule(() => import("./channel-BcwGspPw.mjs").then((n) => n.s));
11
+ const loadApprovalReactionAuth = createLazyRuntimeModule(() => import("./channel-Dw4_imdd.mjs").then((n) => n.s));
12
12
  const loadExecApprovalResolver = createLazyRuntimeModule(() => import("openclaw/plugin-sdk/approval-gateway-runtime"));
13
- const loadMatrixSend = createLazyRuntimeModule(() => import("./send-LCOuTVc1.mjs").then((n) => n.s));
13
+ const loadMatrixSend = createLazyRuntimeModule(() => import("./send-BprM-Wmx.mjs").then((n) => n.s));
14
14
  function buildMatrixApprovalTerminalText(result) {
15
15
  const approval = result.approval;
16
16
  const terminalLabel = approval.status === "allowed" ? approval.decision === "allow-always" ? "Allowed always" : "Allowed once" : approval.status === "denied" ? "Denied" : approval.status === "expired" ? "Expired" : "Cancelled";
@@ -142,7 +142,7 @@ async function handleInboundMatrixReaction(params) {
142
142
  messageId: reaction.eventId,
143
143
  threadRootId
144
144
  });
145
- const { route, runtimeBindingId } = resolveMatrixInboundRoute({
145
+ const { route, runtimeBindingId } = await resolveMatrixInboundRouteAsync({
146
146
  cfg: params.cfg,
147
147
  accountId: params.accountId,
148
148
  roomId: params.roomId,
@@ -152,7 +152,7 @@ async function handleInboundMatrixReaction(params) {
152
152
  threadId: thread.threadId,
153
153
  resolveAgentRoute: params.core.channel.routing.resolveAgentRoute
154
154
  });
155
- if (runtimeBindingId) getSessionBindingService().touch(runtimeBindingId, params.event.origin_server_ts, {
155
+ if (runtimeBindingId) await getSessionBindingService().touchAsync(runtimeBindingId, params.event.origin_server_ts, {
156
156
  channel: "matrix",
157
157
  accountId: params.accountId
158
158
  });
@@ -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 { n as listMatrixDirectoryGroupsLive, r as listMatrixDirectoryPeersLive } from "./directory-live-B1WbfSHo.mjs";
3
+ import { n as listMatrixDirectoryGroupsLive, r as listMatrixDirectoryPeersLive } from "./directory-live-BpSz-FQB.mjs";
4
4
  import { normalizeOptionalLowercaseString } from "openclaw/plugin-sdk/string-coerce-runtime";
5
5
  //#region extensions/matrix/src/resolve-targets.ts
6
6
  var resolve_targets_exports = /* @__PURE__ */ __exportAll({ resolveMatrixTargets: () => resolveMatrixTargets });
@@ -11,19 +11,20 @@ function chunkMatrixStateJson(value, maxBytes, maxChunks, limitMessage) {
11
11
  if (chunks.length >= maxChunks) throw new Error(limitMessage);
12
12
  chunks.push(chunk);
13
13
  };
14
- let current = "";
14
+ let chunkStart = 0;
15
15
  let currentBytes = 0;
16
- for (const char of value) {
17
- const charBytes = Buffer.byteLength(char, "utf8");
18
- if (current && currentBytes + charBytes > maxBytes) {
19
- pushChunk(current);
20
- current = "";
16
+ for (let index = 0; index < value.length;) {
17
+ const codePoint = value.codePointAt(index);
18
+ const charBytes = codePoint <= 127 ? 1 : codePoint <= 2047 ? 2 : codePoint <= 65535 ? 3 : 4;
19
+ if (index > chunkStart && currentBytes + charBytes > maxBytes) {
20
+ pushChunk(value.slice(chunkStart, index));
21
+ chunkStart = index;
21
22
  currentBytes = 0;
22
23
  }
23
- current += char;
24
24
  currentBytes += charBytes;
25
+ index += codePoint > 65535 ? 2 : 1;
25
26
  }
26
- if (current) pushChunk(current);
27
+ if (chunkStart < value.length) pushChunk(value.slice(chunkStart));
27
28
  return chunks;
28
29
  }
29
30
  async function readMatrixStateChunks(store, keys, kind) {
@@ -61,8 +62,7 @@ function resolveMatrixSqliteStateEnv(options) {
61
62
  OPENCLAW_STATE_DIR: stateDir
62
63
  };
63
64
  }
64
- async function updateMatrixKeyedState(store, key, update, legacyUpdate, onUndefined = "keep") {
65
- if (!store.observe || !store.compareAndApply) return await legacyUpdate();
65
+ async function updateMatrixKeyedState(store, key, update, onUndefined = "keep") {
66
66
  let observation = await store.observe(key);
67
67
  for (;;) {
68
68
  const value = update(observation.value);
@@ -1,6 +1,6 @@
1
- import { w as setBoundedMap } from "./send-LCOuTVc1.mjs";
2
- import { c as EventType } from "./messages-B1CZqU8u.mjs";
3
- import { r as withResolvedRoomAction } from "./client-BlTvpEWC.mjs";
1
+ import { w as setBoundedMap } from "./send-BprM-Wmx.mjs";
2
+ import { s as EventType } from "./messages-_XHVg3do.mjs";
3
+ import { r as withResolvedRoomAction } from "./client-BKiiI29H.mjs";
4
4
  import { n as isMatrixNotFoundError } from "./errors-Bw4EHwKX.mjs";
5
5
  import { filterStringEntries } from "openclaw/plugin-sdk/string-coerce-runtime";
6
6
  //#region extensions/matrix/src/matrix/actions/room.ts
@@ -0,0 +1,2 @@
1
+ export { i as setMatrixRuntime, a as setMatrixRuntimeLifecycle } from "./runtime-1kn1P6io.mjs";
2
+ import "../runtime-setter-api.js";
@@ -1,16 +1,18 @@
1
1
  import { i as __exportAll } from "./doctor-contract-CsTNmbMa.mjs";
2
2
  import { t as getMatrixRuntime } from "./runtime-1kn1P6io.mjs";
3
- import { r as assertMatrixSupportedStateFile } from "./retired-state-DW5pLH05.mjs";
4
- import { d as writeMatrixRecoveryKeyStateForPathAsync, l as readMatrixRecoveryKeyStateForPathAsync } from "./storage-DkC6bHgA.mjs";
3
+ import { r as assertMatrixSupportedStateFile } from "./retired-state-DOCruzWd.mjs";
4
+ import { a as readMatrixRecoveryKeyStateForPathAsync, l as writeMatrixRecoveryKeyStateForPathAsync } from "./crypto-state-store-D4wrCvFs.mjs";
5
5
  import { n as withMatrixSendCurrentness, r as withoutMatrixSendCurrentness, t as captureMatrixSendCurrentness } from "./send-currentness-C2rMVVIQ.mjs";
6
6
  import { i as parseMxc, r as matrixEventToRaw } from "./event-helpers-CxNgMQqH.mjs";
7
+ import { i as createMatrixStartupAbortError, o as throwIfMatrixStartupAborted, r as awaitMatrixStartupWithAbort } from "./client-C4Gibhzl.mjs";
7
8
  import { n as isMatrixNotFoundError, t as formatMatrixErrorReason } from "./errors-Bw4EHwKX.mjs";
8
- import { i as createMatrixStartupAbortError, o as throwIfMatrixStartupAborted, r as awaitMatrixStartupWithAbort } from "./client-vPPbaxNp.mjs";
9
9
  import { n as createMatrixGuardedFetch, t as MatrixAuthedHttpClient } from "./http-client-ByR4STVQ.mjs";
10
10
  import { n as resolveMatrixRoomKeyBackupReadinessError } from "./backup-health-Dm_YMVFT.mjs";
11
11
  import { r as noop, t as LogService } from "./logger-CXQnpXCt.mjs";
12
12
  import { t as createMatrixJsSdkClientLogger } from "./logging-BKV8TYQq.mjs";
13
+ import { t as acquireMatrixCryptoStoreOwnership } from "./crypto-store-ownership-Z_Y5WRKr.mjs";
13
14
  import { a as isMatrixAccessTokenInvalidatedError, c as resolveMatrixLocalTimeoutMs, f as isMatrixReadySyncState, i as createMatrixExplicitBootstrapOptions, l as unresolvedMatrixDeviceVerificationStatus, n as MATRIX_INITIAL_CRYPTO_BOOTSTRAP_OPTIONS, o as resolveMatrixDiagnostic, p as isMatrixTerminalSyncState, r as MATRIX_STATUS_DIAGNOSTIC_TIMEOUT_MS, s as resolveMatrixDiagnosticResult, t as MATRIX_AUTOMATIC_REPAIR_BOOTSTRAP_OPTIONS, u as unresolvedMatrixRoomKeyBackupStatus } from "./client-support-D-xHScuo.mjs";
15
+ import { t as MATRIX_IDB_PERSIST_INTERVAL_MS } from "./idb-persistence-lock-Bh3ZLIsE.mjs";
14
16
  import { createRequire } from "node:module";
15
17
  import { createLazyRuntimeModule } from "openclaw/plugin-sdk/lazy-runtime";
16
18
  import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
@@ -19,10 +21,10 @@ import { createHash } from "node:crypto";
19
21
  import path from "node:path";
20
22
  import { AsyncLocalStorage } from "node:async_hooks";
21
23
  import { KeyedAsyncQueue } from "openclaw/plugin-sdk/keyed-async-queue";
22
- import { raceWithTimeout } from "openclaw/plugin-sdk/time-runtime";
23
24
  import { createDeferred } from "openclaw/plugin-sdk/extension-shared";
25
+ import { raceWithTimeout } from "openclaw/plugin-sdk/time-runtime";
24
26
  import { captureChannelReadAuthority, withEffectAuthority } from "openclaw/plugin-sdk/fetch-runtime";
25
- import { ClientEvent, EventType, Filter, MatrixError, MatrixEventEvent, MsgType, Preset, createClient } from "matrix-js-sdk/lib/matrix.js";
27
+ import { ClientEvent, EventType, Filter, MatrixError, MsgType, Preset, createClient } from "matrix-js-sdk/lib/matrix.js";
26
28
  import { EventEmitter } from "node:events";
27
29
  import { RoomEvent } from "matrix-js-sdk/lib/models/room.js";
28
30
  import { VerificationMethod } from "matrix-js-sdk/lib/types.js";
@@ -132,6 +134,25 @@ function refreshMatrixDmRoomIds(direct, dmRoomIds) {
132
134
  return true;
133
135
  }
134
136
  //#endregion
137
+ //#region extensions/matrix/src/matrix/sdk/client-crypto-bootstrap.ts
138
+ async function bootstrapMatrixClientCrypto(params) {
139
+ const { crypto, bootstrapper, abortSignal } = params;
140
+ if (!crypto || !bootstrapper) return false;
141
+ const initial = await bootstrapper.bootstrap(crypto, MATRIX_INITIAL_CRYPTO_BOOTSTRAP_OPTIONS);
142
+ throwIfMatrixStartupAborted(abortSignal);
143
+ if (!initial.crossSigningPublished || initial.ownDeviceVerified === false) {
144
+ if ((await params.getOwnDeviceVerificationStatus()).signedByOwner) LogService.warn("MatrixClientLite", "Cross-signing/bootstrap is incomplete for an already owner-signed device; skipping automatic reset and preserving the current identity. Restore the recovery key or run an explicit verification bootstrap if repair is needed.");
145
+ else try {
146
+ const repaired = await bootstrapper.bootstrap(crypto, MATRIX_AUTOMATIC_REPAIR_BOOTSTRAP_OPTIONS);
147
+ throwIfMatrixStartupAborted(abortSignal);
148
+ if (repaired.crossSigningPublished && repaired.ownDeviceVerified !== false) LogService.info("MatrixClientLite", "Cross-signing/bootstrap recovered after forced reset");
149
+ } catch (err) {
150
+ LogService.warn("MatrixClientLite", "Failed to recover cross-signing/bootstrap with forced reset:", err);
151
+ }
152
+ }
153
+ return true;
154
+ }
155
+ //#endregion
135
156
  //#region extensions/matrix/src/matrix/sdk/client-sync-quiesce.ts
136
157
  const MATRIX_SYNC_QUIESCE_TIMEOUT_MS = 5e3;
137
158
  const MATRIX_JS_SDK_SYNC_VERSION = "42.4.0";
@@ -242,18 +263,102 @@ async function waitForMatrixInitialSyncReady(params) {
242
263
  }
243
264
  }
244
265
  //#endregion
245
- //#region extensions/matrix/src/matrix/sdk/idb-persistence-lock.ts
246
- const MATRIX_IDB_PERSIST_INTERVAL_MS = 6e4;
247
- const MATRIX_IDB_SNAPSHOT_LOCK_OPTIONS = {
248
- retries: {
249
- retries: 18,
250
- factor: 2,
251
- minTimeout: 50,
252
- maxTimeout: 5e3,
253
- randomize: true
254
- },
255
- stale: 3e5
256
- };
266
+ //#region extensions/matrix/src/matrix/sdk/crypto-store-lifecycle.ts
267
+ async function closeMatrixCryptoStores(closeRecoveryKeys, releaseOwnership, teardownComplete) {
268
+ const recovery = await Promise.allSettled([closeRecoveryKeys()]);
269
+ const release = teardownComplete ? await Promise.allSettled([releaseOwnership()]) : [];
270
+ const failures = [...recovery, ...release].filter((result) => result.status === "rejected").map((result) => result.reason);
271
+ if (failures.length > 1) throw new AggregateError(failures, "Failed to close Matrix crypto stores");
272
+ if (failures.length === 1) throw failures[0];
273
+ }
274
+ /** Final publication is allowed only for a generation that initialized under custody. */
275
+ async function persistMatrixFinalState(params) {
276
+ if (params.cryptoInitialized) {
277
+ if (params.snapshotPath && !params.ownership) throw new Error("Refusing Matrix crypto snapshot publication without ownership");
278
+ await params.persistSnapshot();
279
+ }
280
+ if (!params.encryptionEnabled || params.cryptoInitialized) params.syncStore?.markCleanShutdown();
281
+ await params.syncStore?.flush();
282
+ if (params.cryptoInitialized) await params.ownership?.sealSafeState();
283
+ }
284
+ /** Join an in-flight crypto initialization before a generation can be retired. */
285
+ function createMatrixCryptoInitializationGate() {
286
+ let pending = null;
287
+ let failure = null;
288
+ return {
289
+ get pending() {
290
+ return pending;
291
+ },
292
+ get failure() {
293
+ return failure;
294
+ },
295
+ recordFailure(error) {
296
+ failure = { error };
297
+ },
298
+ async run(initialize, abortSignal) {
299
+ if (failure) throw new Error("Matrix crypto initialization failed; restart this process before retrying", { cause: failure.error });
300
+ if (pending) {
301
+ await pending;
302
+ abortSignal?.throwIfAborted();
303
+ return;
304
+ }
305
+ const task = initialize();
306
+ pending = task;
307
+ try {
308
+ await task;
309
+ } finally {
310
+ if (pending === task) pending = null;
311
+ }
312
+ }
313
+ };
314
+ }
315
+ /** Quiescence failure forbids publication but still requires teardown under custody. */
316
+ async function runMatrixClientShutdown(params) {
317
+ const failures = [];
318
+ let persist = params.persist;
319
+ try {
320
+ try {
321
+ await params.quiesceSync();
322
+ } catch (error) {
323
+ if (persist) failures.push(error);
324
+ persist = false;
325
+ }
326
+ if (!persist) params.discardSync();
327
+ await params.stop(persist);
328
+ } catch (error) {
329
+ failures.push(error);
330
+ params.discardSync();
331
+ } finally {
332
+ try {
333
+ await params.closeStores();
334
+ } catch (error) {
335
+ failures.push(error);
336
+ }
337
+ }
338
+ if (failures.length === 1) throw failures[0];
339
+ if (failures.length > 1) throw new AggregateError(failures, "Failed to shut down Matrix client generation");
340
+ }
341
+ /** SDK crypto stop is not retryable after throwing: it marks itself stopped before store closure. */
342
+ function createMatrixSdkStopGate() {
343
+ let stopped = false;
344
+ let failure = null;
345
+ return {
346
+ get stopped() {
347
+ return stopped || failure !== null;
348
+ },
349
+ stop(stopSdk) {
350
+ if (stopped) return;
351
+ if (failure) throw failure.error;
352
+ try {
353
+ stopSdk();
354
+ stopped = true;
355
+ } catch (error) {
356
+ failure = { error };
357
+ throw error;
358
+ }
359
+ }
360
+ };
361
+ }
257
362
  //#endregion
258
363
  //#region extensions/matrix/src/matrix/sdk/live-room-readiness.ts
259
364
  async function withMatrixLiveEncryptedRoom(owner, run, params) {
@@ -309,7 +414,6 @@ async function probeMatrixLiveEncryptedRoom(params) {
309
414
  for (;;) {
310
415
  changed = false;
311
416
  assertActive();
312
- const sync = params.getSync();
313
417
  const room = params.client.getRoom(params.roomId);
314
418
  const crypto = params.client.getCrypto();
315
419
  const isCurrent = () => {
@@ -319,7 +423,7 @@ async function probeMatrixLiveEncryptedRoom(params) {
319
423
  if (isCurrent() && crypto) {
320
424
  const encrypted = await crypto.isEncryptionEnabledInRoom(params.roomId);
321
425
  assertActive();
322
- if (params.getSync().revision !== sync.revision || !isCurrent()) continue;
426
+ if (!isCurrent()) continue;
323
427
  if (encrypted) return () => {
324
428
  assertActive();
325
429
  if (!isCurrent()) throw new Error("Matrix live encrypted room changed before dispatch; retry the send");
@@ -714,7 +818,7 @@ var MatrixSendScheduler = class extends MatrixScheduler {
714
818
  //#region extensions/matrix/src/matrix/sdk/client-base.ts
715
819
  const MATRIX_ENCRYPTED_STARTUP_TIMEOUT_MS = 6e4;
716
820
  let loadedMatrixCryptoRuntime = null;
717
- const loadMatrixCryptoRuntime = createLazyRuntimeModule(() => import("./crypto-runtime-CpJ0b7vY.mjs").then((runtime) => {
821
+ const loadMatrixCryptoRuntime = createLazyRuntimeModule(() => import("./crypto-runtime-D8yY7kjD.mjs").then((runtime) => {
718
822
  loadedMatrixCryptoRuntime = runtime;
719
823
  return runtime;
720
824
  }));
@@ -739,19 +843,21 @@ var MatrixClientBase = class {
739
843
  this.currentSyncState = null;
740
844
  this.currentSyncError = void 0;
741
845
  this.currentSyncFromCache = false;
742
- this.currentSyncRevision = 0;
743
846
  this.transactionScopeId = null;
744
847
  this.transactionScopePromise = null;
745
848
  this.messageWireDispatchGuards = new MatrixMessageWireDispatchGuards();
746
849
  this.requestAbortController = new AbortController();
747
850
  this.cryptoRequestOwner = new AsyncLocalStorage();
748
851
  this.startupPromise = null;
749
- this.cryptoInitializationPromise = null;
852
+ this.cryptoInitializationGate = createMatrixCryptoInitializationGate();
750
853
  this.liveRoomReadinessOperations = /* @__PURE__ */ new Set();
751
- this.sdkStopped = false;
854
+ this.sdkStopGate = createMatrixSdkStopGate();
855
+ this.generationTeardownComplete = false;
752
856
  this.stopDiscardPromise = null;
753
857
  this.idbPersistPromise = null;
754
858
  this.idbPersistAbortController = null;
859
+ this.cryptoStoreOwnership = null;
860
+ this.sdkIndexedDbSession = null;
755
861
  this.assertClientActive = () => {
756
862
  this.requestAbortController.signal.throwIfAborted();
757
863
  };
@@ -898,7 +1004,7 @@ var MatrixClientBase = class {
898
1004
  }
899
1005
  async startSyncSession(opts) {
900
1006
  if (this.started) return;
901
- if (this.sdkStopped) throw new Error("Matrix client has been fully stopped and cannot be restarted; acquire a new shared client generation");
1007
+ if (this.sdkStopGate.stopped) throw new Error("Matrix client has been fully stopped and cannot be restarted; acquire a new shared client generation");
902
1008
  const assertCurrent = this.captureRequestAuthority();
903
1009
  assertCurrent?.();
904
1010
  this.assertClientActive();
@@ -986,12 +1092,11 @@ var MatrixClientBase = class {
986
1092
  assertActive: () => {
987
1093
  this.assertClientActive();
988
1094
  opts.assertCurrent?.();
989
- if (this.sdkStopped || this.syncQuiescePromise) throw new Error("Matrix client is stopping; acquire a new client before sending");
1095
+ if (this.sdkStopGate.stopped || this.syncQuiescePromise) throw new Error("Matrix client is stopping; acquire a new client before sending");
990
1096
  },
991
1097
  getSync: () => ({
992
1098
  state: this.currentSyncState,
993
- fromCache: this.currentSyncFromCache,
994
- revision: this.currentSyncRevision
1099
+ fromCache: this.currentSyncFromCache
995
1100
  })
996
1101
  });
997
1102
  }
@@ -1002,14 +1107,6 @@ var MatrixClientBase = class {
1002
1107
  if (this.started) return;
1003
1108
  await this.startSyncSession({ bootstrapCrypto: false });
1004
1109
  }
1005
- stopSdkClient() {
1006
- if (this.sdkStopped) return;
1007
- this.currentSyncState = null;
1008
- this.currentSyncError = void 0;
1009
- this.sdkStopped = true;
1010
- this.client.stopClient();
1011
- this.started = false;
1012
- }
1013
1110
  async quiesceSync() {
1014
1111
  this.syncQuiescePromise ??= quiesceMatrixClientSync({
1015
1112
  client: this.client,
@@ -1028,122 +1125,138 @@ var MatrixClientBase = class {
1028
1125
  stop() {
1029
1126
  this.stopAndPersist().catch(() => this.stopWithoutPersist()).catch(noop);
1030
1127
  }
1128
+ async releaseCryptoStoreOwnership() {
1129
+ const ownership = this.cryptoStoreOwnership;
1130
+ this.cryptoStoreOwnership = null;
1131
+ await ownership?.release();
1132
+ }
1031
1133
  async stopClientGeneration(persist) {
1032
- try {
1033
- if (persist) await this.quiesceSync();
1034
- else {
1035
- await this.quiesceSync().catch(noop);
1036
- this.syncStore?.discardPendingSyncCursorPersistence();
1037
- }
1038
- this.abortPendingRequests();
1039
- await this.startupPromise?.catch(noop);
1040
- await this.cryptoInitializationPromise?.catch(noop);
1041
- await Promise.allSettled(this.liveRoomReadinessOperations);
1042
- clearInterval(this.idbPersistTimer ?? void 0);
1043
- this.idbPersistTimer = null;
1044
- this.idbPersistAbortController?.abort();
1045
- const activePeriodicPersist = this.idbPersistPromise;
1046
- try {
1047
- this.stopSdkClient();
1048
- this.decryptBridge?.stop();
1049
- } finally {
1050
- this.cryptoRequestOwner.disable();
1051
- }
1052
- await Promise.all([this.recoveryKeyStore.close(), activePeriodicPersist]);
1053
- if (persist) {
1054
- await (loadedMatrixCryptoRuntime ?? await loadMatrixCryptoRuntime()).persistIdbToDisk({
1134
+ await runMatrixClientShutdown({
1135
+ persist,
1136
+ quiesceSync: () => this.quiesceSync(),
1137
+ discardSync: () => this.syncStore?.discardPendingSyncCursorPersistence(),
1138
+ stop: async (publishFinalState) => {
1139
+ this.abortPendingRequests();
1140
+ await this.startupPromise?.catch(noop);
1141
+ await this.cryptoInitializationGate.pending?.catch(noop);
1142
+ await Promise.allSettled(this.liveRoomReadinessOperations);
1143
+ clearInterval(this.idbPersistTimer ?? void 0);
1144
+ this.idbPersistTimer = null;
1145
+ this.idbPersistAbortController?.abort();
1146
+ const activePeriodicPersist = this.idbPersistPromise;
1147
+ try {
1148
+ this.sdkStopGate.stop(() => {
1149
+ this.currentSyncState = null;
1150
+ this.currentSyncError = void 0;
1151
+ this.client.stopClient();
1152
+ this.started = false;
1153
+ });
1154
+ } finally {
1155
+ this.decryptBridge?.stop();
1156
+ this.cryptoRequestOwner.disable();
1157
+ }
1158
+ await this.sdkIndexedDbSession?.retire();
1159
+ await Promise.all([this.recoveryKeyStore.close(), activePeriodicPersist]);
1160
+ if (this.cryptoInitializationGate.failure) throw new Error("Matrix crypto initialization failed; restart this process before recovery", { cause: this.cryptoInitializationGate.failure.error });
1161
+ this.generationTeardownComplete = true;
1162
+ if (publishFinalState) await persistMatrixFinalState({
1163
+ encryptionEnabled: this.encryptionEnabled,
1164
+ cryptoInitialized: this.cryptoInitialized,
1165
+ ownership: this.cryptoStoreOwnership,
1055
1166
  snapshotPath: this.idbSnapshotPath,
1056
- databasePrefix: this.cryptoDatabasePrefix,
1057
- strict: true,
1058
- stateRuntime: this.stateRuntime
1167
+ persistSnapshot: async () => {
1168
+ await (loadedMatrixCryptoRuntime ?? await loadMatrixCryptoRuntime()).persistIdbToDisk({
1169
+ snapshotPath: this.idbSnapshotPath,
1170
+ databasePrefix: this.cryptoDatabasePrefix,
1171
+ strict: true,
1172
+ stateRuntime: this.stateRuntime
1173
+ });
1174
+ },
1175
+ syncStore: this.syncStore
1059
1176
  });
1060
- this.syncStore?.markCleanShutdown();
1061
- await this.syncStore?.flush();
1062
- }
1063
- } finally {
1064
- await this.recoveryKeyStore.close();
1065
- }
1177
+ },
1178
+ closeStores: () => closeMatrixCryptoStores(() => this.recoveryKeyStore.close(), () => this.releaseCryptoStoreOwnership(), this.generationTeardownComplete)
1179
+ });
1066
1180
  }
1067
1181
  async stopAndPersist() {
1068
- this.stopPersistPromise ??= this.stopClientGeneration(true);
1069
- await this.stopPersistPromise;
1182
+ await (this.stopPersistPromise ??= this.stopClientGeneration(true));
1070
1183
  }
1071
1184
  stopWithoutPersist() {
1072
1185
  if (!this.stopPersistPromise) this.stopPersistPromise = this.stopDiscardPromise = this.stopClientGeneration(false);
1073
- return this.stopDiscardPromise ??= this.stopPersistPromise.catch(() => this.stopClientGeneration(false));
1186
+ return this.stopDiscardPromise ??= this.stopPersistPromise.catch(() => this.generationTeardownComplete ? void 0 : this.stopClientGeneration(false));
1074
1187
  }
1075
1188
  async bootstrapCryptoIfNeeded(abortSignal) {
1076
1189
  if (!this.encryptionEnabled || !this.cryptoInitialized || this.cryptoBootstrapped) return;
1077
1190
  throwIfMatrixStartupAborted(abortSignal);
1078
1191
  await this.ensureCryptoSupportInitialized();
1079
- const crypto = this.client.getCrypto();
1080
- if (!crypto) return;
1081
- const cryptoBootstrapper = this.cryptoBootstrapper;
1082
- if (!cryptoBootstrapper) return;
1083
- const initial = await cryptoBootstrapper.bootstrap(crypto, MATRIX_INITIAL_CRYPTO_BOOTSTRAP_OPTIONS);
1084
- throwIfMatrixStartupAborted(abortSignal);
1085
- if (!initial.crossSigningPublished || initial.ownDeviceVerified === false) {
1086
- if ((await this.getOwnDeviceVerificationStatus()).signedByOwner) LogService.warn("MatrixClientLite", "Cross-signing/bootstrap is incomplete for an already owner-signed device; skipping automatic reset and preserving the current identity. Restore the recovery key or run an explicit verification bootstrap if repair is needed.");
1087
- else try {
1088
- const repaired = await cryptoBootstrapper.bootstrap(crypto, MATRIX_AUTOMATIC_REPAIR_BOOTSTRAP_OPTIONS);
1089
- throwIfMatrixStartupAborted(abortSignal);
1090
- if (repaired.crossSigningPublished && repaired.ownDeviceVerified !== false) LogService.info("MatrixClientLite", "Cross-signing/bootstrap recovered after forced reset");
1091
- } catch (err) {
1092
- LogService.warn("MatrixClientLite", "Failed to recover cross-signing/bootstrap with forced reset:", err);
1093
- }
1094
- }
1095
- this.cryptoBootstrapped = true;
1192
+ this.cryptoBootstrapped = await bootstrapMatrixClientCrypto({
1193
+ crypto: this.client.getCrypto(),
1194
+ bootstrapper: this.cryptoBootstrapper,
1195
+ getOwnDeviceVerificationStatus: () => this.getOwnDeviceVerificationStatus(),
1196
+ abortSignal
1197
+ });
1096
1198
  }
1097
1199
  async initializeCryptoIfNeeded(abortSignal) {
1098
- if (!this.encryptionEnabled) return;
1099
- if (this.cryptoInitializationPromise) {
1100
- await this.cryptoInitializationPromise;
1101
- throwIfMatrixStartupAborted(abortSignal);
1102
- return;
1103
- }
1104
- if (this.cryptoInitialized) return;
1105
- const initialization = this.initializeCrypto(abortSignal ? AbortSignal.any([abortSignal, this.requestAbortController.signal]) : this.requestAbortController.signal);
1106
- this.cryptoInitializationPromise = initialization;
1107
- try {
1108
- await initialization;
1109
- } finally {
1110
- if (this.cryptoInitializationPromise === initialization) this.cryptoInitializationPromise = null;
1111
- }
1200
+ if (!this.encryptionEnabled || this.cryptoInitialized && !this.cryptoInitializationGate.pending) return;
1201
+ await this.cryptoInitializationGate.run(() => this.initializeCrypto(abortSignal ? AbortSignal.any([abortSignal, this.requestAbortController.signal]) : this.requestAbortController.signal), abortSignal);
1112
1202
  }
1113
1203
  async initializeCrypto(abortSignal) {
1114
1204
  throwIfMatrixStartupAborted(abortSignal);
1115
- const { persistIdbToDisk, restoreIdbFromDisk } = await loadMatrixCryptoRuntime();
1116
- await restoreIdbFromDisk(this.idbSnapshotPath, this.stateRuntime);
1117
- throwIfMatrixStartupAborted(abortSignal);
1205
+ const { persistIdbToDisk, restoreIdbFromDisk, resolveDefaultIdbSnapshotPath, beginMatrixSdkIndexedDbSession } = await loadMatrixCryptoRuntime();
1206
+ this.idbSnapshotPath ??= resolveDefaultIdbSnapshotPath();
1207
+ if (!this.cryptoStoreOwnership) this.cryptoStoreOwnership = await acquireMatrixCryptoStoreOwnership(this.idbSnapshotPath, {
1208
+ signal: abortSignal,
1209
+ stateRuntime: this.stateRuntime
1210
+ });
1211
+ let rustCryptoInitializationStarted = false;
1118
1212
  try {
1119
- await this.client.initRustCrypto({ cryptoDatabasePrefix: this.cryptoDatabasePrefix });
1120
- this.cryptoInitialized = true;
1213
+ await restoreIdbFromDisk(this.idbSnapshotPath, this.stateRuntime, this.cryptoDatabasePrefix);
1121
1214
  throwIfMatrixStartupAborted(abortSignal);
1122
- await persistIdbToDisk({
1123
- snapshotPath: this.idbSnapshotPath,
1124
- databasePrefix: this.cryptoDatabasePrefix,
1125
- abortSignal,
1126
- stateRuntime: this.stateRuntime
1127
- });
1215
+ await this.cryptoStoreOwnership?.armUnsafeState();
1128
1216
  throwIfMatrixStartupAborted(abortSignal);
1129
- this.idbPersistTimer = setInterval(() => {
1130
- if (this.idbPersistPromise) return;
1131
- const abortController = new AbortController();
1132
- this.idbPersistAbortController = abortController;
1133
- this.idbPersistPromise = persistIdbToDisk({
1217
+ this.sdkIndexedDbSession = beginMatrixSdkIndexedDbSession(this.cryptoDatabasePrefix);
1218
+ try {
1219
+ rustCryptoInitializationStarted = true;
1220
+ await this.client.initRustCrypto({ cryptoDatabasePrefix: this.cryptoDatabasePrefix });
1221
+ this.cryptoInitialized = true;
1222
+ throwIfMatrixStartupAborted(abortSignal);
1223
+ await persistIdbToDisk({
1134
1224
  snapshotPath: this.idbSnapshotPath,
1135
1225
  databasePrefix: this.cryptoDatabasePrefix,
1136
- abortSignal: abortController.signal,
1226
+ abortSignal,
1137
1227
  stateRuntime: this.stateRuntime
1138
- }).catch(noop).finally(() => {
1139
- this.idbPersistPromise = null;
1140
- this.idbPersistAbortController = null;
1141
1228
  });
1142
- }, MATRIX_IDB_PERSIST_INTERVAL_MS);
1143
- this.idbPersistTimer.unref?.();
1144
- } catch (err) {
1145
- throwIfMatrixStartupAborted(abortSignal);
1146
- LogService.warn("MatrixClientLite", "Failed to initialize rust crypto:", err);
1229
+ throwIfMatrixStartupAborted(abortSignal);
1230
+ this.idbPersistTimer = setInterval(() => {
1231
+ if (this.idbPersistPromise) return;
1232
+ const abortController = new AbortController();
1233
+ this.idbPersistAbortController = abortController;
1234
+ this.idbPersistPromise = persistIdbToDisk({
1235
+ snapshotPath: this.idbSnapshotPath,
1236
+ databasePrefix: this.cryptoDatabasePrefix,
1237
+ abortSignal: abortController.signal,
1238
+ stateRuntime: this.stateRuntime
1239
+ }).catch(noop).finally(() => {
1240
+ this.idbPersistPromise = null;
1241
+ this.idbPersistAbortController = null;
1242
+ });
1243
+ }, MATRIX_IDB_PERSIST_INTERVAL_MS);
1244
+ this.idbPersistTimer.unref?.();
1245
+ } catch (err) {
1246
+ if (!this.cryptoInitialized) {
1247
+ this.cryptoInitializationGate.recordFailure(err);
1248
+ throw err;
1249
+ }
1250
+ throwIfMatrixStartupAborted(abortSignal);
1251
+ LogService.warn("MatrixClientLite", "Failed to initialize rust crypto:", err);
1252
+ }
1253
+ } catch (error) {
1254
+ if (!this.cryptoInitialized && !rustCryptoInitializationStarted) try {
1255
+ await this.cryptoStoreOwnership?.cancelUnsafeState();
1256
+ } finally {
1257
+ await this.releaseCryptoStoreOwnership();
1258
+ }
1259
+ throw error;
1147
1260
  }
1148
1261
  }
1149
1262
  };
@@ -1352,17 +1465,8 @@ var MatrixClientCore = class extends MatrixClientBase {
1352
1465
  const rawEvent = await this.client.fetchRoomEvent(roomId, eventId);
1353
1466
  if (rawEvent.type !== "m.room.encrypted") return rawEvent;
1354
1467
  const event = this.client.getEventMapper()(rawEvent);
1355
- let decryptedEvent;
1356
- const onDecrypted = (candidate) => {
1357
- decryptedEvent = candidate;
1358
- };
1359
- event.once(MatrixEventEvent.Decrypted, onDecrypted);
1360
- try {
1361
- await this.client.decryptEventIfNeeded(event);
1362
- } finally {
1363
- event.off(MatrixEventEvent.Decrypted, onDecrypted);
1364
- }
1365
- return matrixEventToRaw(decryptedEvent ?? event);
1468
+ await this.client.decryptEventIfNeeded(event);
1469
+ return matrixEventToRaw(event);
1366
1470
  }
1367
1471
  async getRelations(roomId, eventId, relationType, eventType, opts = {}) {
1368
1472
  const result = await this.client.relations(roomId, eventId, relationType, eventType, opts);
@@ -1849,7 +1953,6 @@ var MatrixClient = class extends MatrixClientVerification {
1849
1953
  this.currentSyncState = state;
1850
1954
  this.currentSyncError = error;
1851
1955
  this.currentSyncFromCache = fromCache;
1852
- this.currentSyncRevision += 1;
1853
1956
  }
1854
1957
  });
1855
1958
  }
@@ -1868,4 +1971,4 @@ var MatrixClient = class extends MatrixClientVerification {
1868
1971
  }
1869
1972
  };
1870
1973
  //#endregion
1871
- export { MatrixClient, isRepairableSecretStorageAccessError as a, trustMatrixOwnIdentity as i, isMatrixDeviceOwnerVerified as n, MATRIX_IDB_SNAPSHOT_LOCK_OPTIONS as o, isMatrixDeviceVerifiedInCurrentClient as r, sdk_exports as t };
1974
+ export { MatrixClient, isRepairableSecretStorageAccessError as a, trustMatrixOwnIdentity as i, isMatrixDeviceOwnerVerified as n, isMatrixDeviceVerifiedInCurrentClient as r, sdk_exports as t };