@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,36 +1,29 @@
1
1
  import { t as getMatrixRuntime } from "./runtime-1kn1P6io.mjs";
2
2
  import { a as resolveMatrixAccountConfig, n as hasExplicitMatrixAccountConfig } from "./account-config-CRsKoMqJ.mjs";
3
- import { p as updateMatrixAccountConfig, r as matrixSetupAdapter, v as resolveMatrixAccountAsync } from "./setup-core-CKnNTfgD.mjs";
3
+ import { l as sanitizeMatrixPathSegment } from "./storage-paths-B51JM-pC.mjs";
4
+ import { p as updateMatrixAccountConfig, r as matrixSetupAdapter, v as resolveMatrixAccountAsync } from "./setup-core-DcCk1_Tv.mjs";
4
5
  import { n as resolveMatrixConfigPath } from "./config-paths-CnREYb1Y.mjs";
5
- import { n as withResolvedActionClient } from "./client-BlTvpEWC.mjs";
6
- import { d as resolveMatrixAuthContext } from "./client-vPPbaxNp.mjs";
6
+ import { d as resolveMatrixAuthContext } from "./client-C4Gibhzl.mjs";
7
+ import { n as withResolvedActionClient } from "./client-BKiiI29H.mjs";
7
8
  import { t as resolveMatrixRoomKeyBackupIssue } from "./backup-health-Dm_YMVFT.mjs";
8
9
  import { i as setMatrixConsoleLogging } from "./logger-CXQnpXCt.mjs";
9
10
  import { r as setMatrixSdkLogMode } from "./logging-BKV8TYQq.mjs";
10
11
  import { n as isOpenClawManagedMatrixDevice, r as summarizeMatrixDeviceHealth } from "./device-health-Be60VF1w.mjs";
11
- import { n as updateMatrixOwnProfile, t as applyMatrixProfileUpdate } from "./profile-update-C7bjaGR6.mjs";
12
- import { a as confirmMatrixVerificationSas, b as verifyMatrixRecoveryKey, c as getMatrixRoomKeyBackupStatus, d as listMatrixVerifications, f as mismatchMatrixVerificationSas, g as runMatrixSelfVerification, h as restoreMatrixRoomKeyBackup, l as getMatrixVerificationSas, m as resetMatrixRoomKeyBackup, n as bootstrapMatrixVerification, p as requestMatrixVerification, r as cancelMatrixVerification, t as acceptMatrixVerification, u as getMatrixVerificationStatus, v as startMatrixVerification } from "./verification-B3VswneT.mjs";
12
+ import { n as updateMatrixOwnProfile, t as applyMatrixProfileUpdate } from "./profile-update--Pf3jCXD.mjs";
13
+ import { n as listMatrixCryptoUnsafeState, r as recoverMatrixCryptoUnsafeState } from "./crypto-unsafe-state-doctor-C8szCYmf.mjs";
14
+ import { a as confirmMatrixVerificationSas, b as verifyMatrixRecoveryKey, c as getMatrixRoomKeyBackupStatus, d as listMatrixVerifications, f as mismatchMatrixVerificationSas, g as runMatrixSelfVerification, h as restoreMatrixRoomKeyBackup, l as getMatrixVerificationSas, m as resetMatrixRoomKeyBackup, n as bootstrapMatrixVerification, p as requestMatrixVerification, r as cancelMatrixVerification, t as acceptMatrixVerification, u as getMatrixVerificationStatus, v as startMatrixVerification } from "./verification--qUbmRd-.mjs";
13
15
  import { normalizeAccountId } from "openclaw/plugin-sdk/account-id";
14
16
  import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
17
+ import path from "node:path";
15
18
  import { parseStrictInteger, timestampMsToIsoString } from "openclaw/plugin-sdk/number-runtime";
19
+ import os from "node:os";
16
20
  import { formatZonedTimestamp } from "openclaw/plugin-sdk/time-runtime";
17
21
  import { readByteStreamWithLimit } from "openclaw/plugin-sdk/response-limit-runtime";
18
22
  import { isDeepStrictEqual } from "node:util";
23
+ import { runWithLocalStateOwner } from "openclaw/plugin-sdk/cli-state-owner";
19
24
  import { getRuntimeConfigSnapshot, getRuntimeConfigSourceSnapshot } from "openclaw/plugin-sdk/runtime-config-snapshot";
20
25
  //#region extensions/matrix/src/cli-shared.ts
21
- let matrixCliExitScheduled = false;
22
26
  const MATRIX_CLI_RECOVERY_KEY_STDIN_MAX_BYTES = 1048576;
23
- function scheduleMatrixCliExit() {
24
- if (matrixCliExitScheduled || process.env.VITEST) return;
25
- matrixCliExitScheduled = true;
26
- setTimeout(() => {
27
- process.stdout.write("", () => {
28
- process.stderr.write("", () => {
29
- process.exit(process.exitCode ?? 0);
30
- });
31
- });
32
- }, 0);
33
- }
34
27
  async function readMatrixCliRecoveryKeyFromStdin() {
35
28
  const recoveryKey = (await readByteStreamWithLimit(process.stdin, {
36
29
  maxBytes: MATRIX_CLI_RECOVERY_KEY_STDIN_MAX_BYTES,
@@ -134,13 +127,23 @@ function parseOptionalInt(value, fieldName, opts = {}) {
134
127
  return parsed;
135
128
  }
136
129
  async function runMatrixCliAccountCommand(options, config) {
137
- const context = resolveMatrixCliAccountContext(options.account);
130
+ let accountId = normalizeAccountId(options.account);
138
131
  await runMatrixCliCommand(options, {
139
132
  ...config,
140
- run: () => config.run(context),
133
+ ...config.gateway ? { gateway: {
134
+ ...config.gateway,
135
+ onAccount: (id) => {
136
+ accountId = id;
137
+ }
138
+ } } : {},
139
+ run: () => {
140
+ const context = resolveMatrixCliAccountContext(options.account);
141
+ accountId = context.accountId;
142
+ return config.run(context);
143
+ },
141
144
  onText: (result, verbose) => {
142
- printAccountLabel(context.accountId);
143
- config.onText(result, verbose, context.accountId);
145
+ printAccountLabel(accountId);
146
+ config.onText(result, verbose, accountId);
144
147
  }
145
148
  });
146
149
  }
@@ -150,7 +153,15 @@ async function runMatrixCliCommand(options, config) {
150
153
  setMatrixSdkLogMode(verbose ? "default" : "quiet");
151
154
  setMatrixConsoleLogging(verbose);
152
155
  try {
153
- const result = await config.run();
156
+ const outcome = await runWithLocalStateOwner({
157
+ method: config.gateway?.method ?? "matrix.cli",
158
+ params: await config.gateway?.params() ?? {},
159
+ target: "Matrix account state",
160
+ ...config.gateway ? {} : { onForeignOwner: "refuse" },
161
+ runLocal: async () => ({ result: await config.run() })
162
+ });
163
+ if (outcome.accountId) config.gateway?.onAccount?.(outcome.accountId);
164
+ const result = outcome.result;
154
165
  if (json) printJson(config.onJson ? config.onJson(result) : result);
155
166
  else config.onText(result, verbose);
156
167
  if (config.shouldFail?.(result)) process.exitCode = 1;
@@ -162,8 +173,6 @@ async function runMatrixCliCommand(options, config) {
162
173
  config.onTextError?.(message);
163
174
  }
164
175
  process.exitCode = 1;
165
- } finally {
166
- scheduleMatrixCliExit();
167
176
  }
168
177
  }
169
178
  function sanitizeMatrixCliText(value) {
@@ -396,7 +405,7 @@ async function addMatrixAccount(params) {
396
405
  backupVersion: null
397
406
  };
398
407
  if (accountConfig.encryption === true) {
399
- const { maybeBootstrapNewEncryptedMatrixAccount } = await import("./setup-bootstrap-CV-hHBXu.mjs");
408
+ const { maybeBootstrapNewEncryptedMatrixAccount } = await import("./setup-bootstrap-DmznRqYe.mjs");
400
409
  verificationBootstrap = await maybeBootstrapNewEncryptedMatrixAccount({
401
410
  previousCfg: cfg,
402
411
  cfg: updated,
@@ -586,7 +595,7 @@ function printDirectRoomInspection(result) {
586
595
  }
587
596
  async function inspectMatrixDirectRoom(params) {
588
597
  const cfg = getMatrixRuntime().config.current();
589
- const [{ withResolvedActionClient }, { inspectMatrixDirectRooms }] = await Promise.all([import("./client-BlTvpEWC.mjs").then((n) => n.t), import("./direct-management-B3wYhx_M.mjs").then((n) => n.t)]);
598
+ const [{ withResolvedActionClient }, { inspectMatrixDirectRooms }] = await Promise.all([import("./client-BKiiI29H.mjs").then((n) => n.t), import("./direct-management-B3wYhx_M.mjs").then((n) => n.t)]);
590
599
  return await withResolvedActionClient({
591
600
  accountId: params.accountId,
592
601
  cfg
@@ -604,7 +613,7 @@ async function repairMatrixDirectRoom(params) {
604
613
  cfg,
605
614
  accountId: params.accountId
606
615
  });
607
- const [{ withStartedActionClient }, { repairMatrixDirectRooms }] = await Promise.all([import("./client-BlTvpEWC.mjs").then((n) => n.t), import("./direct-management-B3wYhx_M.mjs").then((n) => n.t)]);
616
+ const [{ withStartedActionClient }, { repairMatrixDirectRooms }] = await Promise.all([import("./client-BKiiI29H.mjs").then((n) => n.t), import("./direct-management-B3wYhx_M.mjs").then((n) => n.t)]);
608
617
  return await withStartedActionClient({
609
618
  accountId: params.accountId,
610
619
  cfg
@@ -676,6 +685,35 @@ function registerMatrixDirectCommands(root) {
676
685
  });
677
686
  }
678
687
  //#endregion
688
+ //#region extensions/matrix/src/cli-doctor.ts
689
+ function registerMatrixDoctorCommands(root) {
690
+ const accountForRoot = (rootDir, stateDir) => rootDir === path.resolve(stateDir, "matrix") ? "default" : path.basename(path.dirname(path.dirname(rootDir)));
691
+ const doctor = root.command("doctor").description("Inspect and recover Matrix crypto storage refusal");
692
+ doctor.command("inspect").description("List accounts blocked by an unsafe crypto final save (read-only)").option("--json", "Output JSON").action(async (options) => {
693
+ const stateDir = getMatrixRuntime().state.resolveStateDir(process.env, os.homedir);
694
+ const accounts = (await listMatrixCryptoUnsafeState(stateDir)).map((rootDir) => ({
695
+ account: accountForRoot(rootDir, stateDir),
696
+ rootDir
697
+ }));
698
+ if (options.json) console.log(JSON.stringify({ blocked: accounts }, null, 2));
699
+ else {
700
+ console.log(accounts.length ? `Matrix crypto refusal: ${accounts.length} account store(s) blocked` : "No blocked Matrix crypto stores found.");
701
+ for (const account of accounts) console.log(`- ${account.account}: ${account.rootDir}`);
702
+ }
703
+ });
704
+ doctor.command("recover").description("Accept rollback to a validated SQLite snapshot and clear one account's refusal").requiredOption("--account <id>", "Blocked account ID").requiredOption("--accept-snapshot-rollback", "Acknowledge that keys from the failed owner may be lost").action(async (options) => {
705
+ const stateDir = getMatrixRuntime().state.resolveStateDir(process.env, os.homedir);
706
+ const account = sanitizeMatrixPathSegment(normalizeAccountId(options.account));
707
+ const roots = (await listMatrixCryptoUnsafeState(stateDir)).filter((rootDir) => accountForRoot(rootDir, stateDir) === account);
708
+ if (roots.length !== 1) throw new Error(`Expected exactly one blocked Matrix crypto store for account ${account}; found ${roots.length}. Refusing ambiguous recovery.`);
709
+ await recoverMatrixCryptoUnsafeState({
710
+ storageRootDir: roots[0],
711
+ acceptSnapshotRollback: options.acceptSnapshotRollback === true
712
+ });
713
+ console.log(`Matrix crypto refusal cleared for account ${account}; restart the Gateway.`);
714
+ });
715
+ }
716
+ //#endregion
679
717
  //#region extensions/matrix/src/cli-encryption.ts
680
718
  function isMatrixVerificationSetupComplete(status) {
681
719
  return status.encryptionEnabled && status.verified && status.crossSigningVerified && status.signedByOwner && status.serverDeviceKnown === true && resolveMatrixRoomKeyBackupIssue(status.backup).code === "ok";
@@ -881,11 +919,20 @@ function registerMatrixVerificationBackupCommands(verify) {
881
919
  });
882
920
  });
883
921
  verify.command("bootstrap").description("Bootstrap Matrix cross-signing and device verification state").option("--account <id>", "Account ID (for multi-account setups)").option("--recovery-key <key>", "Recovery key to apply before bootstrap (prefer --recovery-key-stdin)").option("--recovery-key-stdin", "Read the Matrix recovery key from stdin").option("--force-reset-cross-signing", "Force reset cross-signing identity before bootstrap (requires active recovery key)").option("--verbose", "Show detailed diagnostics").option("--json", "Output as JSON").action(async (options) => {
922
+ const recoveryKey = resolveMatrixCliRecoveryKeyInput(options);
884
923
  await runMatrixCliAccountCommand(options, {
924
+ gateway: {
925
+ method: "matrix.verify.bootstrap.owner",
926
+ params: async () => ({
927
+ accountId: options.account,
928
+ recoveryKey: await recoveryKey,
929
+ forceResetCrossSigning: options.forceResetCrossSigning === true
930
+ })
931
+ },
885
932
  run: async ({ accountId, cfg }) => await bootstrapMatrixVerification({
886
933
  accountId,
887
934
  cfg,
888
- recoveryKey: await resolveMatrixCliRecoveryKeyInput(options),
935
+ recoveryKey: await recoveryKey,
889
936
  forceResetCrossSigning: options.forceResetCrossSigning === true
890
937
  }),
891
938
  onText: (result, verbose, accountId) => {
@@ -917,11 +964,19 @@ function registerMatrixVerificationBackupCommands(verify) {
917
964
  });
918
965
  });
919
966
  verify.command("device [key]").description("Verify device using a Matrix recovery key").option("--account <id>", "Account ID (for multi-account setups)").option("--recovery-key-stdin", "Read the Matrix recovery key from stdin").option("--verbose", "Show detailed diagnostics").option("--json", "Output as JSON").action(async (key, options) => {
967
+ const recoveryKey = requireMatrixCliRecoveryKeyInput({
968
+ recoveryKey: key,
969
+ recoveryKeyStdin: options.recoveryKeyStdin
970
+ });
920
971
  await runMatrixCliAccountCommand(options, {
921
- run: async ({ accountId, cfg }) => await verifyMatrixRecoveryKey(await requireMatrixCliRecoveryKeyInput({
922
- recoveryKey: key,
923
- recoveryKeyStdin: options.recoveryKeyStdin
924
- }), {
972
+ gateway: {
973
+ method: "matrix.verify.recoveryKey.owner",
974
+ params: async () => ({
975
+ accountId: options.account,
976
+ key: await recoveryKey
977
+ })
978
+ },
979
+ run: async ({ accountId, cfg }) => await verifyMatrixRecoveryKey(await recoveryKey, {
925
980
  accountId,
926
981
  cfg
927
982
  }),
@@ -1165,16 +1220,14 @@ function registerMatrixVerificationCommands(root) {
1165
1220
  errorPrefix: "Verification start failed"
1166
1221
  });
1167
1222
  verify.command("sas <id>").description("Show SAS emoji or decimals for a Matrix verification request").option("--account <id>", "Account ID (for multi-account setups)").option("--user-id <id>", "Matrix user ID for DM verification follow-up").option("--room-id <id>", "Matrix direct-message room ID for verification follow-up").option("--verbose", "Show detailed diagnostics").option("--json", "Output as JSON").action(async (id, options) => {
1168
- const { accountId, cfg } = resolveMatrixCliAccountContext(options.account);
1169
- await runMatrixCliCommand(options, {
1170
- run: () => getMatrixVerificationSas(id, {
1223
+ await runMatrixCliAccountCommand(options, {
1224
+ run: ({ accountId, cfg }) => getMatrixVerificationSas(id, {
1171
1225
  accountId,
1172
1226
  cfg,
1173
1227
  ...matrixCliVerificationDmLookupOptions(options)
1174
1228
  }),
1175
- onText: (sas) => {
1229
+ onText: (sas, _verbose, accountId) => {
1176
1230
  const requestId = formatMatrixCliText(id);
1177
- printAccountLabel(accountId);
1178
1231
  console.log(`Verification id: ${requestId}`);
1179
1232
  printMatrixVerificationSas(sas);
1180
1233
  printMatrixVerificationSasGuidance(requestId, accountId, formatMatrixVerificationDmFollowupParts(options));
@@ -1209,6 +1262,14 @@ function registerMatrixVerificationCommands(root) {
1209
1262
  });
1210
1263
  verify.command("status").description("Check Matrix device verification status").option("--account <id>", "Account ID (for multi-account setups)").option("--verbose", "Show detailed diagnostics").option("--include-recovery-key", "Include stored recovery key in output").option("--allow-degraded-local-state", "Return best-effort diagnostics without preparing the Matrix account").option("--json", "Output as JSON").action(async (options) => {
1211
1264
  await runMatrixCliAccountCommand(options, {
1265
+ gateway: {
1266
+ method: "matrix.verify.status.owner",
1267
+ params: () => ({
1268
+ accountId: options.account,
1269
+ includeRecoveryKey: options.includeRecoveryKey === true,
1270
+ allowDegradedLocalState: options.allowDegradedLocalState === true
1271
+ })
1272
+ },
1212
1273
  run: ({ accountId, cfg }) => getMatrixVerificationStatus({
1213
1274
  accountId,
1214
1275
  cfg,
@@ -1234,6 +1295,7 @@ function registerMatrixCli(params) {
1234
1295
  registerMatrixEncryptionCommands(root);
1235
1296
  registerMatrixVerificationCommands(root);
1236
1297
  registerMatrixDeviceCommands(root);
1298
+ registerMatrixDoctorCommands(root);
1237
1299
  }
1238
1300
  //#endregion
1239
1301
  export { registerMatrixCli };
@@ -2,7 +2,7 @@ import { definePluginEntry } from "openclaw/plugin-sdk/plugin-entry";
2
2
  //#region extensions/matrix/src/cli-metadata.ts
3
3
  function registerMatrixCliMetadata(api) {
4
4
  api.registerCli(async ({ program }) => {
5
- const { registerMatrixCli } = await import("./cli-mbL9jCro.mjs");
5
+ const { registerMatrixCli } = await import("./cli-CEmWh7wh.mjs");
6
6
  registerMatrixCli({ program });
7
7
  }, { descriptors: [{
8
8
  name: "matrix",
@@ -1,5 +1,5 @@
1
1
  import { i as __exportAll } from "./doctor-contract-CsTNmbMa.mjs";
2
- import { C as resolveMatrixRoomId } from "./send-LCOuTVc1.mjs";
2
+ import { C as resolveMatrixRoomId } from "./send-BprM-Wmx.mjs";
3
3
  import { createLazyRuntimeModule } from "openclaw/plugin-sdk/lazy-runtime";
4
4
  //#region extensions/matrix/src/matrix/actions/client.ts
5
5
  var client_exports = /* @__PURE__ */ __exportAll({
@@ -7,8 +7,8 @@ var client_exports = /* @__PURE__ */ __exportAll({
7
7
  withResolvedRoomAction: () => withResolvedRoomAction,
8
8
  withStartedActionClient: () => withStartedActionClient
9
9
  });
10
- const loadMatrixActionClientRuntime = createLazyRuntimeModule(() => import("./client-bootstrap-D05xy1HB.mjs"));
11
- async function withResolvedActionClient(opts, run, mode = "stop") {
10
+ const loadMatrixActionClientRuntime = createLazyRuntimeModule(() => import("./client-bootstrap-kOIDV4z_.mjs"));
11
+ async function withResolvedActionClient(opts, run, mode = "persist") {
12
12
  const { withResolvedRuntimeMatrixClient } = await loadMatrixActionClientRuntime();
13
13
  return await withResolvedRuntimeMatrixClient(opts, run, mode);
14
14
  }
@@ -5,7 +5,7 @@ import { t as getMatrixScopedEnvVarNames } from "./env-vars-aEBngJPa.mjs";
5
5
  import { o as resolveMatrixBaseConfig, r as listNormalizedMatrixAccountIds, t as findMatrixAccountConfig } from "./account-config-CRsKoMqJ.mjs";
6
6
  import { t as resolveMatrixConfigFieldPath } from "./config-paths-CnREYb1Y.mjs";
7
7
  import { n as validateMatrixHomeserverUrl, t as resolveValidatedMatrixHomeserverUrl } from "./url-validation-CF6pG6eE.mjs";
8
- import { i as repairCurrentTokenStorageMetaDeviceId } from "./storage-DkC6bHgA.mjs";
8
+ import { i as repairCurrentTokenStorageMetaDeviceId } from "./storage-l8V0XsGM.mjs";
9
9
  import { createLazyRuntimeMethod, createLazyRuntimeModule } from "openclaw/plugin-sdk/lazy-runtime";
10
10
  import { DEFAULT_ACCOUNT_ID, normalizeAccountId, normalizeOptionalAccountId } from "openclaw/plugin-sdk/account-id";
11
11
  import { formatErrorMessage, toErrorObject, toStringifiedError } from "openclaw/plugin-sdk/error-runtime";
@@ -15,12 +15,13 @@ import { resolveOptionalIntegerOption } from "openclaw/plugin-sdk/number-runtime
15
15
  import { ssrfPolicyFromDangerouslyAllowPrivateNetwork } from "openclaw/plugin-sdk/ssrf-runtime";
16
16
  import { requireRuntimeConfig } from "openclaw/plugin-sdk/plugin-config-runtime";
17
17
  import { AsyncLocalStorage } from "node:async_hooks";
18
- import { racePromiseWithAbortSignal, raceWithTimeout } from "openclaw/plugin-sdk/time-runtime";
19
18
  import { retryAsync } from "openclaw/plugin-sdk/retry-runtime";
20
19
  import { sleepWithAbort } from "openclaw/plugin-sdk/runtime-env";
21
20
  import { createDeferred } from "openclaw/plugin-sdk/extension-shared";
21
+ import { resolveGlobalSingleton } from "openclaw/plugin-sdk/global-singleton";
22
+ import { racePromiseWithAbortSignal, raceWithTimeout } from "openclaw/plugin-sdk/time-runtime";
22
23
  //#region extensions/matrix/src/matrix/client/auth-request.ts
23
- const loadMatrixAuthClientDeps = createLazyRuntimeModule(() => Promise.all([import("./sdk-Cfc6m7fY.mjs").then((n) => n.t), import("./logging-BKV8TYQq.mjs").then((n) => n.n)]).then(([sdkModule, loggingModule]) => ({
24
+ const loadMatrixAuthClientDeps = createLazyRuntimeModule(() => Promise.all([import("./sdk-ByU8So5S.mjs").then((n) => n.t), import("./logging-BKV8TYQq.mjs").then((n) => n.n)]).then(([sdkModule, loggingModule]) => ({
24
25
  MatrixClient: sdkModule.MatrixClient,
25
26
  ensureMatrixSdkLoggingConfigured: loggingModule.ensureMatrixSdkLoggingConfigured
26
27
  })));
@@ -89,8 +90,8 @@ async function fetchMatrixWhoamiIdentity(params) {
89
90
  }
90
91
  //#endregion
91
92
  //#region extensions/matrix/src/matrix/client/config.ts
92
- const loadMatrixCredentialsReadDeps = createLazyRuntimeModule(() => import("./credentials-read-CqRiEAQa.mjs").then((n) => n.i));
93
- const loadMatrixCredentialsWriteRuntime = createLazyRuntimeModule(() => import("./credentials-Bf9PQ7xs.mjs"));
93
+ const loadMatrixCredentialsReadDeps = createLazyRuntimeModule(() => import("./credentials-read-D2ULV55A.mjs").then((n) => n.i));
94
+ const loadMatrixCredentialsWriteRuntime = createLazyRuntimeModule(() => import("./credentials-CPnJZaZB.mjs"));
94
95
  const loadMatrixSecretInputDeps = createLazyRuntimeModule(() => import("openclaw/plugin-sdk/secret-input-runtime"));
95
96
  function credentialsMatchBackfillAuthLineage(params) {
96
97
  if (!params.stored) return true;
@@ -378,16 +379,21 @@ async function resolveMatrixAuth(params) {
378
379
  ssrfPolicy: resolved.ssrfPolicy,
379
380
  dispatcherPolicy: resolved.dispatcherPolicy
380
381
  });
381
- const login = await retryMatrixAuthRequest("matrix auth login", async () => await loginClient.doRequest("POST", "/_matrix/client/v3/login", void 0, {
382
- type: "m.login.password",
383
- identifier: {
384
- type: "m.id.user",
385
- user: resolved.userId
386
- },
387
- password,
388
- device_id: resolved.deviceId,
389
- initial_device_display_name: resolved.deviceName ?? "OpenClaw Gateway"
390
- }));
382
+ let login;
383
+ try {
384
+ login = await retryMatrixAuthRequest("matrix auth login", async () => await loginClient.doRequest("POST", "/_matrix/client/v3/login", void 0, {
385
+ type: "m.login.password",
386
+ identifier: {
387
+ type: "m.id.user",
388
+ user: resolved.userId
389
+ },
390
+ password,
391
+ device_id: resolved.deviceId,
392
+ initial_device_display_name: resolved.deviceName ?? "OpenClaw Gateway"
393
+ }));
394
+ } finally {
395
+ await loginClient.stopWithoutPersist();
396
+ }
391
397
  const loginAccessToken = login.access_token?.trim();
392
398
  if (!loginAccessToken) throw new Error("Matrix login did not return an access token");
393
399
  const auth = buildResolvedMatrixAuth(resolved, {
@@ -517,10 +523,23 @@ async function awaitMatrixStartupWithAbort(promise, abortSignal) {
517
523
  }
518
524
  //#endregion
519
525
  //#region extensions/matrix/src/matrix/client/shared.ts
520
- const loadMatrixCreateClientDeps = createLazyRuntimeModule(() => import("./create-client-CroC4BVc.mjs"));
526
+ const loadMatrixCreateClientDeps = createLazyRuntimeModule(() => import("./create-client-BS8UYx6N.mjs"));
521
527
  const MATRIX_RETIREMENT_DRAIN_TIMEOUT_MS = 5e3;
522
- const sharedClientStates = /* @__PURE__ */ new Map();
523
- const sharedClientPromises = /* @__PURE__ */ new Map();
528
+ const sharedClientRegistry = resolveGlobalSingleton(Symbol.for("openclaw.matrix.shared-client-registry"), () => ({
529
+ states: /* @__PURE__ */ new Map(),
530
+ promises: /* @__PURE__ */ new Map(),
531
+ storageOwners: /* @__PURE__ */ new Map()
532
+ }));
533
+ const sharedClientStates = sharedClientRegistry.states;
534
+ const sharedClientPromises = sharedClientRegistry.promises;
535
+ const sharedStorageOwners = sharedClientRegistry.storageOwners;
536
+ var MatrixTransportGenerationBusyError = class extends Error {
537
+ constructor() {
538
+ super("Matrix account transport is changing; retry after the account restart finishes.");
539
+ this.code = "MATRIX_ACCOUNT_RESTARTING";
540
+ this.retryable = true;
541
+ }
542
+ };
524
543
  function buildSharedClientKey(auth) {
525
544
  return JSON.stringify([
526
545
  auth.homeserver,
@@ -538,8 +557,9 @@ async function createSharedMatrixClient(params) {
538
557
  client: await createMatrixClient({
539
558
  ...params.auth,
540
559
  localTimeoutMs: params.timeoutMs
541
- }),
560
+ }, params.preparedStorage),
542
561
  key: buildSharedClientKey(params.auth),
562
+ storageOwnerKey: params.preparedStorage.storagePaths?.idbSnapshotPath ?? null,
543
563
  started: false,
544
564
  startPromise: null,
545
565
  phase: "open",
@@ -553,30 +573,17 @@ async function createSharedMatrixClient(params) {
553
573
  };
554
574
  }
555
575
  function deleteSharedClientState(state) {
556
- if (sharedClientStates.get(state.key) === state) sharedClientStates.delete(state.key);
576
+ if (sharedClientStates.get(state.key) === state) {
577
+ sharedClientStates.delete(state.key);
578
+ if (state.storageOwnerKey) sharedStorageOwners.delete(state.storageOwnerKey);
579
+ }
557
580
  const detachLifecycle = state.detachLifecycle;
558
581
  state.detachLifecycle = void 0;
559
582
  detachLifecycle?.();
560
583
  }
561
584
  function bindSharedClientLifecycle(state, lifecycle) {
562
585
  if (!lifecycle) return;
563
- const retire = () => forceRetireState(state);
564
- const onAbort = () => {
565
- retire().catch(() => void 0);
566
- };
567
- lifecycle.signal.addEventListener("abort", onAbort, { once: true });
568
- let removeDisposer;
569
- try {
570
- removeDisposer = lifecycle.onDispose(retire);
571
- } catch (error) {
572
- lifecycle.signal.removeEventListener("abort", onAbort);
573
- throw error;
574
- }
575
- state.detachLifecycle = () => {
576
- lifecycle.signal.removeEventListener("abort", onAbort);
577
- removeDisposer();
578
- };
579
- if (lifecycle.signal.aborted) onAbort();
586
+ state.detachLifecycle = lifecycle.onDispose(() => forceRetireState(state));
580
587
  }
581
588
  async function ensureSharedClientStarted(state, abortSignal) {
582
589
  if (state.started) return;
@@ -626,12 +633,28 @@ async function resolveOpenSharedMatrixClientState(params, lifecycle) {
626
633
  await awaitMatrixStartupWithAbort(pending, params.abortSignal);
627
634
  continue;
628
635
  }
636
+ const { prepareMatrixClientStorage } = await loadMatrixCreateClientDeps();
637
+ const preparedStorage = await prepareMatrixClientStorage(auth);
638
+ throwIfMatrixStartupAborted(params.abortSignal);
639
+ if (sharedClientStates.has(key) || sharedClientPromises.has(key)) continue;
640
+ const storageOwnerKey = preparedStorage.storagePaths?.idbSnapshotPath ?? null;
641
+ const ownerPromise = storageOwnerKey ? sharedStorageOwners.get(storageOwnerKey) : void 0;
642
+ if (ownerPromise) {
643
+ const owner = await awaitMatrixStartupWithAbort(ownerPromise, params.abortSignal);
644
+ if (owner.retirementPromise) {
645
+ await awaitMatrixStartupWithAbort(owner.retirementPromise, params.abortSignal);
646
+ continue;
647
+ }
648
+ throw new MatrixTransportGenerationBusyError();
649
+ }
629
650
  const creationPromise = createSharedMatrixClient({
630
651
  auth,
631
652
  timeoutMs: params.timeoutMs,
632
- lifecycle
653
+ lifecycle,
654
+ preparedStorage
633
655
  });
634
656
  sharedClientPromises.set(key, creationPromise);
657
+ if (storageOwnerKey) sharedStorageOwners.set(storageOwnerKey, creationPromise);
635
658
  try {
636
659
  const created = await creationPromise;
637
660
  sharedClientStates.set(key, created);
@@ -644,6 +667,7 @@ async function resolveOpenSharedMatrixClientState(params, lifecycle) {
644
667
  return created;
645
668
  } finally {
646
669
  if (sharedClientPromises.get(key) === creationPromise) sharedClientPromises.delete(key);
670
+ if (storageOwnerKey && !sharedClientStates.has(key) && sharedStorageOwners.get(storageOwnerKey) === creationPromise) sharedStorageOwners.delete(storageOwnerKey);
647
671
  }
648
672
  }
649
673
  }
@@ -681,40 +705,20 @@ function forceReleaseLeases(state, releasePromise) {
681
705
  state.leases.clear();
682
706
  state.noLeases.resolve();
683
707
  }
684
- async function waitForRetirementDrain(state, task, isPending, timeoutMessage) {
685
- if (!isPending()) return;
686
- await raceWithTimeout(task, MATRIX_RETIREMENT_DRAIN_TIMEOUT_MS, () => {
687
- if (!isPending()) return task;
688
- state.phase = "late-drain";
689
- throw new Error(timeoutMessage);
708
+ function waitForRetirement(retirement) {
709
+ return raceWithTimeout(retirement, MATRIX_RETIREMENT_DRAIN_TIMEOUT_MS, () => {
710
+ throw new Error("Matrix client retirement did not settle within 5000ms");
690
711
  }, { ref: false });
691
712
  }
692
713
  function beginGenerationRetirement(params) {
693
714
  const { state } = params;
694
- if (state.retirementPromise) return state.retirementPromise;
695
- state.phase = "quiescing";
715
+ if (state.retirementPromise) return waitForRetirement(state.retirementPromise);
716
+ state.phase = "retiring";
696
717
  if (state.leases.size === 0) state.noLeases.resolve();
697
718
  const result = createDeferred();
698
719
  state.retirementPromise = result.promise;
699
720
  Promise.resolve().then(async () => {
700
- const startup = state.startPromise;
701
- if (startup) try {
702
- await waitForRetirementDrain(state, startup.catch(() => void 0), () => state.startPromise === startup, `Matrix client startup did not settle within ${MATRIX_RETIREMENT_DRAIN_TIMEOUT_MS}ms during retirement`);
703
- } catch (error) {
704
- state.poisonError = toStringifiedError(error);
705
- result.reject(state.poisonError);
706
- const failure = (await Promise.allSettled([
707
- startup.catch(() => void 0).then(async () => {
708
- state.started = false;
709
- await state.client.stopWithoutPersist();
710
- }),
711
- retireMonitorLeases(state, params.monitorLeases ?? []),
712
- state.noLeases.promise
713
- ])).find((outcome) => outcome.status === "rejected");
714
- if (failure) state.poisonError = toStringifiedError(failure.reason);
715
- else deleteSharedClientState(state);
716
- throw state.poisonError;
717
- }
721
+ await state.startPromise?.catch(() => void 0);
718
722
  try {
719
723
  await state.client.quiesceSync();
720
724
  state.started = false;
@@ -722,30 +726,16 @@ function beginGenerationRetirement(params) {
722
726
  } catch (error) {
723
727
  state.poisonError = toStringifiedError(error);
724
728
  }
725
- let monitorRetired = true;
726
729
  try {
727
730
  await retireMonitorLeases(state, params.monitorLeases ?? []);
728
731
  } catch (error) {
729
732
  state.poisonError ??= toStringifiedError(error);
730
- monitorRetired = false;
731
- }
732
- state.phase = "closing";
733
- let lateLeaseDrain = null;
734
- try {
735
- await waitForRetirementDrain(state, state.noLeases.promise, () => state.leases.size > 0, `Matrix transient leases did not drain within ${MATRIX_RETIREMENT_DRAIN_TIMEOUT_MS}ms`);
736
- } catch (error) {
737
- state.poisonError ??= toStringifiedError(error);
738
- result.reject(state.poisonError);
739
- lateLeaseDrain = state.noLeases.promise;
740
733
  }
734
+ await state.noLeases.promise;
735
+ if (state.poisonError) await state.client.drainPendingDecryptions("matrix failed shutdown").catch((error) => {
736
+ state.poisonError = toStringifiedError(error);
737
+ });
741
738
  let failure = state.poisonError;
742
- let canDelete = monitorRetired;
743
- if (failure) canDelete = await state.client.drainPendingDecryptions("matrix poisoned client shutdown").then(() => true, () => false) && canDelete;
744
- else try {
745
- await state.client.drainPendingDecryptions("matrix shared client final shutdown");
746
- } catch (error) {
747
- failure = state.poisonError = toStringifiedError(error);
748
- }
749
739
  let discard = failure !== null || state.releaseMode === "discard";
750
740
  if (!discard) try {
751
741
  await state.client.stopAndPersist();
@@ -753,19 +743,18 @@ function beginGenerationRetirement(params) {
753
743
  discard = true;
754
744
  if (state.releaseMode === "persist") failure = state.poisonError = toStringifiedError(error);
755
745
  }
756
- if (discard) await state.client.stopWithoutPersist().catch((error) => {
757
- failure = state.poisonError = toStringifiedError(error);
758
- canDelete = false;
759
- });
760
- await lateLeaseDrain;
761
- if (canDelete) deleteSharedClientState(state);
746
+ if (discard) await state.client.stopWithoutPersist();
747
+ deleteSharedClientState(state);
762
748
  if (failure) throw failure;
763
- }).then(result.resolve, result.reject);
749
+ }).then(result.resolve, (error) => {
750
+ state.poisonError = toStringifiedError(error);
751
+ result.reject(state.poisonError);
752
+ });
764
753
  abortTransientLeases(state);
765
- return state.retirementPromise;
754
+ return waitForRetirement(state.retirementPromise);
766
755
  }
767
756
  function createSharedMatrixClientLease(state, role) {
768
- if (state.phase !== "open" || state.poisonError) return null;
757
+ if (state.phase !== "open" || state.poisonError) throw new Error("Matrix client is retiring; retry the operation after shutdown");
769
758
  const leaseState = {
770
759
  abortController: new AbortController(),
771
760
  monitorRetirement: null,
@@ -779,9 +768,6 @@ function createSharedMatrixClientLease(state, role) {
779
768
  client: state.client,
780
769
  role,
781
770
  registerMonitorRetirement: (retirement) => {
782
- if (role !== "monitor") throw new Error("Matrix transient leases cannot register monitor retirement");
783
- if (leaseState.releasePromise || state.phase !== "open") throw new Error("Matrix monitor lease is already retiring");
784
- if (leaseState.monitorRetirement && leaseState.monitorRetirement !== retirement) throw new Error("Matrix monitor retirement is already registered");
785
771
  leaseState.monitorRetirement = retirement;
786
772
  },
787
773
  start: async (abortSignal) => {
@@ -794,10 +780,6 @@ function createSharedMatrixClientLease(state, role) {
794
780
  state.releaseMode = mergeReleaseMode(state.releaseMode, releaseParams.mode ?? "stop");
795
781
  state.leases.delete(leaseState);
796
782
  if (state.leases.size === 0) state.noLeases.resolve();
797
- if (state.phase === "late-drain") {
798
- leaseState.releasePromise = Promise.resolve();
799
- return leaseState.releasePromise;
800
- }
801
783
  const finalMonitor = role === "monitor" && !Array.from(state.leases).some((lease) => lease.role === "monitor");
802
784
  if (role === "monitor" && !finalMonitor) {
803
785
  leaseState.releasePromise = retireMonitorLease(state, leaseState);
@@ -827,37 +809,29 @@ async function acquireSharedMatrixClient(params = {}) {
827
809
  ...params,
828
810
  abortSignal
829
811
  };
830
- while (true) {
812
+ throwIfMatrixStartupAborted(abortSignal);
813
+ const state = await resolveOpenSharedMatrixClientState(acquisition, lifecycle);
814
+ if (abortSignal?.aborted) {
815
+ if (state.phase === "open" && state.leases.size === 0) await beginGenerationRetirement({ state });
831
816
  throwIfMatrixStartupAborted(abortSignal);
832
- const state = await resolveOpenSharedMatrixClientState(acquisition, lifecycle);
833
- if (abortSignal?.aborted) {
834
- if (state.phase === "open" && state.leases.size === 0) await beginGenerationRetirement({ state });
835
- throwIfMatrixStartupAborted(abortSignal);
836
- }
837
- const lease = createSharedMatrixClientLease(state, params.role ?? "transient");
838
- if (!lease) continue;
839
- if (params.startClient !== false) try {
840
- await lease.start(abortSignal);
841
- } catch (error) {
842
- await lease.release({ mode: "stop" }).catch(() => void 0);
843
- throw error;
844
- }
845
- return lease;
846
817
  }
818
+ const lease = createSharedMatrixClientLease(state, params.role ?? "transient");
819
+ if (params.startClient !== false) try {
820
+ await lease.start(abortSignal);
821
+ } catch (error) {
822
+ await lease.release({ mode: "stop" }).catch(() => void 0);
823
+ throw error;
824
+ }
825
+ return lease;
847
826
  }
848
827
  async function forceRetireState(state) {
849
- if (state.phase === "late-drain") throw state.poisonError ?? /* @__PURE__ */ new Error("Matrix client generation is still retiring");
850
828
  state.releaseMode = mergeReleaseMode(state.releaseMode, "stop");
851
829
  const retirementPromise = beginGenerationRetirement({
852
830
  state,
853
831
  monitorLeases: Array.from(state.leases).filter((lease) => lease.role === "monitor")
854
832
  });
855
833
  forceReleaseLeases(state, retirementPromise);
856
- try {
857
- await retirementPromise;
858
- } catch (error) {
859
- if (sharedClientStates.get(state.key) === state) throw state.poisonError ?? error;
860
- }
834
+ await retirementPromise;
861
835
  }
862
836
  async function stopSharedClientForAccount(auth) {
863
837
  const state = sharedClientStates.get(buildSharedClientKey(auth));
@@ -881,7 +855,7 @@ var client_exports = /* @__PURE__ */ __exportAll({
881
855
  stopSharedClientForAccount: () => stopSharedClientForAccount,
882
856
  validateMatrixHomeserverUrl: () => validateMatrixHomeserverUrl
883
857
  });
884
- const loadMatrixClientRuntime = createLazyRuntimeModule(() => import("./create-client-CroC4BVc.mjs"));
858
+ const loadMatrixClientRuntime = createLazyRuntimeModule(() => import("./create-client-BS8UYx6N.mjs"));
885
859
  const createMatrixClient = createLazyRuntimeMethod(loadMatrixClientRuntime, (runtime) => runtime.createMatrixClient);
886
860
  //#endregion
887
861
  export { isMatrixStartupAbortError as a, getMatrixMonitorTaskSignal as c, resolveMatrixAuthContext as d, createMatrixStartupAbortError as i, backfillMatrixAuthDeviceIdAfterStartup as l, acquireSharedMatrixClient as n, throwIfMatrixStartupAborted as o, awaitMatrixStartupWithAbort as r, createMatrixMonitorTaskRunner as s, client_exports as t, resolveMatrixAuth as u };