@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,25 +1,19 @@
1
- import { t as getMatrixRuntime } from "./runtime-1kn1P6io.mjs";
2
1
  import { t as ensureMatrixCryptoRuntime } from "./deps-L_1bUAGL.mjs";
3
- import { n as RETIRED_MATRIX_STATE_REMEDIATION } from "./retired-state-DW5pLH05.mjs";
4
- import { c as readMatrixIdbSnapshotJson, u as writeMatrixIdbSnapshotJson } from "./storage-DkC6bHgA.mjs";
5
2
  import { r as noop, t as LogService } from "./logger-CXQnpXCt.mjs";
6
- import { a as isRepairableSecretStorageAccessError, i as trustMatrixOwnIdentity, n as isMatrixDeviceOwnerVerified, o as MATRIX_IDB_SNAPSHOT_LOCK_OPTIONS, r as isMatrixDeviceVerifiedInCurrentClient } from "./sdk-Cfc6m7fY.mjs";
3
+ import { a as isRepairableSecretStorageAccessError, i as trustMatrixOwnIdentity, n as isMatrixDeviceOwnerVerified, r as isMatrixDeviceVerifiedInCurrentClient } from "./sdk-ByU8So5S.mjs";
4
+ import { persistIdbToDisk, resolveDefaultIdbSnapshotPath, restoreIdbFromDisk } from "./idb-persistence-BHTYPRe_.mjs";
7
5
  import { createLazyRuntimeModule } from "openclaw/plugin-sdk/lazy-runtime";
8
- import { formatErrorMessage, toErrorObject, toStringifiedError } from "openclaw/plugin-sdk/error-runtime";
9
- import { asOptionalObjectRecord } from "openclaw/plugin-sdk/string-coerce-runtime";
10
- import path from "node:path";
11
- import { resolveDateTimestampMs, resolveTimestampMsToIsoString } from "openclaw/plugin-sdk/number-runtime";
12
- import fs from "node:fs";
6
+ import { formatErrorMessage, toStringifiedError } from "openclaw/plugin-sdk/error-runtime";
7
+ import { resolveGlobalSingleton } from "openclaw/plugin-sdk/global-singleton";
13
8
  import { raceWithTimeout } from "openclaw/plugin-sdk/time-runtime";
14
9
  import { pruneMapToMaxSize } from "openclaw/plugin-sdk/collection-runtime";
15
10
  import { setTimeout as setTimeout$1 } from "node:timers/promises";
16
11
  import { MatrixEventEvent } from "matrix-js-sdk/lib/matrix.js";
17
12
  import { VerificationMethod } from "matrix-js-sdk/lib/types.js";
18
13
  import "fake-indexeddb/auto";
19
- import { IDBDatabase, indexedDB } from "fake-indexeddb";
14
+ import { IDBDatabase } from "fake-indexeddb";
20
15
  import { CryptoEvent } from "matrix-js-sdk/lib/crypto-api/CryptoEvent.js";
21
16
  import { DecryptionFailureCode } from "matrix-js-sdk/lib/crypto-api/index.js";
22
- import { withFileLock } from "openclaw/plugin-sdk/file-lock";
23
17
  import { VerificationPhase, VerificationRequestEvent, VerifierEvent } from "matrix-js-sdk/lib/crypto-api/verification.js";
24
18
  import { expectDefined } from "openclaw/plugin-sdk/expect-runtime";
25
19
  //#region extensions/matrix/src/matrix/sdk/fake-indexeddb-prune.ts
@@ -275,15 +269,7 @@ var MatrixCryptoBootstrapper = class {
275
269
  };
276
270
  //#endregion
277
271
  //#region extensions/matrix/src/matrix/sdk/crypto-facade.ts
278
- const matrixCryptoNodeRuntimeLoader = createLazyRuntimeModule(() => import("./crypto-node.runtime-6Aj_ltHQ.mjs"));
279
- async function loadMatrixCryptoNodeRuntime() {
280
- try {
281
- return await matrixCryptoNodeRuntimeLoader();
282
- } catch (error) {
283
- matrixCryptoNodeRuntimeLoader.clear();
284
- throw error;
285
- }
286
- }
272
+ const loadMatrixCryptoNodeRuntime = createLazyRuntimeModule(() => import("./crypto-node.runtime-6Aj_ltHQ.mjs"));
287
273
  async function loadMatrixCryptoNodeBindings() {
288
274
  await ensureMatrixCryptoRuntime();
289
275
  return (await loadMatrixCryptoNodeRuntime()).loadMatrixCryptoNodeBindings();
@@ -374,13 +360,11 @@ var MatrixDecryptBridge = class {
374
360
  constructor(deps) {
375
361
  this.deps = deps;
376
362
  this.trackedEncryptedEvents = /* @__PURE__ */ new WeakSet();
377
- this.pendingSdkDecryptions = /* @__PURE__ */ new Set();
363
+ this.pendingDecryptions = /* @__PURE__ */ new Set();
378
364
  this.decryptedMessageDedupe = /* @__PURE__ */ new Map();
379
365
  this.decryptRetries = /* @__PURE__ */ new Map();
380
366
  this.failedDecryptionsNotified = /* @__PURE__ */ new Set();
381
367
  this.exhaustedDecryptRetries = /* @__PURE__ */ new Map();
382
- this.activeRetryRuns = 0;
383
- this.retryIdleResolvers = /* @__PURE__ */ new Set();
384
368
  this.cryptoRetrySignalsBound = false;
385
369
  this.quiescing = false;
386
370
  this.stopped = false;
@@ -397,13 +381,7 @@ var MatrixDecryptBridge = class {
397
381
  if (this.trackedEncryptedEvents.has(event)) return;
398
382
  this.trackedEncryptedEvents.add(event);
399
383
  const sdkDecryption = event.getDecryptionPromise();
400
- if (sdkDecryption) {
401
- this.pendingSdkDecryptions.add(sdkDecryption);
402
- const forgetSdkDecryption = () => {
403
- this.pendingSdkDecryptions.delete(sdkDecryption);
404
- };
405
- sdkDecryption.then(forgetSdkDecryption, forgetSdkDecryption);
406
- }
384
+ if (sdkDecryption) this.trackDecryption(sdkDecryption);
407
385
  event.on(MatrixEventEvent.Decrypted, (decryptedEvent, err) => {
408
386
  this.handleEncryptedEventDecrypted({
409
387
  roomId,
@@ -471,14 +449,13 @@ var MatrixDecryptBridge = class {
471
449
  this.quiescing = true;
472
450
  this.stopped = true;
473
451
  for (const retryKey of this.decryptRetries.keys()) this.clearDecryptRetry(retryKey);
474
- this.pendingSdkDecryptions.clear();
452
+ this.pendingDecryptions.clear();
475
453
  this.exhaustedDecryptRetries.clear();
476
454
  }
477
455
  async drainPendingDecryptions(_reason) {
478
456
  this.quiescing = true;
479
- const pendingSdkDecryptions = Array.from(this.pendingSdkDecryptions);
480
457
  this.startPendingRetries(Array.from(this.decryptRetries.entries()));
481
- await raceWithTimeout(Promise.all([Promise.allSettled(pendingSdkDecryptions), this.waitForActiveRetryRunsToFinish()]), MATRIX_DECRYPT_DRAIN_TIMEOUT_MS, () => {
458
+ await raceWithTimeout(Promise.allSettled(this.pendingDecryptions), MATRIX_DECRYPT_DRAIN_TIMEOUT_MS, () => {
482
459
  throw new Error(`Matrix decryption drain did not finish within ${MATRIX_DECRYPT_DRAIN_TIMEOUT_MS}ms`);
483
460
  }, { ref: false });
484
461
  }
@@ -559,19 +536,26 @@ var MatrixDecryptBridge = class {
559
536
  }, delayMs);
560
537
  this.decryptRetries.set(retryKey, next);
561
538
  }
562
- async runDecryptRetry(retryKey) {
539
+ trackDecryption(pending) {
540
+ this.pendingDecryptions.add(pending);
541
+ const forget = () => this.pendingDecryptions.delete(pending);
542
+ pending.then(forget, forget);
543
+ }
544
+ runDecryptRetry(retryKey) {
545
+ const pending = this.attemptDecryptRetry(retryKey);
546
+ this.trackDecryption(pending);
547
+ return pending;
548
+ }
549
+ async attemptDecryptRetry(retryKey) {
563
550
  const state = this.decryptRetries.get(retryKey);
564
551
  if (!state || state.inFlight) return;
565
552
  state.inFlight = true;
566
553
  state.timer = null;
567
- this.activeRetryRuns += 1;
568
554
  const retryEvent = state.event;
569
555
  const retryCrypto = this.deps.client.getCrypto?.();
570
556
  const canAttemptDecryption = retryCrypto !== void 0 && retryCrypto !== null && typeof retryEvent.attemptDecryption === "function";
571
557
  if (!(canAttemptDecryption || typeof this.deps.client.decryptEventIfNeeded === "function")) {
572
558
  this.clearDecryptRetry(retryKey);
573
- this.activeRetryRuns = Math.max(0, this.activeRetryRuns - 1);
574
- this.resolveRetryIdleIfNeeded();
575
559
  return;
576
560
  }
577
561
  try {
@@ -579,8 +563,6 @@ var MatrixDecryptBridge = class {
579
563
  else await this.deps.client.decryptEventIfNeeded?.(state.event, { isRetry: true });
580
564
  } catch {} finally {
581
565
  state.inFlight = false;
582
- this.activeRetryRuns = Math.max(0, this.activeRetryRuns - 1);
583
- this.resolveRetryIdleIfNeeded();
584
566
  }
585
567
  if (this.decryptRetries.get(retryKey) !== state) return;
586
568
  if (this.stopped || this.quiescing && state.event.isDecryptionFailure()) {
@@ -623,210 +605,8 @@ var MatrixDecryptBridge = class {
623
605
  for (const [key, createdAt] of this.decryptedMessageDedupe) if (now - createdAt > ttlMs) this.decryptedMessageDedupe.delete(key);
624
606
  pruneMapToMaxSize(this.decryptedMessageDedupe, 2048);
625
607
  }
626
- async waitForActiveRetryRunsToFinish() {
627
- if (this.activeRetryRuns === 0) return;
628
- await new Promise((resolve) => {
629
- this.retryIdleResolvers.add(resolve);
630
- });
631
- }
632
- resolveRetryIdleIfNeeded() {
633
- if (this.activeRetryRuns !== 0) return;
634
- for (const resolve of this.retryIdleResolvers) resolve();
635
- this.retryIdleResolvers.clear();
636
- }
637
608
  };
638
609
  //#endregion
639
- //#region extensions/matrix/src/matrix/sdk/idb-persistence.ts
640
- const LEGACY_SNAPSHOT_DIAGNOSTIC = {
641
- code: "matrix-idb-snapshot-requires-doctor",
642
- message: "Matrix IndexedDB snapshot exists outside canonical SQLite state",
643
- remediation: RETIRED_MATRIX_STATE_REMEDIATION
644
- };
645
- var MatrixIdbSnapshotMigrationRequiredError = class extends Error {
646
- constructor() {
647
- super(`${LEGACY_SNAPSHOT_DIAGNOSTIC.message}; ${LEGACY_SNAPSHOT_DIAGNOSTIC.remediation}`);
648
- this.code = LEGACY_SNAPSHOT_DIAGNOSTIC.code;
649
- this.remediation = LEGACY_SNAPSHOT_DIAGNOSTIC.remediation;
650
- this.name = "MatrixIdbSnapshotMigrationRequiredError";
651
- }
652
- };
653
- function isValidIdbIndexSnapshot(value) {
654
- const candidate = asOptionalObjectRecord(value);
655
- return typeof candidate?.name === "string" && (typeof candidate.keyPath === "string" || Array.isArray(candidate.keyPath) && candidate.keyPath.every((entry) => typeof entry === "string")) && typeof candidate.multiEntry === "boolean" && typeof candidate.unique === "boolean";
656
- }
657
- function isValidIdbRecordSnapshot(value) {
658
- const candidate = asOptionalObjectRecord(value);
659
- return Boolean(candidate && "key" in candidate && "value" in candidate);
660
- }
661
- function isValidIdbStoreSnapshot(value) {
662
- const candidate = asOptionalObjectRecord(value);
663
- const keyPath = candidate?.keyPath;
664
- const validKeyPath = keyPath === null || typeof keyPath === "string" || Array.isArray(keyPath) && keyPath.every((entry) => typeof entry === "string");
665
- return typeof candidate?.name === "string" && validKeyPath && typeof candidate.autoIncrement === "boolean" && Array.isArray(candidate.indexes) && candidate.indexes.every((entry) => isValidIdbIndexSnapshot(entry)) && Array.isArray(candidate.records) && candidate.records.every((entry) => isValidIdbRecordSnapshot(entry));
666
- }
667
- function isValidIdbDatabaseSnapshot(value) {
668
- const candidate = asOptionalObjectRecord(value);
669
- return typeof candidate?.name === "string" && typeof candidate.version === "number" && Number.isFinite(candidate.version) && candidate.version > 0 && Array.isArray(candidate.stores) && candidate.stores.every((entry) => isValidIdbStoreSnapshot(entry));
670
- }
671
- function parseSnapshotPayload(data) {
672
- const parsed = JSON.parse(data);
673
- if (!Array.isArray(parsed) || parsed.length === 0) return null;
674
- if (!parsed.every((entry) => isValidIdbDatabaseSnapshot(entry))) throw new Error("Malformed IndexedDB snapshot payload");
675
- return parsed;
676
- }
677
- function idbReq(req) {
678
- return new Promise((resolve, reject) => {
679
- req.addEventListener("success", () => resolve(req.result), { once: true });
680
- req.addEventListener("error", () => reject(toErrorObject(req.error, "Non-Error rejection")), { once: true });
681
- });
682
- }
683
- async function dumpIndexedDatabases(databasePrefix) {
684
- const idb = indexedDB;
685
- const dbList = await idb.databases();
686
- const snapshot = [];
687
- const expectedPrefix = databasePrefix ? `${databasePrefix}::` : null;
688
- for (const { name, version } of dbList) {
689
- if (!name || !version) continue;
690
- if (expectedPrefix && !name.startsWith(expectedPrefix)) continue;
691
- const db = await idbReq(idb.open(name, version));
692
- const stores = [];
693
- for (const storeName of db.objectStoreNames) {
694
- const store = db.transaction(storeName, "readonly").objectStore(storeName);
695
- const storeInfo = {
696
- name: storeName,
697
- keyPath: store.keyPath,
698
- autoIncrement: store.autoIncrement,
699
- indexes: [],
700
- records: []
701
- };
702
- for (const idxName of store.indexNames) {
703
- const idx = store.index(idxName);
704
- storeInfo.indexes.push({
705
- name: idxName,
706
- keyPath: idx.keyPath,
707
- multiEntry: idx.multiEntry,
708
- unique: idx.unique
709
- });
710
- }
711
- const keys = await idbReq(store.getAllKeys());
712
- const values = await idbReq(store.getAll());
713
- storeInfo.records = keys.map((k, i) => ({
714
- key: k,
715
- value: values[i]
716
- }));
717
- stores.push(storeInfo);
718
- }
719
- snapshot.push({
720
- name,
721
- version,
722
- stores
723
- });
724
- db.close();
725
- }
726
- return snapshot;
727
- }
728
- async function restoreIndexedDatabases(snapshot) {
729
- const idb = indexedDB;
730
- for (const dbSnap of snapshot) {
731
- const request = idb.open(dbSnap.name, dbSnap.version);
732
- request.addEventListener("upgradeneeded", () => {
733
- const db = request.result;
734
- for (const storeSnap of dbSnap.stores) {
735
- const opts = {};
736
- if (storeSnap.keyPath !== null) opts.keyPath = storeSnap.keyPath;
737
- if (storeSnap.autoIncrement) opts.autoIncrement = true;
738
- const store = db.createObjectStore(storeSnap.name, opts);
739
- for (const idx of storeSnap.indexes) store.createIndex(idx.name, idx.keyPath, {
740
- unique: idx.unique,
741
- multiEntry: idx.multiEntry
742
- });
743
- }
744
- });
745
- const db = await idbReq(request);
746
- try {
747
- for (const storeSnap of dbSnap.stores) {
748
- if (storeSnap.records.length === 0) continue;
749
- const tx = db.transaction(storeSnap.name, "readwrite");
750
- const store = tx.objectStore(storeSnap.name);
751
- for (const rec of storeSnap.records) if (storeSnap.keyPath !== null) store.put(rec.value);
752
- else store.put(rec.value, rec.key);
753
- await new Promise((resolve, reject) => {
754
- tx.addEventListener("complete", () => resolve(), { once: true });
755
- tx.addEventListener("abort", () => reject(toErrorObject(tx.error, "IndexedDB restore transaction aborted")), { once: true });
756
- });
757
- }
758
- } finally {
759
- db.close();
760
- }
761
- }
762
- }
763
- function resolveDefaultIdbSnapshotPath() {
764
- const stateDir = process.env.OPENCLAW_STATE_DIR || path.join(process.env.HOME || "/tmp", ".openclaw");
765
- return path.join(stateDir, "matrix", "crypto-idb-snapshot.json");
766
- }
767
- async function readCanonicalSnapshotJson(snapshotPath, stateRuntime) {
768
- throwIfLegacySnapshotNeedsDoctor(snapshotPath);
769
- return await readMatrixIdbSnapshotJson(path.dirname(snapshotPath), stateRuntime);
770
- }
771
- async function restoreIdbFromDisk(snapshotPath, stateRuntime) {
772
- const resolvedPath = snapshotPath ?? resolveDefaultIdbSnapshotPath();
773
- let callbackStarted = false;
774
- try {
775
- const snapshotStateRuntime = stateRuntime ?? getMatrixRuntime().state;
776
- return await withFileLock(resolvedPath, MATRIX_IDB_SNAPSHOT_LOCK_OPTIONS, async () => {
777
- callbackStarted = true;
778
- const storedSnapshotJson = await readCanonicalSnapshotJson(resolvedPath, snapshotStateRuntime);
779
- if (!storedSnapshotJson) return false;
780
- const snapshot = parseSnapshotPayload(storedSnapshotJson);
781
- if (!snapshot) return false;
782
- await restoreIndexedDatabases(snapshot);
783
- LogService.info("IdbPersistence", `Restored ${snapshot.length} IndexedDB database(s) from Matrix SQLite state`);
784
- return true;
785
- });
786
- } catch (err) {
787
- if (err instanceof MatrixIdbSnapshotMigrationRequiredError) throw err;
788
- if (!callbackStarted && fs.existsSync(resolvedPath)) throwLegacySnapshotMigrationRequired();
789
- LogService.warn("IdbPersistence", "Failed to restore IndexedDB snapshot from SQLite:", err);
790
- return false;
791
- }
792
- }
793
- async function persistIdbToDisk(params) {
794
- const snapshotPath = params?.snapshotPath ?? resolveDefaultIdbSnapshotPath();
795
- let callbackStarted = false;
796
- try {
797
- const stateRuntime = params?.stateRuntime ?? getMatrixRuntime().state;
798
- fs.mkdirSync(path.dirname(snapshotPath), { recursive: true });
799
- const persistedCount = await withFileLock(snapshotPath, MATRIX_IDB_SNAPSHOT_LOCK_OPTIONS, async () => {
800
- callbackStarted = true;
801
- const storageRootDir = path.dirname(snapshotPath);
802
- await readCanonicalSnapshotJson(snapshotPath, stateRuntime);
803
- const snapshot = await dumpIndexedDatabases(params?.databasePrefix);
804
- if (params?.abortSignal?.aborted || snapshot.length === 0) return 0;
805
- await writeMatrixIdbSnapshotJson({
806
- storageRootDir,
807
- snapshotJson: JSON.stringify(snapshot),
808
- databaseCount: snapshot.length,
809
- stateRuntime
810
- });
811
- return snapshot.length;
812
- });
813
- if (persistedCount === 0) return;
814
- LogService.debug("IdbPersistence", `Persisted ${persistedCount} IndexedDB database(s) to Matrix SQLite state`);
815
- } catch (err) {
816
- if (err instanceof MatrixIdbSnapshotMigrationRequiredError) throw err;
817
- if (!callbackStarted && fs.existsSync(snapshotPath)) throwLegacySnapshotMigrationRequired();
818
- LogService.warn("IdbPersistence", "Failed to persist IndexedDB snapshot:", err);
819
- if (params?.strict) throw err;
820
- }
821
- }
822
- function throwIfLegacySnapshotNeedsDoctor(snapshotPath) {
823
- if (fs.existsSync(snapshotPath)) throwLegacySnapshotMigrationRequired();
824
- }
825
- function throwLegacySnapshotMigrationRequired() {
826
- LogService.warn("IdbPersistence", LEGACY_SNAPSHOT_DIAGNOSTIC);
827
- throw new MatrixIdbSnapshotMigrationRequiredError();
828
- }
829
- //#endregion
830
610
  //#region extensions/matrix/src/matrix/sdk/verification-manager.ts
831
611
  const MAX_TRACKED_VERIFICATION_SESSIONS = 256;
832
612
  const TERMINAL_SESSION_RETENTION_MS = 864e5;
@@ -846,23 +626,11 @@ var MatrixVerificationManager = class {
846
626
  return fallback;
847
627
  }
848
628
  }
849
- readVerificationRequestIdentity(request) {
850
- return {
851
- transactionId: this.readRequestValue(() => request.transactionId?.trim() ?? "", ""),
852
- roomId: this.readRequestValue(() => request.roomId ?? "", ""),
853
- otherUserId: this.readRequestValue(() => request.otherUserId, ""),
854
- otherDeviceId: this.readRequestValue(() => request.otherDeviceId ?? "", ""),
855
- isSelfVerification: this.readRequestValue(() => request.isSelfVerification, false),
856
- initiatedByMe: this.readRequestValue(() => request.initiatedByMe, false)
857
- };
858
- }
859
629
  isSameLogicalVerificationRequest(left, right) {
860
- const leftIdentity = this.readVerificationRequestIdentity(left);
861
- const rightIdentity = this.readVerificationRequestIdentity(right);
862
- return leftIdentity.transactionId !== "" && leftIdentity.transactionId === rightIdentity.transactionId && leftIdentity.roomId === rightIdentity.roomId && leftIdentity.otherUserId === rightIdentity.otherUserId && this.isSameOptionalIdentityValue(leftIdentity.otherDeviceId, rightIdentity.otherDeviceId) && leftIdentity.isSelfVerification === rightIdentity.isSelfVerification && leftIdentity.initiatedByMe === rightIdentity.initiatedByMe;
863
- }
864
- isSameOptionalIdentityValue(left, right) {
865
- return left === "" || right === "" || left === right;
630
+ const transactionId = left.transactionId?.trim();
631
+ const leftDeviceId = left.otherDeviceId;
632
+ const rightDeviceId = right.otherDeviceId;
633
+ return Boolean(transactionId) && transactionId === right.transactionId?.trim() && (left.roomId ?? "") === (right.roomId ?? "") && left.otherUserId === right.otherUserId && (!leftDeviceId || !rightDeviceId || leftDeviceId === rightDeviceId) && left.isSelfVerification === right.isSelfVerification && left.initiatedByMe === right.initiatedByMe;
866
634
  }
867
635
  pruneVerificationSessions(nowMs) {
868
636
  for (const [id, session] of this.verificationSessions) {
@@ -879,7 +647,7 @@ var MatrixVerificationManager = class {
879
647
  this.opts.onSummaryChanged?.(summary);
880
648
  }
881
649
  touchVerificationSession(session) {
882
- session.updatedAtMs = resolveDateTimestampMs(Date.now());
650
+ session.updatedAtMs = Date.now();
883
651
  this.emitVerificationSummary(session);
884
652
  }
885
653
  observeVerificationOperation(session, operation, onError) {
@@ -897,8 +665,8 @@ var MatrixVerificationManager = class {
897
665
  buildVerificationSummary(session) {
898
666
  const request = session.request;
899
667
  const phase = this.readRequestValue(() => request.phase, VerificationPhase.Requested);
900
- const accepting = this.readRequestValue(() => request.accepting, false);
901
- const declining = this.readRequestValue(() => request.declining, false);
668
+ const accepting = request.accepting;
669
+ const declining = request.declining;
902
670
  const pending = this.readRequestValue(() => request.pending, false);
903
671
  const methods = this.readRequestValue(() => request.methods, []).slice();
904
672
  const sasCallbacks = session.sasCallbacks ?? session.activeVerifier?.getShowSasCallbacks();
@@ -906,12 +674,12 @@ var MatrixVerificationManager = class {
906
674
  const canAccept = phase < VerificationPhase.Ready && !accepting && !declining;
907
675
  return {
908
676
  id: session.id,
909
- transactionId: this.readRequestValue(() => request.transactionId, void 0),
910
- roomId: this.readRequestValue(() => request.roomId, void 0),
911
- otherUserId: this.readRequestValue(() => request.otherUserId, "unknown"),
912
- otherDeviceId: this.readRequestValue(() => request.otherDeviceId, void 0),
913
- isSelfVerification: this.readRequestValue(() => request.isSelfVerification, false),
914
- initiatedByMe: this.readRequestValue(() => request.initiatedByMe, false),
677
+ transactionId: request.transactionId,
678
+ roomId: request.roomId,
679
+ otherUserId: request.otherUserId,
680
+ otherDeviceId: request.otherDeviceId,
681
+ isSelfVerification: request.isSelfVerification,
682
+ initiatedByMe: request.initiatedByMe,
915
683
  phase,
916
684
  phaseName: VerificationPhase[phase]?.toLowerCase() ?? `unknown(${phase})`,
917
685
  pending,
@@ -926,15 +694,15 @@ var MatrixVerificationManager = class {
926
694
  hasReciprocateQr: Boolean(session.reciprocateQrCallbacks),
927
695
  completed: phase === VerificationPhase.Done,
928
696
  error: session.error,
929
- createdAt: resolveTimestampMsToIsoString(session.createdAtMs),
930
- updatedAt: resolveTimestampMsToIsoString(session.updatedAtMs)
697
+ createdAt: new Date(session.createdAtMs).toISOString(),
698
+ updatedAt: new Date(session.updatedAtMs).toISOString()
931
699
  };
932
700
  }
933
701
  findVerificationSession(id) {
934
702
  const direct = this.verificationSessions.get(id);
935
703
  if (direct) return direct;
936
704
  const transactionMatches = Array.from(this.verificationSessions.values()).filter((session) => {
937
- return this.readRequestValue(() => session.request.transactionId?.trim(), "") === id;
705
+ return session.request.transactionId?.trim() === id;
938
706
  });
939
707
  if (transactionMatches.length === 1) return expectDefined(transactionMatches[0], "single Matrix verification session");
940
708
  if (transactionMatches.length > 1) throw new Error(`Matrix verification request id is ambiguous for transaction ${id}; use the verification id instead`);
@@ -954,11 +722,11 @@ var MatrixVerificationManager = class {
954
722
  maybeAutoAcceptInboundRequest(session) {
955
723
  if (session.acceptRequested) return;
956
724
  const request = session.request;
957
- const isSelfVerification = this.readRequestValue(() => request.isSelfVerification, false);
958
- const initiatedByMe = this.readRequestValue(() => request.initiatedByMe, false);
725
+ const isSelfVerification = request.isSelfVerification;
726
+ const initiatedByMe = request.initiatedByMe;
959
727
  const phase = this.readRequestValue(() => request.phase, VerificationPhase.Requested);
960
- const accepting = this.readRequestValue(() => request.accepting, false);
961
- const declining = this.readRequestValue(() => request.declining, false);
728
+ const accepting = request.accepting;
729
+ const declining = request.declining;
962
730
  if (isSelfVerification || initiatedByMe) return;
963
731
  if (phase !== VerificationPhase.Requested || accepting || declining) return;
964
732
  session.acceptRequested = true;
@@ -968,8 +736,8 @@ var MatrixVerificationManager = class {
968
736
  }
969
737
  maybeAutoStartInboundSas(session) {
970
738
  if (session.activeVerifier || session.verifyStarted || session.startRequested) return;
971
- if (this.readRequestValue(() => session.request.initiatedByMe, true)) return;
972
- if (!this.readRequestValue(() => session.request.isSelfVerification, false)) return;
739
+ if (session.request.initiatedByMe) return;
740
+ if (!session.request.isSelfVerification) return;
973
741
  const phase = this.readRequestValue(() => session.request.phase, VerificationPhase.Requested);
974
742
  if (phase < VerificationPhase.Ready || phase >= VerificationPhase.Cancelled) return;
975
743
  const methods = this.readRequestValue(() => session.request.methods, []);
@@ -1021,7 +789,7 @@ var MatrixVerificationManager = class {
1021
789
  }
1022
790
  maybeAutoConfirmSas(session) {
1023
791
  if (session.sasAutoConfirmStarted || session.sasAutoConfirmTimer) return;
1024
- if (this.readRequestValue(() => session.request.initiatedByMe, true)) return;
792
+ if (session.request.initiatedByMe) return;
1025
793
  const callbacks = session.sasCallbacks ?? session.activeVerifier?.getShowSasCallbacks();
1026
794
  if (!callbacks) return;
1027
795
  session.sasCallbacks = callbacks;
@@ -1042,8 +810,8 @@ var MatrixVerificationManager = class {
1042
810
  session.verifyPromise = this.observeVerificationOperation(session, session.activeVerifier.verify());
1043
811
  }
1044
812
  async trustOwnDeviceAfterConfirmedSas(session) {
1045
- if (!this.readRequestValue(() => session.request.isSelfVerification, false)) return;
1046
- const deviceId = this.readRequestValue(() => session.request.otherDeviceId?.trim(), "");
813
+ if (!session.request.isSelfVerification) return;
814
+ const deviceId = session.request.otherDeviceId?.trim();
1047
815
  if (!deviceId || !this.opts.trustOwnDeviceAfterSas) return;
1048
816
  await this.opts.trustOwnDeviceAfterSas(deviceId);
1049
817
  }
@@ -1054,7 +822,7 @@ var MatrixVerificationManager = class {
1054
822
  this.touchVerificationSession(existing);
1055
823
  return this.buildVerificationSummary(existing);
1056
824
  }
1057
- if (this.readVerificationRequestIdentity(request).transactionId) {
825
+ if (request.transactionId?.trim()) {
1058
826
  for (const existing of this.verificationSessions.values()) if (this.isSameLogicalVerificationRequest(existing.request, request)) {
1059
827
  existing.request = request;
1060
828
  this.ensureVerificationRequestTracked(existing);
@@ -1063,7 +831,7 @@ var MatrixVerificationManager = class {
1063
831
  return this.buildVerificationSummary(existing);
1064
832
  }
1065
833
  }
1066
- const now = resolveDateTimestampMs(Date.now());
834
+ const now = Date.now();
1067
835
  const session = {
1068
836
  id: `verification-${++this.verificationSessionCounter}`,
1069
837
  request,
@@ -1131,10 +899,8 @@ var MatrixVerificationManager = class {
1131
899
  }
1132
900
  async confirmVerificationSas(id) {
1133
901
  const session = this.findVerificationSession(id);
1134
- const callbacks = session.sasCallbacks ?? session.activeVerifier?.getShowSasCallbacks();
1135
- if (!callbacks) throw new Error("Matrix SAS confirmation is not available for this verification request");
902
+ const callbacks = this.requireSasCallbacks(session, "confirmation");
1136
903
  this.clearSasAutoConfirmTimer(session);
1137
- session.sasCallbacks = callbacks;
1138
904
  session.sasAutoConfirmStarted = true;
1139
905
  await this.confirmSasForSession(session, callbacks);
1140
906
  await session.verifyPromise;
@@ -1143,10 +909,8 @@ var MatrixVerificationManager = class {
1143
909
  }
1144
910
  mismatchVerificationSas(id) {
1145
911
  const session = this.findVerificationSession(id);
1146
- const callbacks = session.sasCallbacks ?? session.activeVerifier?.getShowSasCallbacks();
1147
- if (!callbacks) throw new Error("Matrix SAS mismatch is not available for this verification request");
912
+ const callbacks = this.requireSasCallbacks(session, "mismatch");
1148
913
  this.clearSasAutoConfirmTimer(session);
1149
- session.sasCallbacks = callbacks;
1150
914
  callbacks.mismatch();
1151
915
  this.touchVerificationSession(session);
1152
916
  return this.buildVerificationSummary(session);
@@ -1162,17 +926,131 @@ var MatrixVerificationManager = class {
1162
926
  }
1163
927
  getVerificationSas(id) {
1164
928
  const session = this.findVerificationSession(id);
1165
- const callbacks = session.sasCallbacks ?? session.activeVerifier?.getShowSasCallbacks();
1166
- if (!callbacks) throw new Error("Matrix SAS data is not available for this verification request");
1167
- session.sasCallbacks = callbacks;
929
+ const callbacks = this.requireSasCallbacks(session, "data");
1168
930
  return {
1169
931
  decimal: callbacks.sas.decimal,
1170
932
  emoji: callbacks.sas.emoji
1171
933
  };
1172
934
  }
935
+ requireSasCallbacks(session, operation) {
936
+ const callbacks = session.sasCallbacks ?? session.activeVerifier?.getShowSasCallbacks();
937
+ if (!callbacks) throw new Error(`Matrix SAS ${operation} is not available for this verification request`);
938
+ session.sasCallbacks = callbacks;
939
+ return callbacks;
940
+ }
1173
941
  };
1174
942
  //#endregion
943
+ //#region extensions/matrix/src/matrix/sdk/indexeddb-session.ts
944
+ const registry = resolveGlobalSingleton(Symbol.for("openclaw.matrix.sdkIndexedDbSessions"), () => ({ sessions: /* @__PURE__ */ new Map() }));
945
+ const sessions = registry.sessions;
946
+ function retiredError() {
947
+ return new DOMException("Matrix crypto IndexedDB generation has retired", "InvalidStateError");
948
+ }
949
+ function trackTransaction(session, transaction) {
950
+ let settle;
951
+ const pending = new Promise((resolve) => {
952
+ settle = resolve;
953
+ });
954
+ session.transactions.add(pending);
955
+ const complete = () => {
956
+ session.transactions.delete(pending);
957
+ settle();
958
+ };
959
+ transaction.addEventListener("complete", complete, { once: true });
960
+ transaction.addEventListener("abort", complete, { once: true });
961
+ }
962
+ function admitConnection(session, database) {
963
+ if (session.connections.has(database)) return;
964
+ session.connections.add(database);
965
+ const transaction = database.transaction.bind(database);
966
+ database.transaction = (...args) => {
967
+ if (session.state !== "active") throw retiredError();
968
+ const result = transaction(...args);
969
+ trackTransaction(session, result);
970
+ return result;
971
+ };
972
+ }
973
+ function openForSession(factory, session, name, version) {
974
+ if (session.state !== "active") throw retiredError();
975
+ const request = factory.open(name, version);
976
+ let settle;
977
+ const pending = new Promise((resolve) => {
978
+ settle = resolve;
979
+ });
980
+ session.pendingOpens.add(pending);
981
+ const complete = () => {
982
+ session.pendingOpens.delete(pending);
983
+ settle();
984
+ };
985
+ request.addEventListener("upgradeneeded", () => {
986
+ admitConnection(session, request.result);
987
+ if (session.state !== "active") request.transaction?.abort();
988
+ else if (request.transaction) trackTransaction(session, request.transaction);
989
+ });
990
+ request.addEventListener("success", () => {
991
+ try {
992
+ admitConnection(session, request.result);
993
+ if (session.state !== "active") request.result.close();
994
+ } catch (error) {
995
+ session.failure = { error };
996
+ session.state = "failed";
997
+ } finally {
998
+ complete();
999
+ }
1000
+ }, { once: true });
1001
+ request.addEventListener("error", complete, { once: true });
1002
+ return request;
1003
+ }
1004
+ function installSdkFactory() {
1005
+ if (registry.factory) return;
1006
+ const factory = globalThis.indexedDB;
1007
+ registry.factory = new Proxy(factory, { get(target, key) {
1008
+ if (key === "open") return (name, version) => {
1009
+ const session = sessions.get(name);
1010
+ return session ? openForSession(target, session, name, version) : target.open(name, version);
1011
+ };
1012
+ const value = Reflect.get(target, key, target);
1013
+ return typeof value === "function" ? value.bind(target) : value;
1014
+ } });
1015
+ globalThis.indexedDB = registry.factory;
1016
+ }
1017
+ /** Own SDK connections through stop; the physical store lock owns publication. */
1018
+ function beginMatrixSdkIndexedDbSession(databasePrefix = "matrix-js-sdk") {
1019
+ installSdkFactory();
1020
+ const names = [`${databasePrefix}::matrix-sdk-crypto`, `${databasePrefix}::matrix-sdk-crypto-meta`];
1021
+ if (names.some((name) => {
1022
+ const previous = sessions.get(name);
1023
+ return previous && previous.state !== "retired";
1024
+ })) throw new Error("Matrix SDK IndexedDB generation is still active or failed retirement");
1025
+ const session = {
1026
+ state: "active",
1027
+ connections: /* @__PURE__ */ new Set(),
1028
+ pendingOpens: /* @__PURE__ */ new Set(),
1029
+ transactions: /* @__PURE__ */ new Set()
1030
+ };
1031
+ for (const name of names) sessions.set(name, session);
1032
+ let retirement;
1033
+ return { retire: () => {
1034
+ retirement ??= (async () => {
1035
+ session.state = "retiring";
1036
+ try {
1037
+ for (const connection of session.connections) connection.close();
1038
+ await Promise.all(session.pendingOpens);
1039
+ for (const connection of session.connections) connection.close();
1040
+ await Promise.all(session.transactions);
1041
+ if (session.failure) throw session.failure.error;
1042
+ session.state = "retired";
1043
+ session.connections.clear();
1044
+ } catch (error) {
1045
+ session.state = "failed";
1046
+ throw error;
1047
+ }
1048
+ })();
1049
+ return retirement;
1050
+ } };
1051
+ }
1052
+ //#endregion
1175
1053
  //#region extensions/matrix/src/matrix/sdk/crypto-runtime.ts
1176
1054
  installFakeIndexedDbTransactionPruner();
1177
1055
  //#endregion
1178
- export { MatrixCryptoBootstrapper, MatrixDecryptBridge, MatrixVerificationManager, createMatrixCryptoFacade, isMatrixDeviceOwnerVerified, isMatrixDeviceVerifiedInCurrentClient, persistIdbToDisk, restoreIdbFromDisk };
1056
+ export { MatrixCryptoBootstrapper, MatrixDecryptBridge, MatrixVerificationManager, beginMatrixSdkIndexedDbSession, createMatrixCryptoFacade, isMatrixDeviceOwnerVerified, isMatrixDeviceVerifiedInCurrentClient, persistIdbToDisk, resolveDefaultIdbSnapshotPath, restoreIdbFromDisk };