@openclaw/matrix 2026.9.8 → 2026.10.1-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 (278) hide show
  1. package/dist/.setup/{account-selection-B7axQ80R.mjs → account-selection-BDeeqwwR.mjs} +1 -1
  2. package/dist/.setup/{accounts-WkgrIxMt.mjs → accounts-C_r0UlEm.mjs} +2 -2
  3. package/dist/.setup/{approval-handler.runtime-C-pw3NvY.mjs → approval-handler.runtime-QkHLH2az.mjs} +14 -19
  4. package/dist/.setup/{approval-reactions-BrS5ECU0.mjs → approval-reactions-DhB6gNPU.mjs} +11 -25
  5. package/dist/.setup/{channel-DXenXmj0.mjs → channel-CeRXEAEP.mjs} +17 -46
  6. package/dist/.setup/{channel.runtime-BXUawOno.mjs → channel.runtime-DBQA2y1F.mjs} +6 -6
  7. package/dist/.setup/{channel.setup-DWfLaXqT.mjs → channel.setup-DC2t7_PK.mjs} +12 -26
  8. package/dist/.setup/{cli-IhZO2OEj.mjs → cli-Be8tdNw8.mjs} +24 -45
  9. package/dist/.setup/{cli-metadata-nowEgdY0.mjs → cli-metadata-CtcjBFhc.mjs} +1 -1
  10. package/dist/.setup/{client-BXATebyo.mjs → client-DY3HExqI.mjs} +3 -3
  11. package/dist/.setup/{client-bootstrap-BiHX55is.mjs → client-bootstrap-CZvJjr29.mjs} +1 -1
  12. package/dist/.setup/{client-Ccv77kwh.mjs → client-kmih04ng.mjs} +21 -40
  13. package/dist/.setup/{client-support-Bn9Bk0-H.mjs → client-support-D7BlioUb.mjs} +14 -23
  14. package/dist/.setup/{config-update-5m1Un5gJ.mjs → config-update-CZndPxNd.mjs} +29 -72
  15. package/dist/.setup/{create-client-DRZ580E3.mjs → create-client-CbJVyFDy.mjs} +5 -5
  16. package/dist/.setup/{credentials-C9qDO5-2.mjs → credentials-C2dvc_kB.mjs} +1 -1
  17. package/dist/.setup/{credentials-read-KD4o5biZ.mjs → credentials-read-CqRiEAQa.mjs} +1 -1
  18. package/dist/.setup/{crypto-runtime-DPjIDF8H.mjs → crypto-runtime-B2AjWo-i.mjs} +223 -79
  19. package/dist/.setup/{deps-CLQ4EOq7.mjs → deps-CFNl7tQo.mjs} +14 -39
  20. package/dist/.setup/{device-health-U-yoVjPw.mjs → device-health-Be60VF1w.mjs} +1 -1
  21. package/dist/.setup/{direct-management-Cn2t8n1V.mjs → direct-management-DJtQhLKH.mjs} +4 -8
  22. package/dist/.setup/{directory-live-_sw-Q7KO.mjs → directory-live-DW5UykLL.mjs} +3 -3
  23. package/dist/.setup/{doctor-contract-De6geW0h.mjs → doctor-contract-CsTNmbMa.mjs} +10 -133
  24. package/dist/.setup/{draft-stream-CdVMstpR.mjs → draft-stream-B87DfA6a.mjs} +4 -8
  25. package/dist/.setup/{encryption-guidance-B6797jNA.mjs → encryption-guidance-BEjKbiMR.mjs} +1 -1
  26. package/dist/.setup/{exec-approvals-fsiMQ1ce.mjs → exec-approvals-BLDAMyHs.mjs} +6 -19
  27. package/dist/.setup/{file-sync-store-B-9bMb_O.mjs → file-sync-store-Clc9iEdn.mjs} +3 -3
  28. package/dist/.setup/{http-client-C1XvVD3K.mjs → http-client-DfJY5Ck0.mjs} +8 -29
  29. package/dist/.setup/{inbound-dedupe-BGrMrTTu.mjs → inbound-dedupe-C-EBGY0B.mjs} +1 -1
  30. package/dist/.setup/{joined-room-encryption-TZoOKXgh.mjs → joined-room-encryption-BAD70N5n.mjs} +1 -1
  31. package/dist/.setup/logger-CXQnpXCt.mjs +44 -0
  32. package/dist/.setup/{logging-mhnFQGzB.mjs → logging-BKV8TYQq.mjs} +7 -32
  33. package/dist/.setup/{messages-Buz27pi5.mjs → messages-uCbwLRKS.mjs} +5 -8
  34. package/dist/.setup/{monitor-BBg5qgov.mjs → monitor-skIntQVG.mjs} +109 -180
  35. package/dist/.setup/{onboarding-hJaieQj5.mjs → onboarding-Cm_tOJxs.mjs} +12 -19
  36. package/dist/.setup/{outbound-C9vBijaH.mjs → outbound-CqQou3ny.mjs} +16 -22
  37. package/dist/.setup/{profile-B3DD2jYa.mjs → profile-DS0xdJAi.mjs} +11 -31
  38. package/dist/.setup/{profile-update-CmxIAd4c.mjs → profile-update-C1n8SRqH.mjs} +3 -3
  39. package/dist/.setup/{reaction-events-mnzc_JvP.mjs → reaction-events-Cqq46xsG.mjs} +5 -5
  40. package/dist/.setup/{resolve-targets-BFq3q4c9.mjs → resolve-targets-DFeU1Ww6.mjs} +2 -2
  41. package/dist/.setup/retired-state-BXUQ2I-C.mjs +91 -0
  42. package/dist/.setup/{room-info-BbTGRJcR.mjs → room-info-BPMbwe8I.mjs} +33 -50
  43. package/dist/.setup/{sdk-DmRVM0VA.mjs → sdk-CgQGkCsS.mjs} +226 -182
  44. package/dist/.setup/{send-GOF64QRc.mjs → send-B1Y2L4wj.mjs} +19 -68
  45. package/dist/.setup/{setup-bootstrap-AzalcuCW.mjs → setup-bootstrap-UNIGyKnk.mjs} +2 -2
  46. package/dist/.setup/{setup-core-BeifoeL4.mjs → setup-core-6DppLENo.mjs} +5 -5
  47. package/dist/.setup/{setup-plugin-api-Bsbdw41x.mjs → setup-plugin-api-BRs9bcp4.mjs} +1 -1
  48. package/dist/.setup/startup-verification-D00eUt74.mjs +122 -0
  49. package/dist/.setup/storage-D7agewjH.mjs +464 -0
  50. package/dist/.setup/{sync-cache-state-C6sEmvJK.mjs → sync-cache-state-C2z64uyk.mjs} +10 -24
  51. package/dist/.setup/{thread-bindings-jXu_9cHE.mjs → thread-bindings-DveHVZqN.mjs} +13 -71
  52. package/dist/.setup/{tool-actions-Ce7Okg6m.mjs → tool-actions-BqlK2ilM.mjs} +51 -73
  53. package/dist/.setup/{verification-C45rOZkM.mjs → verification-kMlFYUn0.mjs} +10 -27
  54. package/dist/api.js +5 -5
  55. package/dist/channel-plugin-api.js +1 -1
  56. package/dist/cli-metadata.js +1 -1
  57. package/dist/contract-api.js +2 -2
  58. package/dist/doctor-contract-api.js +48 -201
  59. package/dist/helper-api.js +1 -1
  60. package/dist/index.js +1 -1
  61. package/dist/plugin-entry.handlers.runtime.js +1 -1
  62. package/dist/runtime-api.js +3 -3
  63. package/dist/session-binding-contract-api.js +1 -1
  64. package/dist/setup-entry.js +1 -1
  65. package/dist/setup-plugin-api.js +1 -1
  66. package/node_modules/@openclaw/fs-safe/CHANGELOG.md +95 -0
  67. package/node_modules/@openclaw/fs-safe/README.md +70 -379
  68. package/node_modules/@openclaw/fs-safe/dist/absolute-path.js +35 -51
  69. package/node_modules/@openclaw/fs-safe/dist/advanced.d.ts +2 -0
  70. package/node_modules/@openclaw/fs-safe/dist/advanced.js +1 -0
  71. package/node_modules/@openclaw/fs-safe/dist/archive-input.js +2 -0
  72. package/node_modules/@openclaw/fs-safe/dist/archive-parser.wasm +0 -0
  73. package/node_modules/@openclaw/fs-safe/dist/archive-staging.d.ts +1 -1
  74. package/node_modules/@openclaw/fs-safe/dist/archive-staging.js +9 -10
  75. package/node_modules/@openclaw/fs-safe/dist/archive.js +2 -5
  76. package/node_modules/@openclaw/fs-safe/dist/atomic-io.d.ts +51 -0
  77. package/node_modules/@openclaw/fs-safe/dist/atomic-io.js +242 -0
  78. package/node_modules/@openclaw/fs-safe/dist/config.d.ts +1 -1
  79. package/node_modules/@openclaw/fs-safe/dist/config.js +1 -1
  80. package/node_modules/@openclaw/fs-safe/dist/copy-file-input.d.ts +1 -1
  81. package/node_modules/@openclaw/fs-safe/dist/copy-file-input.js +2 -2
  82. package/node_modules/@openclaw/fs-safe/dist/copy-tree-portable.js +2 -0
  83. package/node_modules/@openclaw/fs-safe/dist/create.js +12 -5
  84. package/node_modules/@openclaw/fs-safe/dist/directory-guard.d.ts +11 -0
  85. package/node_modules/@openclaw/fs-safe/dist/directory-guard.js +4 -7
  86. package/node_modules/@openclaw/fs-safe/dist/entry-publication-types.d.ts +55 -0
  87. package/node_modules/@openclaw/fs-safe/dist/entry-publication-types.js +1 -0
  88. package/node_modules/@openclaw/fs-safe/dist/entry-publication.d.ts +8 -0
  89. package/node_modules/@openclaw/fs-safe/dist/entry-publication.js +262 -0
  90. package/node_modules/@openclaw/fs-safe/dist/exclusive-create.d.ts +3 -0
  91. package/node_modules/@openclaw/fs-safe/dist/exclusive-create.js +22 -0
  92. package/node_modules/@openclaw/fs-safe/dist/file-cleanup.d.ts +1 -6
  93. package/node_modules/@openclaw/fs-safe/dist/file-cleanup.js +3 -6
  94. package/node_modules/@openclaw/fs-safe/dist/file-identity.js +3 -6
  95. package/node_modules/@openclaw/fs-safe/dist/file-lock-sync-root-io.js +2 -2
  96. package/node_modules/@openclaw/fs-safe/dist/file-lock-sync-root-mutation.js +9 -0
  97. package/node_modules/@openclaw/fs-safe/dist/file-lock-sync-root.js +4 -6
  98. package/node_modules/@openclaw/fs-safe/dist/file-lock-sync-stale-admission.js +1 -1
  99. package/node_modules/@openclaw/fs-safe/dist/file-lock-sync.js +8 -0
  100. package/node_modules/@openclaw/fs-safe/dist/file-store-boundary.js +2 -0
  101. package/node_modules/@openclaw/fs-safe/dist/file-store-sync-write.js +20 -18
  102. package/node_modules/@openclaw/fs-safe/dist/file-store.js +4 -10
  103. package/node_modules/@openclaw/fs-safe/dist/fs.d.ts +2 -10
  104. package/node_modules/@openclaw/fs-safe/dist/fs.js +2 -10
  105. package/node_modules/@openclaw/fs-safe/dist/guarded-mkdir.d.ts +3 -4
  106. package/node_modules/@openclaw/fs-safe/dist/guarded-mkdir.js +6 -18
  107. package/node_modules/@openclaw/fs-safe/dist/guest-dispatch-python.js +1 -1
  108. package/node_modules/@openclaw/fs-safe/dist/guest-native-python.js +0 -2
  109. package/node_modules/@openclaw/fs-safe/dist/guest.js +3 -9
  110. package/node_modules/@openclaw/fs-safe/dist/index.d.ts +1 -1
  111. package/node_modules/@openclaw/fs-safe/dist/index.js +1 -1
  112. package/node_modules/@openclaw/fs-safe/dist/json-durable-queue-directory.js +1 -5
  113. package/node_modules/@openclaw/fs-safe/dist/json.js +19 -37
  114. package/node_modules/@openclaw/fs-safe/dist/move-path.js +2 -0
  115. package/node_modules/@openclaw/fs-safe/dist/mutation-authority.d.ts +1 -0
  116. package/node_modules/@openclaw/fs-safe/dist/mutation-authority.js +9 -1
  117. package/node_modules/@openclaw/fs-safe/dist/native-binding.d.ts +47 -2
  118. package/node_modules/@openclaw/fs-safe/dist/native-config.d.ts +1 -9
  119. package/node_modules/@openclaw/fs-safe/dist/native-config.js +6 -40
  120. package/node_modules/@openclaw/fs-safe/dist/native-parent-admission.d.ts +2 -0
  121. package/node_modules/@openclaw/fs-safe/dist/native-parent-admission.js +5 -2
  122. package/node_modules/@openclaw/fs-safe/dist/native-pinned-write.js +11 -316
  123. package/node_modules/@openclaw/fs-safe/dist/native-policy-parent-windows.d.ts +7 -7
  124. package/node_modules/@openclaw/fs-safe/dist/native-policy-parent-windows.js +28 -175
  125. package/node_modules/@openclaw/fs-safe/dist/native-policy-parent.d.ts +15 -0
  126. package/node_modules/@openclaw/fs-safe/dist/native-policy-parent.js +418 -0
  127. package/node_modules/@openclaw/fs-safe/dist/native-rename-outcome.js +9 -4
  128. package/node_modules/@openclaw/fs-safe/dist/native-staged-file.js +17 -13
  129. package/node_modules/@openclaw/fs-safe/dist/native-staged-symlink.js +6 -24
  130. package/node_modules/@openclaw/fs-safe/dist/native.js +5 -1
  131. package/node_modules/@openclaw/fs-safe/dist/path-case.js +10 -9
  132. package/node_modules/@openclaw/fs-safe/dist/path-scope-lexical.js +4 -1
  133. package/node_modules/@openclaw/fs-safe/dist/path-segment-route.d.ts +1 -0
  134. package/node_modules/@openclaw/fs-safe/dist/path-segment-route.js +3 -0
  135. package/node_modules/@openclaw/fs-safe/dist/path.js +4 -1
  136. package/node_modules/@openclaw/fs-safe/dist/permissions-windows.d.ts +0 -1
  137. package/node_modules/@openclaw/fs-safe/dist/pinned-mutation-admission.js +1 -3
  138. package/node_modules/@openclaw/fs-safe/dist/pinned-write-staged.js +2 -0
  139. package/node_modules/@openclaw/fs-safe/dist/pinned-write.js +9 -10
  140. package/node_modules/@openclaw/fs-safe/dist/private-producer-handoff.js +3 -6
  141. package/node_modules/@openclaw/fs-safe/dist/publish-copy-stage.js +2 -2
  142. package/node_modules/@openclaw/fs-safe/dist/publish-file.js +4 -3
  143. package/node_modules/@openclaw/fs-safe/dist/replace-file-buffer.d.ts +3 -4
  144. package/node_modules/@openclaw/fs-safe/dist/replace-file-buffer.js +18 -32
  145. package/node_modules/@openclaw/fs-safe/dist/replace-file-copy-fallback.d.ts +5 -17
  146. package/node_modules/@openclaw/fs-safe/dist/replace-file-copy-fallback.js +92 -230
  147. package/node_modules/@openclaw/fs-safe/dist/replace-file-copy-source.d.ts +4 -15
  148. package/node_modules/@openclaw/fs-safe/dist/replace-file-copy-source.js +22 -63
  149. package/node_modules/@openclaw/fs-safe/dist/replace-file-descriptor.d.ts +9 -34
  150. package/node_modules/@openclaw/fs-safe/dist/replace-file-descriptor.js +78 -83
  151. package/node_modules/@openclaw/fs-safe/dist/replace-file-destination.d.ts +18 -20
  152. package/node_modules/@openclaw/fs-safe/dist/replace-file-destination.js +64 -98
  153. package/node_modules/@openclaw/fs-safe/dist/replace-file-temp-owner.d.ts +16 -33
  154. package/node_modules/@openclaw/fs-safe/dist/replace-file-temp-owner.js +61 -200
  155. package/node_modules/@openclaw/fs-safe/dist/replace-file-types.d.ts +1 -6
  156. package/node_modules/@openclaw/fs-safe/dist/replace-file.js +76 -216
  157. package/node_modules/@openclaw/fs-safe/dist/root-boundary.js +14 -24
  158. package/node_modules/@openclaw/fs-safe/dist/root-context.d.ts +1 -4
  159. package/node_modules/@openclaw/fs-safe/dist/root-context.js +4 -19
  160. package/node_modules/@openclaw/fs-safe/dist/root-create-native.d.ts +52 -0
  161. package/node_modules/@openclaw/fs-safe/dist/root-create-native.js +350 -0
  162. package/node_modules/@openclaw/fs-safe/dist/root-directory-list-types.d.ts +35 -0
  163. package/node_modules/@openclaw/fs-safe/dist/root-directory-list-types.js +1 -0
  164. package/node_modules/@openclaw/fs-safe/dist/root-directory-list.d.ts +2 -27
  165. package/node_modules/@openclaw/fs-safe/dist/root-directory-list.js +31 -28
  166. package/node_modules/@openclaw/fs-safe/dist/root-directory.js +1 -4
  167. package/node_modules/@openclaw/fs-safe/dist/root-errors.js +34 -0
  168. package/node_modules/@openclaw/fs-safe/dist/root-file.js +9 -21
  169. package/node_modules/@openclaw/fs-safe/dist/root-impl.js +105 -37
  170. package/node_modules/@openclaw/fs-safe/dist/root-move-noreplace.d.ts +7 -2
  171. package/node_modules/@openclaw/fs-safe/dist/root-move-noreplace.js +67 -38
  172. package/node_modules/@openclaw/fs-safe/dist/root-observed-path.d.ts +1 -1
  173. package/node_modules/@openclaw/fs-safe/dist/root-observed-path.js +0 -2
  174. package/node_modules/@openclaw/fs-safe/dist/root-options.d.ts +2 -3
  175. package/node_modules/@openclaw/fs-safe/dist/root-path-existing.js +3 -1
  176. package/node_modules/@openclaw/fs-safe/dist/root-path-stat.js +68 -85
  177. package/node_modules/@openclaw/fs-safe/dist/root-path.js +6 -1
  178. package/node_modules/@openclaw/fs-safe/dist/root-paths-lexical.d.ts +4 -0
  179. package/node_modules/@openclaw/fs-safe/dist/root-paths-lexical.js +1 -1
  180. package/node_modules/@openclaw/fs-safe/dist/root-paths.js +4 -9
  181. package/node_modules/@openclaw/fs-safe/dist/root-remove-native.d.ts +4 -0
  182. package/node_modules/@openclaw/fs-safe/dist/root-remove-native.js +311 -0
  183. package/node_modules/@openclaw/fs-safe/dist/root-remove.d.ts +11 -0
  184. package/node_modules/@openclaw/fs-safe/dist/root-remove.js +3 -1
  185. package/node_modules/@openclaw/fs-safe/dist/root-walk.d.ts +2 -2
  186. package/node_modules/@openclaw/fs-safe/dist/root-walk.js +1 -3
  187. package/node_modules/@openclaw/fs-safe/dist/root-write-admission.d.ts +3 -3
  188. package/node_modules/@openclaw/fs-safe/dist/root-write-admission.js +8 -10
  189. package/node_modules/@openclaw/fs-safe/dist/safe-path-segment.d.ts +0 -1
  190. package/node_modules/@openclaw/fs-safe/dist/safe-path-segment.js +0 -4
  191. package/node_modules/@openclaw/fs-safe/dist/secret-file.js +12 -9
  192. package/node_modules/@openclaw/fs-safe/dist/secure-temp-dir.d.ts +0 -2
  193. package/node_modules/@openclaw/fs-safe/dist/sibling-staged-file.js +2 -0
  194. package/node_modules/@openclaw/fs-safe/dist/sibling-temp.js +7 -4
  195. package/node_modules/@openclaw/fs-safe/dist/sidecar-lock-acquire.js +13 -6
  196. package/node_modules/@openclaw/fs-safe/dist/sidecar-lock-reclaim.d.ts +0 -3
  197. package/node_modules/@openclaw/fs-safe/dist/sidecar-lock-reclaim.js +5 -23
  198. package/node_modules/@openclaw/fs-safe/dist/staged-file-settlement.d.ts +2 -1
  199. package/node_modules/@openclaw/fs-safe/dist/staged-file-settlement.js +11 -6
  200. package/node_modules/@openclaw/fs-safe/dist/temp-cleanup.js +1 -8
  201. package/node_modules/@openclaw/fs-safe/dist/temp-workspace-child-admission.d.ts +1 -1
  202. package/node_modules/@openclaw/fs-safe/dist/temp-workspace-child-admission.js +2 -9
  203. package/node_modules/@openclaw/fs-safe/dist/text-atomic.d.ts +1 -6
  204. package/node_modules/@openclaw/fs-safe/dist/trash.js +6 -2
  205. package/node_modules/@openclaw/fs-safe/dist/walk.js +100 -46
  206. package/node_modules/@openclaw/fs-safe/dist/watch-hints.d.ts +7 -0
  207. package/node_modules/@openclaw/fs-safe/dist/watch-hints.js +235 -19
  208. package/node_modules/@openclaw/fs-safe/dist/watch-native.d.ts +21 -2
  209. package/node_modules/@openclaw/fs-safe/dist/watch-native.js +21 -3
  210. package/node_modules/@openclaw/fs-safe/dist/watch-rescan.d.ts +6 -0
  211. package/node_modules/@openclaw/fs-safe/dist/watch-rescan.js +111 -0
  212. package/node_modules/@openclaw/fs-safe/dist/watch-scan.d.ts +13 -0
  213. package/node_modules/@openclaw/fs-safe/dist/watch-scan.js +27 -4
  214. package/node_modules/@openclaw/fs-safe/dist/watch-stream.js +2 -0
  215. package/node_modules/@openclaw/fs-safe/dist/watch.js +131 -40
  216. package/node_modules/@openclaw/fs-safe/dist/windows-path-alias.d.ts +8 -0
  217. package/node_modules/@openclaw/fs-safe/dist/windows-path-alias.js +24 -6
  218. package/node_modules/@openclaw/fs-safe/dist/windows-path-syntax.d.ts +13 -0
  219. package/node_modules/@openclaw/fs-safe/dist/windows-path-syntax.js +51 -0
  220. package/node_modules/@openclaw/fs-safe/docs/advanced.md +4 -0
  221. package/node_modules/@openclaw/fs-safe/docs/atomic.md +4 -1
  222. package/node_modules/@openclaw/fs-safe/docs/config.md +6 -14
  223. package/node_modules/@openclaw/fs-safe/docs/contributing.md +4 -14
  224. package/node_modules/@openclaw/fs-safe/docs/durability.md +6 -29
  225. package/node_modules/@openclaw/fs-safe/docs/entry-publication.md +146 -0
  226. package/node_modules/@openclaw/fs-safe/docs/errors.md +16 -0
  227. package/node_modules/@openclaw/fs-safe/docs/file-store.md +28 -5
  228. package/node_modules/@openclaw/fs-safe/docs/index.md +2 -31
  229. package/node_modules/@openclaw/fs-safe/docs/install.md +10 -31
  230. package/node_modules/@openclaw/fs-safe/docs/json.md +1 -1
  231. package/node_modules/@openclaw/fs-safe/docs/local-roots.md +0 -1
  232. package/node_modules/@openclaw/fs-safe/docs/migrating-to-0.5.md +12 -12
  233. package/node_modules/@openclaw/fs-safe/docs/native-helper.md +35 -96
  234. package/node_modules/@openclaw/fs-safe/docs/native.md +22 -20
  235. package/node_modules/@openclaw/fs-safe/docs/path.md +1 -1
  236. package/node_modules/@openclaw/fs-safe/docs/permissions.md +1 -2
  237. package/node_modules/@openclaw/fs-safe/docs/public-api.md +1 -2
  238. package/node_modules/@openclaw/fs-safe/docs/reading.md +1 -2
  239. package/node_modules/@openclaw/fs-safe/docs/root.md +26 -184
  240. package/node_modules/@openclaw/fs-safe/docs/secret-file.md +1 -1
  241. package/node_modules/@openclaw/fs-safe/docs/security-model.md +115 -3
  242. package/node_modules/@openclaw/fs-safe/docs/store.md +2 -2
  243. package/node_modules/@openclaw/fs-safe/docs/temp.md +29 -65
  244. package/node_modules/@openclaw/fs-safe/docs/testing.md +90 -58
  245. package/node_modules/@openclaw/fs-safe/docs/types.md +3 -16
  246. package/node_modules/@openclaw/fs-safe/docs/walk.md +33 -5
  247. package/node_modules/@openclaw/fs-safe/docs/watch.md +96 -14
  248. package/node_modules/@openclaw/fs-safe/docs/writing.md +172 -16
  249. package/node_modules/@openclaw/fs-safe/package.json +10 -10
  250. package/node_modules/@openclaw/fs-safe-darwin-arm64/fs-safe-native.node +0 -0
  251. package/node_modules/@openclaw/fs-safe-darwin-arm64/package.json +1 -1
  252. package/node_modules/@openclaw/fs-safe-darwin-x64/fs-safe-native.node +0 -0
  253. package/node_modules/@openclaw/fs-safe-darwin-x64/package.json +1 -1
  254. package/node_modules/@openclaw/fs-safe-linux-arm64-gnu/fs-safe-native.node +0 -0
  255. package/node_modules/@openclaw/fs-safe-linux-arm64-gnu/package.json +1 -1
  256. package/node_modules/@openclaw/fs-safe-linux-arm64-musl/fs-safe-native.node +0 -0
  257. package/node_modules/@openclaw/fs-safe-linux-arm64-musl/package.json +1 -1
  258. package/node_modules/@openclaw/fs-safe-linux-x64-gnu/fs-safe-native.node +0 -0
  259. package/node_modules/@openclaw/fs-safe-linux-x64-gnu/package.json +1 -1
  260. package/node_modules/@openclaw/fs-safe-linux-x64-musl/fs-safe-native.node +0 -0
  261. package/node_modules/@openclaw/fs-safe-linux-x64-musl/package.json +1 -1
  262. package/node_modules/@openclaw/fs-safe-win32-x64-msvc/fs-safe-native.node +0 -0
  263. package/node_modules/@openclaw/fs-safe-win32-x64-msvc/package.json +1 -1
  264. package/openclaw.plugin.json +0 -9
  265. package/package.json +5 -5
  266. package/dist/.setup/crypto-snapshot-doctor.runtime-44FrCPR7.mjs +0 -91
  267. package/dist/.setup/doctor-DMvEBx6o.mjs +0 -49
  268. package/dist/.setup/idb-persistence-DBvfre1X.mjs +0 -227
  269. package/dist/.setup/idb-persistence-lock-D_mDu4Cf.mjs +0 -27
  270. package/dist/.setup/logger-CVv56jzH.mjs +0 -74
  271. package/dist/.setup/startup-verification-Aiy_xVdI.mjs +0 -204
  272. package/dist/.setup/storage-BXS2cB2i.mjs +0 -288
  273. package/dist/.setup/storage-metadata-BDRZ7vpX.mjs +0 -371
  274. package/node_modules/@openclaw/fs-safe/dist/watch-alias.d.ts +0 -6
  275. package/node_modules/@openclaw/fs-safe/dist/watch-alias.js +0 -88
  276. package/node_modules/@openclaw/fs-safe/docs/mutation-policy-proof.md +0 -69
  277. package/node_modules/@openclaw/fs-safe/docs/private-file-store.md +0 -68
  278. package/node_modules/@openclaw/fs-safe/docs/test-hooks.md +0 -110
@@ -1,16 +1,16 @@
1
- import { i as __exportAll } from "./doctor-contract-De6geW0h.mjs";
1
+ import { i as __exportAll } from "./doctor-contract-CsTNmbMa.mjs";
2
2
  import { t as getMatrixRuntime } from "./runtime-1kn1P6io.mjs";
3
- import { E as writeMatrixRecoveryKeyStateForPathAsync, _ as readLegacyMatrixRecoveryKeyFile, f as migrateLegacyMatrixRecoveryKeyFilePathToStoreAsync, x as readMatrixRecoveryKeyStateForPathAsync } from "./storage-metadata-BDRZ7vpX.mjs";
4
- import { r as withoutMatrixSendCurrentness, t as captureMatrixSendCurrentness } from "./send-currentness-C2rMVVIQ.mjs";
3
+ import { r as assertMatrixSupportedStateFile } from "./retired-state-BXUQ2I-C.mjs";
4
+ import { d as writeMatrixRecoveryKeyStateForPathAsync, l as readMatrixRecoveryKeyStateForPathAsync } from "./storage-D7agewjH.mjs";
5
+ import { n as withMatrixSendCurrentness, r as withoutMatrixSendCurrentness, t as captureMatrixSendCurrentness } from "./send-currentness-C2rMVVIQ.mjs";
5
6
  import { i as parseMxc, r as matrixEventToRaw } from "./event-helpers-CspuhE9k.mjs";
6
7
  import { n as isMatrixNotFoundError, t as formatMatrixErrorReason } from "./errors-DKVS3_DO.mjs";
7
- import { i as createMatrixStartupAbortError, o as throwIfMatrixStartupAborted, r as awaitMatrixStartupWithAbort } from "./client-Ccv77kwh.mjs";
8
- import { n as createMatrixGuardedFetch, t as MatrixAuthedHttpClient } from "./http-client-C1XvVD3K.mjs";
8
+ import { i as createMatrixStartupAbortError, o as throwIfMatrixStartupAborted, r as awaitMatrixStartupWithAbort } from "./client-kmih04ng.mjs";
9
+ import { n as createMatrixGuardedFetch, t as MatrixAuthedHttpClient } from "./http-client-DfJY5Ck0.mjs";
9
10
  import { n as resolveMatrixRoomKeyBackupReadinessError } from "./backup-health-Dm_YMVFT.mjs";
10
- import { n as LogService, r as noop, t as ConsoleLogger } from "./logger-CVv56jzH.mjs";
11
- import { t as createMatrixJsSdkClientLogger } from "./logging-mhnFQGzB.mjs";
12
- import { t as MATRIX_IDB_PERSIST_INTERVAL_MS } from "./idb-persistence-lock-D_mDu4Cf.mjs";
13
- 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-Bn9Bk0-H.mjs";
11
+ import { r as noop, t as LogService } from "./logger-CXQnpXCt.mjs";
12
+ import { t as createMatrixJsSdkClientLogger } from "./logging-BKV8TYQq.mjs";
13
+ 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-D7BlioUb.mjs";
14
14
  import { createRequire } from "node:module";
15
15
  import { createLazyRuntimeModule } from "openclaw/plugin-sdk/lazy-runtime";
16
16
  import { normalizeNullableString, normalizeStringEntries, uniqueStrings } from "openclaw/plugin-sdk/string-coerce-runtime";
@@ -19,6 +19,7 @@ import path from "node:path";
19
19
  import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
20
20
  import { AsyncLocalStorage } from "node:async_hooks";
21
21
  import { KeyedAsyncQueue } from "openclaw/plugin-sdk/keyed-async-queue";
22
+ import { createDeferred } from "openclaw/plugin-sdk/extension-shared";
22
23
  import { captureChannelReadAuthority } from "openclaw/plugin-sdk/fetch-runtime";
23
24
  import { ClientEvent, EventType, Filter, MatrixError, MatrixEventEvent, MsgType, Preset, createClient } from "matrix-js-sdk/lib/matrix.js";
24
25
  import { EventEmitter } from "node:events";
@@ -30,34 +31,21 @@ import { MatrixScheduler } from "matrix-js-sdk/lib/scheduler.js";
30
31
  import { EventStatus } from "matrix-js-sdk/lib/models/event-status.js";
31
32
  //#region extensions/matrix/src/matrix/sdk/client-device-info.ts
32
33
  async function resolveMatrixCrossSigningPublicationStatus(params) {
33
- if (!params.userId) return {
34
- userId: null,
35
- masterKeyPublished: false,
36
- selfSigningKeyPublished: false,
37
- userSigningKeyPublished: false,
38
- published: false
34
+ let response;
35
+ if (params.userId) try {
36
+ response = await params.query();
37
+ } catch {}
38
+ const userId = params.userId || null;
39
+ const masterKeyPublished = Boolean(userId && response?.master_keys?.[userId]);
40
+ const selfSigningKeyPublished = Boolean(userId && response?.self_signing_keys?.[userId]);
41
+ const userSigningKeyPublished = Boolean(userId && response?.user_signing_keys?.[userId]);
42
+ return {
43
+ userId,
44
+ masterKeyPublished,
45
+ selfSigningKeyPublished,
46
+ userSigningKeyPublished,
47
+ published: masterKeyPublished && selfSigningKeyPublished && userSigningKeyPublished
39
48
  };
40
- try {
41
- const response = await params.query();
42
- const masterKeyPublished = Boolean(response.master_keys?.[params.userId]);
43
- const selfSigningKeyPublished = Boolean(response.self_signing_keys?.[params.userId]);
44
- const userSigningKeyPublished = Boolean(response.user_signing_keys?.[params.userId]);
45
- return {
46
- userId: params.userId,
47
- masterKeyPublished,
48
- selfSigningKeyPublished,
49
- userSigningKeyPublished,
50
- published: masterKeyPublished && selfSigningKeyPublished && userSigningKeyPublished
51
- };
52
- } catch {
53
- return {
54
- userId: params.userId,
55
- masterKeyPublished: false,
56
- selfSigningKeyPublished: false,
57
- userSigningKeyPublished: false,
58
- published: false
59
- };
60
- }
61
49
  }
62
50
  async function listMatrixOwnDevices(client) {
63
51
  const currentDeviceId = client.getDeviceId()?.trim() || null;
@@ -104,7 +92,8 @@ function registerMatrixClientBridge(params) {
104
92
  params.client.on(ClientEvent.Sync, (state, prevState, data) => {
105
93
  initialSyncComplete ||= state === "PREPARED" || state === "SYNCING";
106
94
  const error = data && typeof data === "object" && "error" in data ? data.error : void 0;
107
- params.setCurrentSyncState(state, error);
95
+ const fromCache = data != null && typeof data === "object" && "fromCache" in data && data.fromCache === true;
96
+ params.setCurrentSyncState(state, error, fromCache);
108
97
  params.emitter.emit("sync.state", state, prevState, error);
109
98
  });
110
99
  params.client.on(ClientEvent.SyncUnexpectedError, (error) => {
@@ -265,6 +254,115 @@ async function waitForMatrixInitialSyncReady(params) {
265
254
  });
266
255
  }
267
256
  //#endregion
257
+ //#region extensions/matrix/src/matrix/sdk/idb-persistence-lock.ts
258
+ const MATRIX_IDB_PERSIST_INTERVAL_MS = 6e4;
259
+ const IDB_SNAPSHOT_LOCK_STALE_MS = 3e5;
260
+ const IDB_SNAPSHOT_LOCK_RETRY_BASE = {
261
+ factor: 2,
262
+ minTimeout: 50,
263
+ maxTimeout: 5e3,
264
+ randomize: true
265
+ };
266
+ function resolveRetriesForMinimumWindowMs(retries, minimumWindowMs) {
267
+ const resolved = {
268
+ ...retries,
269
+ retries: 0
270
+ };
271
+ let total = 0;
272
+ while (total < minimumWindowMs) {
273
+ total += Math.min(retries.maxTimeout, Math.max(retries.minTimeout, retries.minTimeout * retries.factor ** resolved.retries));
274
+ resolved.retries += 1;
275
+ }
276
+ return resolved;
277
+ }
278
+ const MATRIX_IDB_SNAPSHOT_LOCK_OPTIONS = {
279
+ retries: resolveRetriesForMinimumWindowMs(IDB_SNAPSHOT_LOCK_RETRY_BASE, MATRIX_IDB_PERSIST_INTERVAL_MS),
280
+ stale: IDB_SNAPSHOT_LOCK_STALE_MS
281
+ };
282
+ //#endregion
283
+ //#region extensions/matrix/src/matrix/sdk/live-room-readiness.ts
284
+ async function withMatrixLiveEncryptedRoom(owner, run, params) {
285
+ const signal = AbortSignal.any([params.generationSignal, ...params.abortSignal ? [params.abortSignal] : []]);
286
+ const active = (async () => {
287
+ signal.throwIfAborted();
288
+ params.assertActive();
289
+ await params.initializeCrypto();
290
+ signal.throwIfAborted();
291
+ params.assertActive();
292
+ return await probeMatrixLiveEncryptedRoom({
293
+ ...params,
294
+ signal
295
+ });
296
+ })();
297
+ params.operations.add(active);
298
+ active.finally(() => params.operations.delete(active)).catch(noop);
299
+ const stopped = createDeferred();
300
+ const onSyncState = (state) => {
301
+ if (state === "STOPPED") stopped.reject(/* @__PURE__ */ new Error("Matrix sync stopped while waiting for a live encrypted room"));
302
+ };
303
+ params.emitter.on("sync.state", onSyncState);
304
+ let assertCurrent;
305
+ try {
306
+ onSyncState(params.getSync().state);
307
+ assertCurrent = await Promise.race([awaitMatrixStartupWithAbort(active, signal), stopped.promise]);
308
+ } finally {
309
+ params.emitter.off("sync.state", onSyncState);
310
+ }
311
+ assertCurrent();
312
+ return await withMatrixSendCurrentness(owner, assertCurrent, () => run(assertCurrent));
313
+ }
314
+ async function probeMatrixLiveEncryptedRoom(params) {
315
+ let changed;
316
+ let wake;
317
+ const onChange = () => {
318
+ changed = true;
319
+ wake?.();
320
+ };
321
+ const assertActive = () => {
322
+ params.signal.throwIfAborted();
323
+ params.assertActive();
324
+ if (params.getSync().state === "STOPPED") throw new Error("Matrix sync stopped while waiting for a live encrypted room");
325
+ };
326
+ const events = [
327
+ "sync.state",
328
+ "room.event",
329
+ "room.join"
330
+ ];
331
+ for (const event of events) params.emitter.on(event, onChange);
332
+ params.signal.addEventListener("abort", onChange);
333
+ try {
334
+ for (;;) {
335
+ changed = false;
336
+ assertActive();
337
+ const sync = params.getSync();
338
+ const room = params.client.getRoom(params.roomId);
339
+ const crypto = params.client.getCrypto();
340
+ const isCurrent = () => {
341
+ const current = params.getSync();
342
+ return !current.fromCache && (current.state === "PREPARED" || current.state === "SYNCING") && room != null && params.client.getRoom(params.roomId) === room && room.getMyMembership() === "join" && room.hasEncryptionStateEvent() && crypto != null && params.client.getCrypto() === crypto;
343
+ };
344
+ if (isCurrent() && crypto) {
345
+ const encrypted = await crypto.isEncryptionEnabledInRoom(params.roomId);
346
+ assertActive();
347
+ if (params.getSync().revision !== sync.revision || !isCurrent()) continue;
348
+ if (encrypted) return () => {
349
+ assertActive();
350
+ if (!isCurrent()) throw new Error("Matrix live encrypted room changed before dispatch; retry the send");
351
+ };
352
+ }
353
+ if (!changed) {
354
+ await new Promise((resolve) => {
355
+ wake = resolve;
356
+ });
357
+ wake = void 0;
358
+ }
359
+ }
360
+ } finally {
361
+ for (const event of events) params.emitter.off(event, onChange);
362
+ params.signal.removeEventListener("abort", onChange);
363
+ }
364
+ }
365
+ //#endregion
268
366
  //#region extensions/matrix/src/matrix/sdk/message-wire-dispatch.ts
269
367
  function resolveMessageWireDispatch(resource, init) {
270
368
  if ((init?.method ?? (resource instanceof Request ? resource.method : "GET")).toUpperCase() !== "PUT") return null;
@@ -339,18 +437,7 @@ var MatrixRecoveryKeyStore = class {
339
437
  this.closed = false;
340
438
  this.recoveryKeyPath = recoveryKeyPath;
341
439
  this.storageRootDir = recoveryKeyPath ? path.dirname(recoveryKeyPath) : void 0;
342
- if (recoveryKeyPath) {
343
- this.stateRuntime = stateRuntime ?? getMatrixRuntime().state;
344
- const runtime = this.stateRuntime;
345
- this.enqueuePersistence(async () => {
346
- try {
347
- await migrateLegacyMatrixRecoveryKeyFilePathToStoreAsync(recoveryKeyPath, runtime);
348
- } catch (err) {
349
- this.legacyRecoveryKeyPathOnMigrationFailure = recoveryKeyPath;
350
- LogService.warn("MatrixClientLite", "Failed to migrate Matrix recovery key state:", err);
351
- }
352
- });
353
- }
440
+ if (recoveryKeyPath) this.stateRuntime = stateRuntime ?? getMatrixRuntime().state;
354
441
  }
355
442
  enqueuePersistence(run) {
356
443
  if (this.closed) return Promise.reject(/* @__PURE__ */ new Error("Matrix recovery key store is closed"));
@@ -597,12 +684,12 @@ var MatrixRecoveryKeyStore = class {
597
684
  }
598
685
  async loadStoredRecoveryKey() {
599
686
  if (!this.recoveryKeyPath || !this.stateRuntime) return null;
687
+ await assertMatrixSupportedStateFile(this.recoveryKeyPath);
600
688
  try {
601
- const stored = await readMatrixRecoveryKeyStateForPathAsync(this.recoveryKeyPath, this.stateRuntime);
602
- if (stored) return stored;
603
- } catch {}
604
- if (this.legacyRecoveryKeyPathOnMigrationFailure) return readLegacyMatrixRecoveryKeyFile(this.legacyRecoveryKeyPathOnMigrationFailure);
605
- return null;
689
+ return await readMatrixRecoveryKeyStateForPathAsync(this.recoveryKeyPath, this.stateRuntime);
690
+ } catch {
691
+ return null;
692
+ }
606
693
  }
607
694
  saveRecoveryKeyToDisk(params, preserveEncodedPrivateKey = false) {
608
695
  return this.enqueuePersistence(() => this.persistRecoveryKey(params, preserveEncodedPrivateKey));
@@ -610,6 +697,7 @@ var MatrixRecoveryKeyStore = class {
610
697
  async persistRecoveryKey(params, preserveEncodedPrivateKey = false) {
611
698
  if (!this.recoveryKeyPath || !this.stateRuntime) return;
612
699
  try {
700
+ await assertMatrixSupportedStateFile(this.recoveryKeyPath);
613
701
  const payload = {
614
702
  version: 1,
615
703
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
@@ -675,7 +763,7 @@ var MatrixSendScheduler = class extends MatrixScheduler {
675
763
  //#region extensions/matrix/src/matrix/sdk/client-base.ts
676
764
  const MATRIX_ENCRYPTED_STARTUP_TIMEOUT_MS = 6e4;
677
765
  let loadedMatrixCryptoRuntime = null;
678
- const loadMatrixCryptoRuntime = createLazyRuntimeModule(() => import("./crypto-runtime-DPjIDF8H.mjs").then((runtime) => {
766
+ const loadMatrixCryptoRuntime = createLazyRuntimeModule(() => import("./crypto-runtime-B2AjWo-i.mjs").then((runtime) => {
679
767
  loadedMatrixCryptoRuntime = runtime;
680
768
  return runtime;
681
769
  }));
@@ -697,9 +785,10 @@ var MatrixClientBase = class {
697
785
  this.sendQueue = new KeyedAsyncQueue();
698
786
  this.syncQuiescePromise = null;
699
787
  this.stopPersistPromise = null;
700
- this.verificationSummaryListenerBound = false;
701
788
  this.currentSyncState = null;
702
789
  this.currentSyncError = void 0;
790
+ this.currentSyncFromCache = false;
791
+ this.currentSyncRevision = 0;
703
792
  this.transactionScopeId = null;
704
793
  this.transactionScopePromise = null;
705
794
  this.messageWireDispatchGuards = new MatrixMessageWireDispatchGuards();
@@ -707,6 +796,7 @@ var MatrixClientBase = class {
707
796
  this.cryptoRequestOwner = new AsyncLocalStorage();
708
797
  this.startupPromise = null;
709
798
  this.cryptoInitializationPromise = null;
799
+ this.liveRoomReadinessOperations = /* @__PURE__ */ new Set();
710
800
  this.sdkStopped = false;
711
801
  this.stopDiscardPromise = null;
712
802
  this.idbPersistPromise = null;
@@ -742,8 +832,7 @@ var MatrixClientBase = class {
742
832
  this.initialSyncLimit = opts.initialSyncLimit;
743
833
  this.syncFilter = opts.syncFilter;
744
834
  this.encryptionEnabled = opts.encryption === true;
745
- const { password: loginPassword } = opts;
746
- this.password = loginPassword;
835
+ this.password = opts.password;
747
836
  this.syncStore = opts.syncStore;
748
837
  this.idbSnapshotPath = opts.idbSnapshotPath;
749
838
  this.cryptoDatabasePrefix = opts.cryptoDatabasePrefix;
@@ -813,11 +902,14 @@ var MatrixClientBase = class {
813
902
  }
814
903
  });
815
904
  if (!this.encryptionEnabled) return;
816
- this.verificationManager ??= new runtime.MatrixVerificationManager({ trustOwnDeviceAfterSas: async (deviceId) => {
817
- const crypto = this.client.getCrypto();
818
- if (typeof crypto?.crossSignDevice !== "function") return;
819
- await crypto.crossSignDevice(deviceId);
820
- } });
905
+ this.verificationManager ??= new runtime.MatrixVerificationManager({
906
+ onSummaryChanged: (summary) => this.emitter.emit("verification.summary", summary),
907
+ trustOwnDeviceAfterSas: async (deviceId) => {
908
+ const crypto = this.client.getCrypto();
909
+ if (typeof crypto?.crossSignDevice !== "function") return;
910
+ await crypto.crossSignDevice(deviceId);
911
+ }
912
+ });
821
913
  this.cryptoBootstrapper ??= new runtime.MatrixCryptoBootstrapper({
822
914
  getUserId: () => this.getUserId(),
823
915
  getPassword: () => this.password,
@@ -845,12 +937,6 @@ var MatrixClientBase = class {
845
937
  isRoomEncrypted: async (roomId) => await this.getMessageWireEventType(roomId) === "m.room.encrypted",
846
938
  downloadContent: (mxcUrl, opts) => this.downloadContent(mxcUrl, opts)
847
939
  });
848
- if (!this.verificationSummaryListenerBound) {
849
- this.verificationSummaryListenerBound = true;
850
- this.verificationManager.onSummaryChanged((summary) => {
851
- this.emitter.emit("verification.summary", summary);
852
- });
853
- }
854
940
  }
855
941
  async start(opts = {}) {
856
942
  await this.startSyncSession({
@@ -905,7 +991,7 @@ var MatrixClientBase = class {
905
991
  checkActive();
906
992
  throwIfMatrixStartupAborted(signal);
907
993
  if (this.encryptionEnabled && this.cryptoInitialized) {
908
- const { reconcileJoinedRoomEncryption } = await import("./joined-room-encryption-TZoOKXgh.mjs");
994
+ const { reconcileJoinedRoomEncryption } = await import("./joined-room-encryption-BAD70N5n.mjs");
909
995
  checkActive();
910
996
  await this.withClientCryptoWork(() => reconcileJoinedRoomEncryption(this.client, signal, checkActive), signal);
911
997
  checkActive();
@@ -934,6 +1020,30 @@ var MatrixClientBase = class {
934
1020
  await this.withClientCryptoWork(() => this.initializeCryptoIfNeeded());
935
1021
  assertCurrent?.();
936
1022
  }
1023
+ abortPendingRequests() {
1024
+ this.requestAbortController.abort(/* @__PURE__ */ new Error("Matrix client generation is no longer active."));
1025
+ }
1026
+ async withLiveEncryptedRoom(roomId, run, opts = {}) {
1027
+ return await withMatrixLiveEncryptedRoom(this, run, {
1028
+ client: this.client,
1029
+ emitter: this.emitter,
1030
+ roomId,
1031
+ generationSignal: this.requestAbortController.signal,
1032
+ abortSignal: opts.abortSignal,
1033
+ operations: this.liveRoomReadinessOperations,
1034
+ initializeCrypto: () => this.withClientCryptoWork(() => this.prepareForOneOff()),
1035
+ assertActive: () => {
1036
+ this.assertClientActive();
1037
+ opts.assertCurrent?.();
1038
+ if (this.sdkStopped || this.syncQuiescePromise) throw new Error("Matrix client is stopping; acquire a new client before sending");
1039
+ },
1040
+ getSync: () => ({
1041
+ state: this.currentSyncState,
1042
+ fromCache: this.currentSyncFromCache,
1043
+ revision: this.currentSyncRevision
1044
+ })
1045
+ });
1046
+ }
937
1047
  hasPersistedSyncState() {
938
1048
  return this.syncStore?.hasSavedSyncFromCleanShutdown() === true;
939
1049
  }
@@ -974,9 +1084,10 @@ var MatrixClientBase = class {
974
1084
  await this.quiesceSync().catch(noop);
975
1085
  this.syncStore?.discardPendingSyncCursorPersistence();
976
1086
  }
977
- this.requestAbortController.abort(/* @__PURE__ */ new Error("Matrix client generation is no longer active."));
1087
+ this.abortPendingRequests();
978
1088
  await this.startupPromise?.catch(noop);
979
1089
  await this.cryptoInitializationPromise?.catch(noop);
1090
+ await Promise.allSettled(this.liveRoomReadinessOperations);
980
1091
  clearInterval(this.idbPersistTimer ?? void 0);
981
1092
  this.idbPersistTimer = null;
982
1093
  this.idbPersistAbortController?.abort();
@@ -1336,6 +1447,24 @@ var MatrixClientCore = class extends MatrixClientBase {
1336
1447
  }
1337
1448
  };
1338
1449
  //#endregion
1450
+ //#region extensions/matrix/src/matrix/sdk/verification-status.ts
1451
+ function isMatrixDeviceOwnerVerified(status) {
1452
+ return status?.crossSigningVerified === true;
1453
+ }
1454
+ function isMatrixDeviceVerifiedInCurrentClient(status) {
1455
+ return status?.isVerified?.() === true || status?.localVerified === true || isMatrixDeviceOwnerVerified(status);
1456
+ }
1457
+ async function trustMatrixOwnIdentity(crypto) {
1458
+ const ownIdentity = typeof crypto.getOwnIdentity === "function" ? await crypto.getOwnIdentity().catch(() => void 0) : void 0;
1459
+ if (!ownIdentity) return;
1460
+ try {
1461
+ if (typeof ownIdentity.isVerified === "function" && ownIdentity.isVerified()) return;
1462
+ if (typeof ownIdentity.verify === "function") await ownIdentity.verify();
1463
+ } finally {
1464
+ ownIdentity.free?.();
1465
+ }
1466
+ }
1467
+ //#endregion
1339
1468
  //#region extensions/matrix/src/matrix/sdk/client-verification.ts
1340
1469
  var MatrixClientVerification = class extends MatrixClientCore {
1341
1470
  async refreshOwnDeviceKeys() {
@@ -1431,29 +1560,12 @@ var MatrixClientVerification = class extends MatrixClientCore {
1431
1560
  serverDeviceKnown
1432
1561
  };
1433
1562
  }
1434
- async getOwnDeviceIdentityVerificationStatus() {
1435
- const userId = this.client.getUserId() ?? this.selfUserId ?? null;
1436
- const deviceId = this.client.getDeviceId()?.trim() || null;
1437
- const deviceVerification = await this.getDeviceVerificationStatus(userId, deviceId);
1438
- return {
1439
- ...deviceVerification,
1440
- verified: deviceVerification.crossSigningVerified
1441
- };
1442
- }
1443
1563
  async trustOwnIdentityAfterSelfVerification() {
1444
1564
  if (!this.encryptionEnabled) return;
1445
1565
  await this.ensureStartedForCryptoControlPlane();
1446
1566
  await this.ensureCryptoSupportInitialized();
1447
1567
  const crypto = this.client.getCrypto();
1448
- const ownIdentity = crypto && typeof crypto.getOwnIdentity === "function" ? await crypto.getOwnIdentity().catch(() => void 0) : void 0;
1449
- if (!ownIdentity) return;
1450
- try {
1451
- if (typeof ownIdentity.isVerified === "function" && ownIdentity.isVerified()) return;
1452
- if (typeof ownIdentity.verify !== "function") return;
1453
- await ownIdentity.verify();
1454
- } finally {
1455
- ownIdentity.free?.();
1456
- }
1568
+ if (crypto) await trustMatrixOwnIdentity(crypto);
1457
1569
  }
1458
1570
  async resolveActiveRoomKeyBackupVersion(crypto) {
1459
1571
  if (typeof crypto.getActiveSessionBackupVersion !== "function") return null;
@@ -1531,20 +1643,16 @@ var MatrixClientVerification = class extends MatrixClientCore {
1531
1643
  };
1532
1644
  //#endregion
1533
1645
  //#region extensions/matrix/src/matrix/sdk.ts
1534
- var sdk_exports = /* @__PURE__ */ __exportAll({
1535
- ConsoleLogger: () => ConsoleLogger,
1536
- LogService: () => LogService,
1537
- MatrixClient: () => MatrixClient
1538
- });
1646
+ var sdk_exports = /* @__PURE__ */ __exportAll({ MatrixClient: () => MatrixClient });
1539
1647
  var MatrixClient = class extends MatrixClientVerification {
1540
1648
  async verifyWithRecoveryKey(rawRecoveryKey) {
1541
- const fail = async (error, fields = {}) => {
1649
+ const fail = async (error) => {
1542
1650
  const status = await this.getOwnDeviceVerificationStatus();
1543
1651
  return {
1544
1652
  success: false,
1545
- recoveryKeyAccepted: fields.recoveryKeyAccepted ?? false,
1546
- backupUsable: fields.backupUsable ?? false,
1547
- deviceOwnerVerified: fields.deviceOwnerVerified ?? status.verified,
1653
+ recoveryKeyAccepted: false,
1654
+ backupUsable: false,
1655
+ deviceOwnerVerified: status.verified,
1548
1656
  error,
1549
1657
  ...status
1550
1658
  };
@@ -1568,102 +1676,37 @@ var MatrixClient = class extends MatrixClientVerification {
1568
1676
  return await fail(formatErrorMessage(err));
1569
1677
  }
1570
1678
  const storedRecoveryKeyMatches = (await this.recoveryKeyStore.getRecoveryKeySummary())?.encodedPrivateKey?.trim() === trimmedRecoveryKey;
1571
- if (backupUsableBeforeStagedRecovery && storedRecoveryKeyMatches) {
1572
- const status = await this.getOwnDeviceVerificationStatus();
1679
+ const settleRecoveryKey = async (status, keyValidated, reusingStoredKey = false) => {
1573
1680
  const backupUsable = resolveMatrixRoomKeyBackupReadinessError(status.backup, { requireServerBackup: true }) === null;
1574
1681
  const backupError = resolveMatrixRoomKeyBackupReadinessError(status.backup, { requireServerBackup: false });
1575
- const recoveryKeyAccepted = backupUsable;
1576
- if (!status.verified) {
1577
- if (recoveryKeyAccepted) await this.recoveryKeyStore.commitStagedRecoveryKey({ keyId: stagedKeyId });
1578
- else await this.recoveryKeyStore.discardStagedRecoveryKey();
1579
- return {
1580
- success: false,
1581
- recoveryKeyAccepted,
1582
- backupUsable,
1583
- deviceOwnerVerified: false,
1584
- error: "Matrix recovery key was applied, but this device still lacks full Matrix identity trust. The recovery key can unlock usable backup material only when 'Backup usable' is yes; full identity trust still requires Matrix cross-signing verification.",
1585
- ...status
1586
- };
1587
- }
1588
- if (backupError) {
1589
- await this.recoveryKeyStore.discardStagedRecoveryKey();
1590
- return {
1591
- success: false,
1592
- recoveryKeyAccepted,
1593
- backupUsable,
1594
- deviceOwnerVerified: true,
1595
- error: backupError,
1596
- ...status
1597
- };
1598
- }
1599
- await this.recoveryKeyStore.commitStagedRecoveryKey({ keyId: stagedKeyId });
1682
+ const recoveryKeyAccepted = reusingStoredKey ? backupUsable : keyValidated && (status.verified || backupUsable);
1683
+ const error = !status.verified ? "Matrix recovery key was applied, but this device still lacks full Matrix identity trust. The recovery key can unlock usable backup material only when 'Backup usable' is yes; full identity trust still requires Matrix cross-signing verification." : backupError ?? (!keyValidated ? "Matrix recovery key could not be verified against active Matrix backup material; existing backup may be usable from previously loaded recovery material." : void 0);
1684
+ const commit = status.verified ? !error : backupUsable && keyValidated;
1685
+ if (commit) await this.recoveryKeyStore.commitStagedRecoveryKey({ keyId: stagedKeyId });
1686
+ else await this.recoveryKeyStore.discardStagedRecoveryKey();
1687
+ const committedStatus = commit && !reusingStoredKey ? await this.getOwnDeviceVerificationStatus() : status;
1600
1688
  return {
1601
- success: true,
1602
- recoveryKeyAccepted: true,
1689
+ success: !error,
1690
+ recoveryKeyAccepted: error ? recoveryKeyAccepted : true,
1603
1691
  backupUsable,
1604
- deviceOwnerVerified: true,
1605
- verifiedAt: (/* @__PURE__ */ new Date()).toISOString(),
1606
- ...status
1692
+ deviceOwnerVerified: status.verified,
1693
+ ...error ? { error } : { verifiedAt: (/* @__PURE__ */ new Date()).toISOString() },
1694
+ ...committedStatus
1607
1695
  };
1608
- }
1696
+ };
1697
+ if (backupUsableBeforeStagedRecovery && storedRecoveryKeyMatches) return await settleRecoveryKey(await this.getOwnDeviceVerificationStatus(), true, true);
1609
1698
  try {
1610
1699
  const cryptoBootstrapper = this.cryptoBootstrapper;
1611
1700
  if (!cryptoBootstrapper) return await fail("Matrix crypto bootstrapper is not available");
1612
1701
  await cryptoBootstrapper.bootstrap(crypto, { allowAutomaticCrossSigningReset: false });
1613
1702
  await this.enableTrustedRoomKeyBackupIfPossible(crypto);
1614
1703
  const status = await this.getOwnDeviceVerificationStatus();
1615
- const backupError = resolveMatrixRoomKeyBackupReadinessError(status.backup, { requireServerBackup: false });
1616
1704
  const backupUsable = resolveMatrixRoomKeyBackupReadinessError(status.backup, { requireServerBackup: true }) === null;
1617
1705
  const stagedRecoveryKeyUsed = this.recoveryKeyStore.hasStagedRecoveryKeyBeenUsed();
1618
1706
  const secretStorageStatus = typeof crypto.getSecretStorageStatus === "function" ? await crypto.getSecretStorageStatus().catch(() => null) : null;
1619
1707
  const stagedRecoveryKeyConfirmedBySecretStorage = Boolean(stagedKeyId) && secretStorageStatus?.secretStorageKeyValidityMap?.[stagedKeyId ?? ""] === true;
1620
1708
  const stagedRecoveryKeyRejectedBySecretStorage = Boolean(stagedKeyId) && secretStorageStatus?.secretStorageKeyValidityMap?.[stagedKeyId ?? ""] === false;
1621
- const stagedRecoveryKeyValidated = stagedRecoveryKeyUsed && (stagedRecoveryKeyConfirmedBySecretStorage || stagedRecoveryKeyUsed && !stagedRecoveryKeyRejectedBySecretStorage && !stagedRecoveryKeyConfirmedBySecretStorage && !backupUsableBeforeStagedRecovery && backupUsable) || storedRecoveryKeyMatches && backupUsable;
1622
- const recoveryKeyAccepted = stagedRecoveryKeyValidated && (status.verified || backupUsable);
1623
- if (!status.verified) {
1624
- if (backupUsable && stagedRecoveryKeyValidated) await this.recoveryKeyStore.commitStagedRecoveryKey({ keyId: stagedKeyId });
1625
- else await this.recoveryKeyStore.discardStagedRecoveryKey();
1626
- return {
1627
- success: false,
1628
- recoveryKeyAccepted,
1629
- backupUsable,
1630
- deviceOwnerVerified: false,
1631
- error: "Matrix recovery key was applied, but this device still lacks full Matrix identity trust. The recovery key can unlock usable backup material only when 'Backup usable' is yes; full identity trust still requires Matrix cross-signing verification.",
1632
- ...recoveryKeyAccepted ? await this.getOwnDeviceVerificationStatus() : status
1633
- };
1634
- }
1635
- if (backupError) {
1636
- await this.recoveryKeyStore.discardStagedRecoveryKey();
1637
- return {
1638
- success: false,
1639
- recoveryKeyAccepted,
1640
- backupUsable,
1641
- deviceOwnerVerified: true,
1642
- error: backupError,
1643
- ...status
1644
- };
1645
- }
1646
- if (!stagedRecoveryKeyValidated) {
1647
- await this.recoveryKeyStore.discardStagedRecoveryKey();
1648
- return {
1649
- success: false,
1650
- recoveryKeyAccepted: false,
1651
- backupUsable,
1652
- deviceOwnerVerified: true,
1653
- error: "Matrix recovery key could not be verified against active Matrix backup material; existing backup may be usable from previously loaded recovery material.",
1654
- ...status
1655
- };
1656
- }
1657
- await this.recoveryKeyStore.commitStagedRecoveryKey({ keyId: stagedKeyId });
1658
- const committedStatus = await this.getOwnDeviceVerificationStatus();
1659
- return {
1660
- success: true,
1661
- recoveryKeyAccepted: true,
1662
- backupUsable,
1663
- deviceOwnerVerified: true,
1664
- verifiedAt: (/* @__PURE__ */ new Date()).toISOString(),
1665
- ...committedStatus
1666
- };
1709
+ return await settleRecoveryKey(status, stagedRecoveryKeyUsed && (stagedRecoveryKeyConfirmedBySecretStorage || stagedRecoveryKeyUsed && !stagedRecoveryKeyRejectedBySecretStorage && !stagedRecoveryKeyConfirmedBySecretStorage && !backupUsableBeforeStagedRecovery && backupUsable) || storedRecoveryKeyMatches && backupUsable);
1667
1710
  } catch (err) {
1668
1711
  await this.recoveryKeyStore.discardStagedRecoveryKey();
1669
1712
  return await fail(formatErrorMessage(err));
@@ -1846,8 +1889,7 @@ var MatrixClient = class extends MatrixClientVerification {
1846
1889
  async deleteOwnDevices(deviceIds) {
1847
1890
  const uniqueDeviceIds = uniqueStrings(normalizeStringEntries(deviceIds));
1848
1891
  const currentDeviceId = this.client.getDeviceId()?.trim() || null;
1849
- const protectedDeviceIds = uniqueDeviceIds.filter((deviceId) => deviceId === currentDeviceId);
1850
- if (protectedDeviceIds.length > 0) throw new Error(`Refusing to delete the current Matrix device: ${protectedDeviceIds[0]}`);
1892
+ if (currentDeviceId !== null && uniqueDeviceIds.includes(currentDeviceId)) throw new Error(`Refusing to delete the current Matrix device: ${currentDeviceId}`);
1851
1893
  const deleteWithAuth = async (authData) => {
1852
1894
  await this.client.deleteMultipleDevices(uniqueDeviceIds, authData);
1853
1895
  };
@@ -1883,9 +1925,11 @@ var MatrixClient = class extends MatrixClientVerification {
1883
1925
  emitter: this.emitter,
1884
1926
  emitMembershipForRoom: (room) => this.emitMembershipForRoom(room),
1885
1927
  getSelfUserId: () => this.client.getUserId() ?? this.selfUserId ?? "",
1886
- setCurrentSyncState: (state, error) => {
1928
+ setCurrentSyncState: (state, error, fromCache) => {
1887
1929
  this.currentSyncState = state;
1888
1930
  this.currentSyncError = error;
1931
+ this.currentSyncFromCache = fromCache;
1932
+ this.currentSyncRevision += 1;
1889
1933
  }
1890
1934
  });
1891
1935
  }
@@ -1904,4 +1948,4 @@ var MatrixClient = class extends MatrixClientVerification {
1904
1948
  }
1905
1949
  };
1906
1950
  //#endregion
1907
- export { ConsoleLogger, LogService, MatrixClient, isRepairableSecretStorageAccessError as n, sdk_exports as t };
1951
+ 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 };