@openclaw/matrix 2026.10.5-beta.4 → 2026.10.10-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (313) hide show
  1. package/dist/.setup/{approval-handler.runtime-rxLn8CbP.mjs → approval-handler.runtime-CsqMdj7h.mjs} +9 -9
  2. package/dist/.setup/{approval-reactions-DhB6gNPU.mjs → approval-reactions-D2pEUrFS.mjs} +1 -1
  3. package/dist/.setup/{channel-BcwGspPw.mjs → channel-Dw4_imdd.mjs} +132 -111
  4. package/dist/.setup/{channel.runtime-CUc6rbu1.mjs → channel.runtime-2EEtIlyu.mjs} +6 -6
  5. package/dist/.setup/{channel.setup-CwuYD_CT.mjs → channel.setup-Be8TYKMA.mjs} +8 -3
  6. package/dist/.setup/{cli-mbL9jCro.mjs → cli-CEmWh7wh.mjs} +99 -37
  7. package/dist/.setup/{cli-metadata-6MOGuyHq.mjs → cli-metadata-CBLGwJT6.mjs} +1 -1
  8. package/dist/.setup/{client-BlTvpEWC.mjs → client-BKiiI29H.mjs} +3 -3
  9. package/dist/.setup/{client-vPPbaxNp.mjs → client-C4Gibhzl.mjs} +94 -120
  10. package/dist/.setup/{client-bootstrap-D05xy1HB.mjs → client-bootstrap-kOIDV4z_.mjs} +3 -3
  11. package/dist/.setup/{create-client-CroC4BVc.mjs → create-client-BS8UYx6N.mjs} +23 -15
  12. package/dist/.setup/{credentials-Bf9PQ7xs.mjs → credentials-CPnJZaZB.mjs} +3 -5
  13. package/dist/.setup/{credentials-read-CqRiEAQa.mjs → credentials-read-D2ULV55A.mjs} +12 -4
  14. package/dist/.setup/{crypto-runtime-CpJ0b7vY.mjs → crypto-runtime-D8yY7kjD.mjs} +168 -290
  15. package/dist/.setup/crypto-state-store-D4wrCvFs.mjs +185 -0
  16. package/dist/.setup/crypto-store-ownership-Z_Y5WRKr.mjs +174 -0
  17. package/dist/.setup/crypto-unsafe-state-doctor-C8szCYmf.mjs +54 -0
  18. package/dist/.setup/{directory-live-B1WbfSHo.mjs → directory-live-BpSz-FQB.mjs} +1 -1
  19. package/dist/.setup/{draft-stream-Bdrh7dRt.mjs → draft-stream-DYf0th1n.mjs} +1 -1
  20. package/dist/.setup/{exec-approvals-BgNWWJg1.mjs → exec-approvals-DaM-5OA5.mjs} +33 -43
  21. package/dist/.setup/{file-sync-store-BdKx_gMi.mjs → file-sync-store-CUH8EAJq.mjs} +3 -3
  22. package/dist/.setup/idb-persistence-BHTYPRe_.mjs +233 -0
  23. package/dist/.setup/idb-persistence-lock-Bh3ZLIsE.mjs +14 -0
  24. package/dist/.setup/{messages-B1CZqU8u.mjs → messages-_XHVg3do.mjs} +3 -18
  25. package/dist/.setup/{monitor-Dk_fQL1k.mjs → monitor-DRUSJ_Ev.mjs} +31 -39
  26. package/dist/.setup/{onboarding-CrSexor_.mjs → onboarding-CK9Ksgio.mjs} +3 -3
  27. package/dist/.setup/{outbound-LR3SqPIq.mjs → outbound-D5Z_4FBg.mjs} +28 -36
  28. package/dist/.setup/{profile-update-C7bjaGR6.mjs → profile-update--Pf3jCXD.mjs} +2 -2
  29. package/dist/.setup/{reaction-events-CTSvOlXO.mjs → reaction-events-BG9spedG.mjs} +6 -6
  30. package/dist/.setup/{resolve-targets-BVVbbvP6.mjs → resolve-targets-BJ5sIKeM.mjs} +1 -1
  31. package/dist/.setup/{retired-state-DW5pLH05.mjs → retired-state-DOCruzWd.mjs} +10 -10
  32. package/dist/.setup/{room-info-9Uqlpt1V.mjs → room-info-BE7bbX_c.mjs} +3 -3
  33. package/dist/.setup/runtime-setter-api-i2MOXoT3.mjs +2 -0
  34. package/dist/.setup/{sdk-Cfc6m7fY.mjs → sdk-ByU8So5S.mjs} +242 -139
  35. package/dist/.setup/secret-contract-DxyzKSzf.mjs +90 -0
  36. package/dist/.setup/secret-contract-api-Dukgvike.mjs +2 -0
  37. package/dist/.setup/{send-LCOuTVc1.mjs → send-BprM-Wmx.mjs} +19 -42
  38. package/dist/.setup/{setup-bootstrap-CV-hHBXu.mjs → setup-bootstrap-DmznRqYe.mjs} +2 -6
  39. package/dist/.setup/{setup-core-CKnNTfgD.mjs → setup-core-DcCk1_Tv.mjs} +4 -7
  40. package/dist/.setup/setup-plugin-api-BU6UGksW.mjs +2 -0
  41. package/dist/.setup/{startup-verification-CgfUb4yJ.mjs → startup-verification-UU8DUvi4.mjs} +5 -13
  42. package/dist/.setup/state-layout-walk-BQMgMykU.mjs +27 -0
  43. package/dist/.setup/{storage-DkC6bHgA.mjs → storage-l8V0XsGM.mjs} +7 -166
  44. package/dist/.setup/{subagent-hooks-D8jyeQsO.mjs → subagent-hooks-CSY4iwa_.mjs} +7 -6
  45. package/dist/.setup/{sync-cache-state-D4G-fi3t.mjs → sync-cache-state-Cnm4TCEI.mjs} +1 -1
  46. package/dist/.setup/thread-bindings-rrwQAS6R.mjs +620 -0
  47. package/dist/.setup/{thread-bindings-shared-CbsFNbAY.mjs → thread-bindings-shared-CPjUA0Ib.mjs} +26 -5
  48. package/dist/.setup/{tool-actions-DAp6_XSJ.mjs → tool-actions-DBrk6Yei.mjs} +9 -11
  49. package/dist/.setup/{verification-B3VswneT.mjs → verification--qUbmRd-.mjs} +2 -2
  50. package/dist/api.js +6 -6
  51. package/dist/auth-presence.js +16 -2
  52. package/dist/channel-plugin-api.js +1 -2
  53. package/dist/cli-metadata.js +1 -2
  54. package/dist/contract-api.js +2 -2
  55. package/dist/doctor-contract-api.js +20 -27
  56. package/dist/index.js +38 -12
  57. package/dist/plugin-entry.handlers.runtime.js +32 -5
  58. package/dist/runtime-api.js +3 -3
  59. package/dist/runtime-setter-api.js +1 -2
  60. package/dist/secret-contract-api.js +1 -2
  61. package/dist/session-binding-contract-api.js +1 -1
  62. package/dist/setup-entry.js +3 -3
  63. package/dist/setup-plugin-api.js +1 -2
  64. package/dist/subagent-hooks-api.js +1 -1
  65. package/dist/thread-binding-api.js +1 -2
  66. package/dist/thread-bindings-runtime.js +1 -2
  67. package/node_modules/@openclaw/fs-safe/CHANGELOG.md +148 -0
  68. package/node_modules/@openclaw/fs-safe/README.md +20 -4
  69. package/node_modules/@openclaw/fs-safe/dist/advanced.d.ts +2 -1
  70. package/node_modules/@openclaw/fs-safe/dist/advanced.js +1 -0
  71. package/node_modules/@openclaw/fs-safe/dist/archive-merge.js +28 -3
  72. package/node_modules/@openclaw/fs-safe/dist/archive-parser.wasm +0 -0
  73. package/node_modules/@openclaw/fs-safe/dist/archive-read.js +11 -5
  74. package/node_modules/@openclaw/fs-safe/dist/archive-zip-loader.js +4 -2
  75. package/node_modules/@openclaw/fs-safe/dist/archive.js +2 -2
  76. package/node_modules/@openclaw/fs-safe/dist/atomic-io.js +2 -2
  77. package/node_modules/@openclaw/fs-safe/dist/bounded-read.d.ts +1 -0
  78. package/node_modules/@openclaw/fs-safe/dist/bounded-read.js +9 -2
  79. package/node_modules/@openclaw/fs-safe/dist/clone-metadata.d.ts +2 -0
  80. package/node_modules/@openclaw/fs-safe/dist/clone-metadata.js +2 -1
  81. package/node_modules/@openclaw/fs-safe/dist/config.d.ts +6 -0
  82. package/node_modules/@openclaw/fs-safe/dist/config.js +5 -0
  83. package/node_modules/@openclaw/fs-safe/dist/copy-file-input.d.ts +3 -1
  84. package/node_modules/@openclaw/fs-safe/dist/copy-file-input.js +8 -7
  85. package/node_modules/@openclaw/fs-safe/dist/copy-link.d.ts +26 -0
  86. package/node_modules/@openclaw/fs-safe/dist/copy-link.js +170 -0
  87. package/node_modules/@openclaw/fs-safe/dist/copy-metadata.d.ts +9 -0
  88. package/node_modules/@openclaw/fs-safe/dist/copy-metadata.js +39 -0
  89. package/node_modules/@openclaw/fs-safe/dist/copy-path-admission.js +11 -2
  90. package/node_modules/@openclaw/fs-safe/dist/copy-root-file-sync.d.ts +2 -4
  91. package/node_modules/@openclaw/fs-safe/dist/copy-root-file-sync.js +4 -2
  92. package/node_modules/@openclaw/fs-safe/dist/copy-tree-portable.js +3 -6
  93. package/node_modules/@openclaw/fs-safe/dist/copy.js +3 -3
  94. package/node_modules/@openclaw/fs-safe/dist/create.js +1 -1
  95. package/node_modules/@openclaw/fs-safe/dist/creation-boundary.js +7 -4
  96. package/node_modules/@openclaw/fs-safe/dist/darwin-acl.d.ts +12 -0
  97. package/node_modules/@openclaw/fs-safe/dist/darwin-acl.js +29 -0
  98. package/node_modules/@openclaw/fs-safe/dist/directory-durability.d.ts +7 -4
  99. package/node_modules/@openclaw/fs-safe/dist/directory-guard.js +20 -5
  100. package/node_modules/@openclaw/fs-safe/dist/directory-mode-node.d.ts +3 -0
  101. package/node_modules/@openclaw/fs-safe/dist/directory-mode-node.js +27 -2
  102. package/node_modules/@openclaw/fs-safe/dist/directory-receipt.d.ts +7 -7
  103. package/node_modules/@openclaw/fs-safe/dist/directory-receipt.js +9 -4
  104. package/node_modules/@openclaw/fs-safe/dist/durability.d.ts +2 -1
  105. package/node_modules/@openclaw/fs-safe/dist/entry-publication.js +2 -2
  106. package/node_modules/@openclaw/fs-safe/dist/exact-identity.d.ts +17 -0
  107. package/node_modules/@openclaw/fs-safe/dist/exact-identity.js +29 -0
  108. package/node_modules/@openclaw/fs-safe/dist/file-handle-transfer.js +4 -2
  109. package/node_modules/@openclaw/fs-safe/dist/file-hash.d.ts +1 -1
  110. package/node_modules/@openclaw/fs-safe/dist/file-hash.js +11 -9
  111. package/node_modules/@openclaw/fs-safe/dist/file-identity.d.ts +7 -1
  112. package/node_modules/@openclaw/fs-safe/dist/file-identity.js +27 -5
  113. package/node_modules/@openclaw/fs-safe/dist/file-lock-sync-admission.js +1 -2
  114. package/node_modules/@openclaw/fs-safe/dist/file-lock-sync.js +8 -1
  115. package/node_modules/@openclaw/fs-safe/dist/file-lock.d.ts +1 -0
  116. package/node_modules/@openclaw/fs-safe/dist/file-lock.js +1 -0
  117. package/node_modules/@openclaw/fs-safe/dist/file-write-lease.d.ts +9 -0
  118. package/node_modules/@openclaw/fs-safe/dist/file-write-lease.js +42 -0
  119. package/node_modules/@openclaw/fs-safe/dist/guarded-mkdir.d.ts +1 -0
  120. package/node_modules/@openclaw/fs-safe/dist/guarded-mkdir.js +22 -15
  121. package/node_modules/@openclaw/fs-safe/dist/guest-native-python.js +3 -0
  122. package/node_modules/@openclaw/fs-safe/dist/hardlink-fallback.d.ts +1 -0
  123. package/node_modules/@openclaw/fs-safe/dist/hardlink-fallback.js +5 -0
  124. package/node_modules/@openclaw/fs-safe/dist/index.d.ts +1 -0
  125. package/node_modules/@openclaw/fs-safe/dist/index.js +1 -0
  126. package/node_modules/@openclaw/fs-safe/dist/json-durable-queue-ownership.js +16 -3
  127. package/node_modules/@openclaw/fs-safe/dist/local-file-descriptor.js +24 -13
  128. package/node_modules/@openclaw/fs-safe/dist/native-binding.d.ts +85 -18
  129. package/node_modules/@openclaw/fs-safe/dist/native-config.d.ts +5 -0
  130. package/node_modules/@openclaw/fs-safe/dist/native-config.js +11 -0
  131. package/node_modules/@openclaw/fs-safe/dist/native-directory-observation.js +6 -4
  132. package/node_modules/@openclaw/fs-safe/dist/native-fallback-warning.d.ts +2 -1
  133. package/node_modules/@openclaw/fs-safe/dist/native-fallback-warning.js +26 -2
  134. package/node_modules/@openclaw/fs-safe/dist/native-guidance.d.ts +3 -0
  135. package/node_modules/@openclaw/fs-safe/dist/native-guidance.js +21 -0
  136. package/node_modules/@openclaw/fs-safe/dist/native-move-fallback.d.ts +1 -1
  137. package/node_modules/@openclaw/fs-safe/dist/native-move-fallback.js +2 -0
  138. package/node_modules/@openclaw/fs-safe/dist/native-operations.js +8 -6
  139. package/node_modules/@openclaw/fs-safe/dist/native-parent-admission.d.ts +44 -4
  140. package/node_modules/@openclaw/fs-safe/dist/native-parent-admission.js +85 -15
  141. package/node_modules/@openclaw/fs-safe/dist/native-pinned-write-windows.d.ts +3 -3
  142. package/node_modules/@openclaw/fs-safe/dist/native-pinned-write-windows.js +33 -6
  143. package/node_modules/@openclaw/fs-safe/dist/native-pinned-write.d.ts +4 -1
  144. package/node_modules/@openclaw/fs-safe/dist/native-pinned-write.js +22 -3
  145. package/node_modules/@openclaw/fs-safe/dist/native-policy-directory-observation.js +4 -3
  146. package/node_modules/@openclaw/fs-safe/dist/native-policy-parent.d.ts +1 -1
  147. package/node_modules/@openclaw/fs-safe/dist/native-policy-parent.js +3 -0
  148. package/node_modules/@openclaw/fs-safe/dist/native-staged-file-metadata.d.ts +3 -0
  149. package/node_modules/@openclaw/fs-safe/dist/native-staged-file-metadata.js +16 -0
  150. package/node_modules/@openclaw/fs-safe/dist/native-staged-file.d.ts +1 -1
  151. package/node_modules/@openclaw/fs-safe/dist/native-staged-file.js +15 -5
  152. package/node_modules/@openclaw/fs-safe/dist/native-stat-identity.d.ts +3 -0
  153. package/node_modules/@openclaw/fs-safe/dist/native-stat-identity.js +7 -0
  154. package/node_modules/@openclaw/fs-safe/dist/native-status.d.ts +17 -0
  155. package/node_modules/@openclaw/fs-safe/dist/native-status.js +30 -0
  156. package/node_modules/@openclaw/fs-safe/dist/native.d.ts +31 -4
  157. package/node_modules/@openclaw/fs-safe/dist/native.js +107 -9
  158. package/node_modules/@openclaw/fs-safe/dist/opened-realpath.js +9 -1
  159. package/node_modules/@openclaw/fs-safe/dist/overwrite-file-handle.js +4 -1
  160. package/node_modules/@openclaw/fs-safe/dist/owner-dacl-batch.js +1 -1
  161. package/node_modules/@openclaw/fs-safe/dist/owner-dacl.js +1 -1
  162. package/node_modules/@openclaw/fs-safe/dist/permission-exec.js +9 -1
  163. package/node_modules/@openclaw/fs-safe/dist/permissions-public.d.ts +1 -0
  164. package/node_modules/@openclaw/fs-safe/dist/permissions-public.js +1 -0
  165. package/node_modules/@openclaw/fs-safe/dist/permissions-windows.js +83 -47
  166. package/node_modules/@openclaw/fs-safe/dist/pinned-open.d.ts +2 -0
  167. package/node_modules/@openclaw/fs-safe/dist/pinned-open.js +8 -3
  168. package/node_modules/@openclaw/fs-safe/dist/pinned-write-input.js +13 -0
  169. package/node_modules/@openclaw/fs-safe/dist/pinned-write-staged.js +10 -8
  170. package/node_modules/@openclaw/fs-safe/dist/pinned-write-types.d.ts +2 -1
  171. package/node_modules/@openclaw/fs-safe/dist/pinned-write.js +7 -5
  172. package/node_modules/@openclaw/fs-safe/dist/pipe.d.ts +9 -0
  173. package/node_modules/@openclaw/fs-safe/dist/pipe.js +26 -0
  174. package/node_modules/@openclaw/fs-safe/dist/private-directory.js +1 -1
  175. package/node_modules/@openclaw/fs-safe/dist/private-producer-handoff.js +2 -5
  176. package/node_modules/@openclaw/fs-safe/dist/private-temp-workspace.d.ts +3 -2
  177. package/node_modules/@openclaw/fs-safe/dist/private-temp-workspace.js +38 -10
  178. package/node_modules/@openclaw/fs-safe/dist/publish-copy-stage.js +92 -10
  179. package/node_modules/@openclaw/fs-safe/dist/publish-file-failure.d.ts +3 -0
  180. package/node_modules/@openclaw/fs-safe/dist/publish-file-failure.js +3 -0
  181. package/node_modules/@openclaw/fs-safe/dist/publish-file.d.ts +5 -3
  182. package/node_modules/@openclaw/fs-safe/dist/publish-file.js +26 -20
  183. package/node_modules/@openclaw/fs-safe/dist/read-opened-file.d.ts +2 -0
  184. package/node_modules/@openclaw/fs-safe/dist/read-opened-file.js +3 -4
  185. package/node_modules/@openclaw/fs-safe/dist/realpath.js +32 -0
  186. package/node_modules/@openclaw/fs-safe/dist/regular-file.d.ts +4 -0
  187. package/node_modules/@openclaw/fs-safe/dist/regular-file.js +11 -15
  188. package/node_modules/@openclaw/fs-safe/dist/replace-file-descriptor.js +3 -2
  189. package/node_modules/@openclaw/fs-safe/dist/root-copy.d.ts +18 -0
  190. package/node_modules/@openclaw/fs-safe/dist/root-copy.js +128 -0
  191. package/node_modules/@openclaw/fs-safe/dist/root-create-native.d.ts +8 -13
  192. package/node_modules/@openclaw/fs-safe/dist/root-create-native.js +252 -27
  193. package/node_modules/@openclaw/fs-safe/dist/root-directory-creation.js +5 -1
  194. package/node_modules/@openclaw/fs-safe/dist/root-directory-list-types.d.ts +11 -8
  195. package/node_modules/@openclaw/fs-safe/dist/root-directory-list.js +35 -13
  196. package/node_modules/@openclaw/fs-safe/dist/root-file-open-batch-sync.d.ts +8 -0
  197. package/node_modules/@openclaw/fs-safe/dist/root-file-open-batch-sync.js +108 -0
  198. package/node_modules/@openclaw/fs-safe/dist/root-file.d.ts +7 -0
  199. package/node_modules/@openclaw/fs-safe/dist/root-file.js +15 -0
  200. package/node_modules/@openclaw/fs-safe/dist/root-impl.d.ts +2 -0
  201. package/node_modules/@openclaw/fs-safe/dist/root-impl.js +154 -175
  202. package/node_modules/@openclaw/fs-safe/dist/root-mkdir-native.d.ts +2 -0
  203. package/node_modules/@openclaw/fs-safe/dist/root-mkdir-native.js +239 -0
  204. package/node_modules/@openclaw/fs-safe/dist/root-move-noreplace.js +37 -15
  205. package/node_modules/@openclaw/fs-safe/dist/root-native-creation-path.d.ts +32 -0
  206. package/node_modules/@openclaw/fs-safe/dist/root-native-creation-path.js +56 -0
  207. package/node_modules/@openclaw/fs-safe/dist/root-options.d.ts +2 -0
  208. package/node_modules/@openclaw/fs-safe/dist/root-public-types.d.ts +1 -0
  209. package/node_modules/@openclaw/fs-safe/dist/root-remove-native.js +95 -16
  210. package/node_modules/@openclaw/fs-safe/dist/root-remove.js +6 -4
  211. package/node_modules/@openclaw/fs-safe/dist/root-walk.js +23 -19
  212. package/node_modules/@openclaw/fs-safe/dist/root-write-admission.js +8 -6
  213. package/node_modules/@openclaw/fs-safe/dist/root-write-publication.js +5 -1
  214. package/node_modules/@openclaw/fs-safe/dist/secure-file-windows.js +3 -1
  215. package/node_modules/@openclaw/fs-safe/dist/secure-file.d.ts +2 -0
  216. package/node_modules/@openclaw/fs-safe/dist/secure-file.js +10 -4
  217. package/node_modules/@openclaw/fs-safe/dist/sibling-staged-file.js +1 -1
  218. package/node_modules/@openclaw/fs-safe/dist/sidecar-lock-reclaim.js +2 -2
  219. package/node_modules/@openclaw/fs-safe/dist/sidecar-lock-retained.js +1 -1
  220. package/node_modules/@openclaw/fs-safe/dist/sidecar-lock-target.js +8 -1
  221. package/node_modules/@openclaw/fs-safe/dist/staged-directory.d.ts +13 -0
  222. package/node_modules/@openclaw/fs-safe/dist/staged-directory.js +29 -0
  223. package/node_modules/@openclaw/fs-safe/dist/temp-workspace-child-admission.js +5 -3
  224. package/node_modules/@openclaw/fs-safe/dist/temp-workspace-descriptor.d.ts +8 -0
  225. package/node_modules/@openclaw/fs-safe/dist/temp-workspace-descriptor.js +13 -2
  226. package/node_modules/@openclaw/fs-safe/dist/temp-workspace-owner.js +71 -3
  227. package/node_modules/@openclaw/fs-safe/dist/temp-workspace-ownership.d.ts +2 -1
  228. package/node_modules/@openclaw/fs-safe/dist/temp-workspace-ownership.js +22 -0
  229. package/node_modules/@openclaw/fs-safe/dist/temp-workspace-types.d.ts +3 -0
  230. package/node_modules/@openclaw/fs-safe/dist/test-hooks.d.ts +1 -0
  231. package/node_modules/@openclaw/fs-safe/dist/test-hooks.js +1 -0
  232. package/node_modules/@openclaw/fs-safe/dist/trash.js +2 -2
  233. package/node_modules/@openclaw/fs-safe/dist/types.d.ts +4 -0
  234. package/node_modules/@openclaw/fs-safe/dist/watch-native.js +2 -2
  235. package/node_modules/@openclaw/fs-safe/dist/windows-appcontainer.d.ts +5 -0
  236. package/node_modules/@openclaw/fs-safe/dist/windows-appcontainer.js +39 -0
  237. package/node_modules/@openclaw/fs-safe/dist/windows-owner.d.ts +1 -0
  238. package/node_modules/@openclaw/fs-safe/dist/windows-owner.js +25 -36
  239. package/node_modules/@openclaw/fs-safe/dist/windows-security-command.js +24 -5
  240. package/node_modules/@openclaw/fs-safe/dist/windows-security-facts.d.ts +2 -1
  241. package/node_modules/@openclaw/fs-safe/dist/windows-security-facts.js +4 -0
  242. package/node_modules/@openclaw/fs-safe/dist/windows-security-helper.d.ts +2 -0
  243. package/node_modules/@openclaw/fs-safe/dist/windows-security-helper.exe +0 -0
  244. package/node_modules/@openclaw/fs-safe/dist/windows-security-helper.js +7 -0
  245. package/node_modules/@openclaw/fs-safe/dist/windows-test-hooks.d.ts +16 -0
  246. package/node_modules/@openclaw/fs-safe/dist/windows-test-hooks.js +51 -0
  247. package/node_modules/@openclaw/fs-safe/dist/write-file-handle.d.ts +1 -0
  248. package/node_modules/@openclaw/fs-safe/dist/write-file-handle.js +12 -10
  249. package/node_modules/@openclaw/fs-safe/docs/advanced.md +2 -1
  250. package/node_modules/@openclaw/fs-safe/docs/archive.md +16 -0
  251. package/node_modules/@openclaw/fs-safe/docs/config.md +71 -1
  252. package/node_modules/@openclaw/fs-safe/docs/contributing.md +45 -5
  253. package/node_modules/@openclaw/fs-safe/docs/copy.md +45 -5
  254. package/node_modules/@openclaw/fs-safe/docs/durability.md +34 -7
  255. package/node_modules/@openclaw/fs-safe/docs/errors.md +8 -0
  256. package/node_modules/@openclaw/fs-safe/docs/guest.md +2 -0
  257. package/node_modules/@openclaw/fs-safe/docs/install.md +47 -27
  258. package/node_modules/@openclaw/fs-safe/docs/migrating-to-0.5.md +6 -6
  259. package/node_modules/@openclaw/fs-safe/docs/migrating-to-0.6.md +1 -1
  260. package/node_modules/@openclaw/fs-safe/docs/native-helper.md +79 -6
  261. package/node_modules/@openclaw/fs-safe/docs/native.md +279 -8
  262. package/node_modules/@openclaw/fs-safe/docs/permissions.md +64 -15
  263. package/node_modules/@openclaw/fs-safe/docs/pipe.md +81 -0
  264. package/node_modules/@openclaw/fs-safe/docs/platform-capabilities.md +63 -0
  265. package/node_modules/@openclaw/fs-safe/docs/public-api.md +10 -0
  266. package/node_modules/@openclaw/fs-safe/docs/queue-link-free-design.md +237 -0
  267. package/node_modules/@openclaw/fs-safe/docs/quickstart.md +23 -3
  268. package/node_modules/@openclaw/fs-safe/docs/reading.md +56 -2
  269. package/node_modules/@openclaw/fs-safe/docs/regular-file.md +2 -0
  270. package/node_modules/@openclaw/fs-safe/docs/secret-file.md +5 -5
  271. package/node_modules/@openclaw/fs-safe/docs/secure-file.md +1 -1
  272. package/node_modules/@openclaw/fs-safe/docs/security-model.md +35 -0
  273. package/node_modules/@openclaw/fs-safe/docs/sidecar-lock.md +31 -13
  274. package/node_modules/@openclaw/fs-safe/docs/staged-file.md +18 -0
  275. package/node_modules/@openclaw/fs-safe/docs/store.md +15 -0
  276. package/node_modules/@openclaw/fs-safe/docs/temp.md +39 -0
  277. package/node_modules/@openclaw/fs-safe/docs/testing.md +13 -0
  278. package/node_modules/@openclaw/fs-safe/docs/types.md +51 -81
  279. package/node_modules/@openclaw/fs-safe/docs/walk.md +4 -1
  280. package/node_modules/@openclaw/fs-safe/docs/watch.md +3 -2
  281. package/node_modules/@openclaw/fs-safe/docs/writing.md +121 -14
  282. package/node_modules/@openclaw/fs-safe/package.json +21 -12
  283. package/node_modules/@openclaw/fs-safe-darwin-arm64/fs-safe-native.node +0 -0
  284. package/node_modules/@openclaw/fs-safe-darwin-arm64/package.json +1 -1
  285. package/node_modules/@openclaw/fs-safe-darwin-x64/fs-safe-native.node +0 -0
  286. package/node_modules/@openclaw/fs-safe-darwin-x64/package.json +1 -1
  287. package/node_modules/@openclaw/fs-safe-freebsd-arm64/fs-safe-native.node +0 -0
  288. package/node_modules/@openclaw/fs-safe-freebsd-arm64/package.json +29 -0
  289. package/node_modules/@openclaw/fs-safe-freebsd-x64/fs-safe-native.node +0 -0
  290. package/node_modules/@openclaw/fs-safe-freebsd-x64/package.json +29 -0
  291. package/node_modules/@openclaw/fs-safe-linux-arm64-gnu/fs-safe-native.node +0 -0
  292. package/node_modules/@openclaw/fs-safe-linux-arm64-gnu/package.json +1 -1
  293. package/node_modules/@openclaw/fs-safe-linux-arm64-musl/fs-safe-native.node +0 -0
  294. package/node_modules/@openclaw/fs-safe-linux-arm64-musl/package.json +1 -1
  295. package/node_modules/@openclaw/fs-safe-linux-x64-gnu/fs-safe-native.node +0 -0
  296. package/node_modules/@openclaw/fs-safe-linux-x64-gnu/package.json +1 -1
  297. package/node_modules/@openclaw/fs-safe-linux-x64-musl/fs-safe-native.node +0 -0
  298. package/node_modules/@openclaw/fs-safe-linux-x64-musl/package.json +1 -1
  299. package/node_modules/@openclaw/fs-safe-win32-arm64-msvc/fs-safe-native.node +0 -0
  300. package/node_modules/@openclaw/fs-safe-win32-arm64-msvc/package.json +29 -0
  301. package/node_modules/@openclaw/fs-safe-win32-x64-msvc/fs-safe-native.node +0 -0
  302. package/node_modules/@openclaw/fs-safe-win32-x64-msvc/package.json +1 -1
  303. package/node_modules/typebox/build/value/clean/from_object.mjs +1 -1
  304. package/node_modules/typebox/package.json +1 -1
  305. package/openclaw.plugin.json +3 -0
  306. package/package.json +7 -6
  307. package/dist/.setup/runtime-setter-api-DtxDAM-x.mjs +0 -3
  308. package/dist/.setup/secret-contract-DSBRvhdZ.mjs +0 -95
  309. package/dist/.setup/secret-contract-api-DzEJ-X7n.mjs +0 -3
  310. package/dist/.setup/setup-plugin-api-BDAYk1a5.mjs +0 -3
  311. package/dist/.setup/thread-bindings-CT4P-OSZ.mjs +0 -365
  312. package/node_modules/@openclaw/fs-safe/dist/windows-security-bridge.cs +0 -336
  313. package/node_modules/@openclaw/fs-safe/dist/windows-security-bridge.ps1 +0 -90
@@ -0,0 +1,620 @@
1
+ import { t as getMatrixRuntime } from "./runtime-1kn1P6io.mjs";
2
+ import { a as listBindingsForAccount, c as setBindingRecord, d as setMatrixThreadBindingManagerEntry, m as toSessionBindingRecord, o as removeBindingRecord, r as getMatrixThreadBindingManagerEntry, s as resolveBindingKey, t as deleteMatrixThreadBindingManagerEntry } from "./thread-bindings-shared-CPjUA0Ib.mjs";
3
+ import { o as resolveMatrixSqliteStateEnv, r as assertMatrixSupportedStateFile, s as resolveMatrixSqliteStateKey } from "./retired-state-DOCruzWd.mjs";
4
+ import { a as resolveMatrixStateFilePath, t as claimCurrentTokenStorageState } from "./storage-l8V0XsGM.mjs";
5
+ import { r as sendMessageMatrix } from "./send-BprM-Wmx.mjs";
6
+ import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
7
+ import { createHash } from "node:crypto";
8
+ import path from "node:path";
9
+ import { resolveOptionalIntegerOption } from "openclaw/plugin-sdk/number-runtime";
10
+ import { registerSessionBindingAdapterV2, resolveThreadBindingFarewellText, resolveThreadBindingLifecycle, unregisterSessionBindingAdapter, warnPluginSdkDeprecation } from "openclaw/plugin-sdk/thread-bindings-session-runtime";
11
+ import { hasSqliteWorkerOutcomeUnknown } from "openclaw/plugin-sdk/sqlite-runtime";
12
+ import { resolveSessionAgentIdStrict } from "openclaw/plugin-sdk/agent-scope-runtime";
13
+ import { resolveAgentIdFromSessionKey } from "openclaw/plugin-sdk/session-key-runtime";
14
+ //#region extensions/matrix/src/matrix/thread-bindings-session-adapter.ts
15
+ function sameBindingIncarnation(a, b) {
16
+ return resolveBindingKey(a) === resolveBindingKey(b) && a.boundAt === b.boundAt && a.targetSessionKey === b.targetSessionKey && a.targetKind === b.targetKind;
17
+ }
18
+ function buildMatrixBindingIntroText(params) {
19
+ const introText = normalizeOptionalString(params.metadata?.introText);
20
+ if (introText) return introText;
21
+ const label = normalizeOptionalString(params.metadata?.label);
22
+ const agentId = normalizeOptionalString(params.metadata?.agentId) || resolveAgentIdFromSessionKey(params.targetSessionKey);
23
+ return `⚙️ ${label || agentId || "session"} session active. Messages here go directly to this session.`;
24
+ }
25
+ async function sendBindingMessage(params) {
26
+ const trimmed = params.text.trim();
27
+ if (!trimmed) return null;
28
+ return (await sendMessageMatrix(`room:${params.roomId}`, trimmed, {
29
+ cfg: params.cfg,
30
+ client: params.client,
31
+ accountId: params.accountId,
32
+ ...params.threadId ? { threadId: params.threadId } : {}
33
+ })).messageId || null;
34
+ }
35
+ async function sendFarewellMessage(params) {
36
+ const roomId = params.record.parentConversationId ?? params.record.conversationId;
37
+ const idleTimeoutMs = typeof params.record.idleTimeoutMs === "number" ? params.record.idleTimeoutMs : params.defaultIdleTimeoutMs;
38
+ const maxAgeMs = typeof params.record.maxAgeMs === "number" ? params.record.maxAgeMs : params.defaultMaxAgeMs;
39
+ const farewellText = resolveThreadBindingFarewellText({
40
+ reason: params.reason,
41
+ idleTimeoutMs,
42
+ maxAgeMs
43
+ });
44
+ await sendBindingMessage({
45
+ cfg: params.cfg,
46
+ client: params.client,
47
+ accountId: params.accountId,
48
+ roomId,
49
+ threadId: params.record.parentConversationId && params.record.parentConversationId !== params.record.conversationId ? params.record.conversationId : void 0,
50
+ text: farewellText
51
+ }).catch(() => {});
52
+ }
53
+ function createMatrixSessionBindingAdapter(params, { manager, defaults, committedBindings, assertManagerCurrent, assertAcceptingMutation, mutateBindings }) {
54
+ const { removeBindingsAsync, touchBindingAsync } = manager;
55
+ const unbindRecords = async (records, reason, onRemoved) => {
56
+ const removed = await removeBindingsAsync(records);
57
+ if (removed.length === 0) return [];
58
+ removed.forEach((record) => onRemoved?.(record));
59
+ await Promise.all(removed.map((record) => sendFarewellMessage({
60
+ cfg: params.cfg,
61
+ client: params.client,
62
+ accountId: params.accountId,
63
+ record,
64
+ defaultIdleTimeoutMs: defaults.idleTimeoutMs,
65
+ defaultMaxAgeMs: defaults.maxAgeMs,
66
+ reason: typeof reason === "function" ? reason(record) : reason
67
+ })));
68
+ return removed.map((record) => toSessionBindingRecord(record, defaults));
69
+ };
70
+ const getCommittedBinding = (ref) => {
71
+ assertManagerCurrent();
72
+ return [...committedBindings.values()].find((record) => record.conversationId === ref.conversationId.trim() && (!ref.parentConversationId || record.parentConversationId === ref.parentConversationId.trim()));
73
+ };
74
+ const projectCommittedBinding = (record) => {
75
+ const observed = manager.getByConversation(record);
76
+ return toSessionBindingRecord(observed && sameBindingIncarnation(record, observed) ? {
77
+ ...record,
78
+ lastActivityAt: Math.max(record.lastActivityAt, observed.lastActivityAt)
79
+ } : record, defaults);
80
+ };
81
+ return {
82
+ sessionBindingAdapter: {
83
+ version: 2,
84
+ assertCurrent: assertManagerCurrent,
85
+ channel: "matrix",
86
+ accountId: params.accountId,
87
+ capabilities: {
88
+ placements: ["current", "child"],
89
+ bindSupported: true,
90
+ unbindSupported: true
91
+ },
92
+ bind: async (input) => {
93
+ assertAcceptingMutation();
94
+ input.assertCurrent?.();
95
+ const conversationId = input.conversation.conversationId.trim();
96
+ const parentConversationId = normalizeOptionalString(input.conversation.parentConversationId);
97
+ const targetSessionKey = input.targetSessionKey.trim();
98
+ if (!conversationId || !targetSessionKey) return null;
99
+ let boundConversationId = conversationId;
100
+ let boundParentConversationId = parentConversationId;
101
+ const introText = buildMatrixBindingIntroText({
102
+ metadata: input.metadata,
103
+ targetSessionKey
104
+ });
105
+ if (input.placement === "child") {
106
+ const roomId = parentConversationId || conversationId;
107
+ const rootEventId = await sendBindingMessage({
108
+ cfg: params.cfg,
109
+ client: params.client,
110
+ accountId: params.accountId,
111
+ roomId,
112
+ text: introText
113
+ });
114
+ assertManagerCurrent();
115
+ if (!rootEventId) return null;
116
+ boundConversationId = rootEventId;
117
+ boundParentConversationId = roomId;
118
+ }
119
+ const now = Date.now();
120
+ const record = {
121
+ accountId: params.accountId,
122
+ conversationId: boundConversationId,
123
+ ...boundParentConversationId ? { parentConversationId: boundParentConversationId } : {},
124
+ targetKind: input.targetKind === "subagent" ? "subagent" : "acp",
125
+ targetSessionKey,
126
+ agentId: normalizeOptionalString(input.metadata?.agentId) ?? resolveSessionAgentIdStrict({
127
+ config: params.cfg,
128
+ sessionKey: targetSessionKey
129
+ }),
130
+ label: normalizeOptionalString(input.metadata?.label) || void 0,
131
+ boundBy: normalizeOptionalString(input.metadata?.boundBy) || "system",
132
+ boundAt: now,
133
+ lastActivityAt: now,
134
+ idleTimeoutMs: defaults.idleTimeoutMs,
135
+ maxAgeMs: defaults.maxAgeMs
136
+ };
137
+ await mutateBindings((current) => [...current.filter((entry) => resolveBindingKey(entry) !== resolveBindingKey(record)), record], input.placement !== "child" ? input.assertCurrent : void 0);
138
+ assertManagerCurrent();
139
+ if (input.placement === "current" && introText) {
140
+ const roomId = boundParentConversationId || boundConversationId;
141
+ const threadId = boundParentConversationId && boundParentConversationId !== boundConversationId ? boundConversationId : void 0;
142
+ await sendBindingMessage({
143
+ cfg: params.cfg,
144
+ client: params.client,
145
+ accountId: params.accountId,
146
+ roomId,
147
+ threadId,
148
+ text: introText
149
+ }).catch(() => {});
150
+ }
151
+ return toSessionBindingRecord(record, defaults);
152
+ },
153
+ listBySessionAsync: async (targetSessionKey) => {
154
+ assertManagerCurrent();
155
+ return [...committedBindings.values()].filter((record) => record.targetSessionKey === targetSessionKey.trim()).map(projectCommittedBinding);
156
+ },
157
+ resolveByConversationAsync: async (ref) => {
158
+ const record = getCommittedBinding(ref);
159
+ return record ? projectCommittedBinding(record) : null;
160
+ },
161
+ inspectByConversationAsync: async (ref) => {
162
+ const record = getCommittedBinding(ref);
163
+ return record ? projectCommittedBinding(record) : null;
164
+ },
165
+ inspectByConversationsAsync: async (refs) => {
166
+ const records = refs.map(getCommittedBinding);
167
+ return {
168
+ bindings: records.map((record) => record ? projectCommittedBinding(record) : null),
169
+ assertCurrent: () => {
170
+ assertManagerCurrent();
171
+ if (refs.some((ref, index) => getCommittedBinding(ref) !== records[index])) throw new Error("Matrix thread binding selection changed");
172
+ }
173
+ };
174
+ },
175
+ touchAsync: touchBindingAsync,
176
+ listBySession: (targetSessionKey) => manager.listBySessionKey(targetSessionKey).map((record) => toSessionBindingRecord(record, defaults)),
177
+ resolveByConversation: (ref) => {
178
+ const record = manager.getByConversation(ref);
179
+ return record ? toSessionBindingRecord(record, defaults) : null;
180
+ },
181
+ touch: (bindingId, at) => {
182
+ manager.touchBinding(bindingId, at);
183
+ },
184
+ unbind: async (input) => {
185
+ assertManagerCurrent();
186
+ return unbindRecords(listBindingsForAccount(params.accountId).filter((record) => {
187
+ if (input.bindingId?.trim()) return resolveBindingKey(record) === input.bindingId.trim();
188
+ if (input.targetSessionKey?.trim()) return record.targetSessionKey === input.targetSessionKey.trim();
189
+ return false;
190
+ }), input.reason);
191
+ }
192
+ },
193
+ unbindRecords
194
+ };
195
+ }
196
+ //#endregion
197
+ //#region extensions/matrix/src/matrix/thread-bindings.ts
198
+ const THREAD_BINDINGS_NAMESPACE = "thread-bindings";
199
+ const THREAD_BINDINGS_MAX_ENTRIES = 1e4;
200
+ const THREAD_BINDINGS_SWEEP_INTERVAL_MS = 6e4;
201
+ const TOUCH_PERSIST_DELAY_MS = 3e4;
202
+ function createThreadBindingStore(params) {
203
+ return getMatrixRuntime().state.openKeyedStoreV2({
204
+ namespace: THREAD_BINDINGS_NAMESPACE,
205
+ maxEntries: THREAD_BINDINGS_MAX_ENTRIES,
206
+ env: resolveMatrixSqliteStateEnv(params)
207
+ }, params.assertCurrent ? { assertCurrent: params.assertCurrent } : void 0);
208
+ }
209
+ function buildThreadBindingStoreKey(record) {
210
+ const digest = createHash("sha256").update(record.accountId).update("\0").update(record.parentConversationId ?? "").update("\0").update(record.conversationId).digest("hex");
211
+ return `${record.accountId}:${digest}`;
212
+ }
213
+ function normalizeBindingRecord(entry, accountId) {
214
+ if (!entry || typeof entry !== "object" || Array.isArray(entry)) return null;
215
+ const record = entry;
216
+ if (record.accountId && record.accountId !== accountId) return null;
217
+ const conversationId = normalizeOptionalString(record.conversationId);
218
+ const parentConversationId = normalizeOptionalString(record.parentConversationId);
219
+ const targetSessionKey = normalizeOptionalString(record.targetSessionKey) ?? "";
220
+ if (!conversationId || !targetSessionKey) return null;
221
+ const boundAt = resolveOptionalIntegerOption(record.boundAt) ?? Date.now();
222
+ const lastActivityAt = resolveOptionalIntegerOption(record.lastActivityAt) ?? boundAt;
223
+ return {
224
+ accountId,
225
+ conversationId,
226
+ ...parentConversationId ? { parentConversationId } : {},
227
+ targetKind: record.targetKind === "subagent" ? "subagent" : "acp",
228
+ targetSessionKey,
229
+ agentId: normalizeOptionalString(record.agentId) || void 0,
230
+ label: normalizeOptionalString(record.label) || void 0,
231
+ boundBy: normalizeOptionalString(record.boundBy) || void 0,
232
+ boundAt,
233
+ lastActivityAt: Math.max(lastActivityAt, boundAt),
234
+ idleTimeoutMs: resolveOptionalIntegerOption(record.idleTimeoutMs, { min: 0 }),
235
+ maxAgeMs: resolveOptionalIntegerOption(record.maxAgeMs, { min: 0 })
236
+ };
237
+ }
238
+ async function loadBindingsFromPluginState(params) {
239
+ const store = createThreadBindingStore(params);
240
+ const loaded = [];
241
+ for (const entry of await store.entries()) {
242
+ const record = normalizeBindingRecord(entry.value, params.accountId);
243
+ if (record) loaded.push(record);
244
+ }
245
+ return loaded;
246
+ }
247
+ function toPluginJsonValue(value) {
248
+ const serialized = JSON.stringify(value);
249
+ return JSON.parse(serialized);
250
+ }
251
+ async function persistBindingsSnapshot(params) {
252
+ const store = createThreadBindingStore(params);
253
+ const liveKeys = new Set(params.bindings.map((record) => buildThreadBindingStoreKey(record)));
254
+ const stored = /* @__PURE__ */ new Map();
255
+ for (const entry of await store.entries()) {
256
+ const record = normalizeBindingRecord(entry.value, params.accountId);
257
+ if (record) stored.set(entry.key, record);
258
+ if (record && !liveKeys.has(entry.key)) await store.delete(entry.key);
259
+ }
260
+ const committed = [];
261
+ for (const record of params.bindings) {
262
+ const key = buildThreadBindingStoreKey(record);
263
+ const previous = stored.get(key);
264
+ const next = previous && sameBindingIncarnation(previous, record) ? {
265
+ ...record,
266
+ lastActivityAt: Math.max(record.lastActivityAt, previous.lastActivityAt)
267
+ } : record;
268
+ await store.register(key, toPluginJsonValue(next));
269
+ committed.push(next);
270
+ }
271
+ return committed;
272
+ }
273
+ async function createMatrixThreadBindingManager(params) {
274
+ if (params.auth.accountId !== params.accountId) throw new Error(`Matrix thread binding account mismatch: requested ${params.accountId}, auth resolved ${params.auth.accountId}`);
275
+ const legacyFilePath = await resolveMatrixStateFilePath({
276
+ filename: "thread-bindings.json",
277
+ auth: params.auth,
278
+ accountId: params.accountId,
279
+ env: params.env,
280
+ stateDir: params.stateDir
281
+ });
282
+ await assertMatrixSupportedStateFile(legacyFilePath);
283
+ const sqliteStateDir = path.dirname(legacyFilePath);
284
+ const storageKey = resolveMatrixSqliteStateKey({
285
+ env: params.env,
286
+ stateDir: sqliteStateDir
287
+ });
288
+ const existingEntry = getMatrixThreadBindingManagerEntry(params.accountId);
289
+ if (existingEntry) {
290
+ if (existingEntry.storageKey === storageKey) return existingEntry.manager;
291
+ await existingEntry.manager.stop();
292
+ }
293
+ const loaded = await loadBindingsFromPluginState({
294
+ accountId: params.accountId,
295
+ env: params.env,
296
+ stateDir: sqliteStateDir
297
+ });
298
+ for (const record of loaded) setBindingRecord(record);
299
+ const committedBindings = new Map(loaded.map((record) => [resolveBindingKey(record), record]));
300
+ let persistQueue = Promise.resolve();
301
+ const publishCommittedBindings = (committed, before) => {
302
+ const previousByKey = new Map(before.map((record) => [resolveBindingKey(record), record]));
303
+ const currentByKey = new Map(listBindingsForAccount(params.accountId).map((record) => [resolveBindingKey(record), record]));
304
+ committedBindings.clear();
305
+ for (const record of committed) {
306
+ const key = resolveBindingKey(record);
307
+ committedBindings.set(key, record);
308
+ if (currentByKey.get(key) === previousByKey.get(key)) setBindingRecord(record);
309
+ }
310
+ for (const record of before) {
311
+ const key = resolveBindingKey(record);
312
+ if (!committedBindings.has(key) && currentByKey.get(key) === record) removeBindingRecord(record);
313
+ }
314
+ };
315
+ const persistSnapshot = async (bindings, before, assertCurrent) => {
316
+ try {
317
+ const committed = await persistBindingsSnapshot({
318
+ accountId: params.accountId,
319
+ bindings,
320
+ env: params.env,
321
+ stateDir: sqliteStateDir,
322
+ assertCurrent
323
+ });
324
+ assertCurrent();
325
+ return committed;
326
+ } catch (error) {
327
+ if (hasSqliteWorkerOutcomeUnknown(error)) {
328
+ stopping = true;
329
+ throw new Error("Matrix thread binding persistence has an unknown outcome; restart the account", { cause: error });
330
+ }
331
+ try {
332
+ const committed = await loadBindingsFromPluginState({
333
+ accountId: params.accountId,
334
+ env: params.env,
335
+ stateDir: sqliteStateDir,
336
+ assertCurrent: assertManagerCurrent
337
+ });
338
+ assertManagerCurrent();
339
+ publishCommittedBindings(committed, before);
340
+ } catch (reconciliationError) {
341
+ stopping = true;
342
+ throw new AggregateError([error, reconciliationError], "Matrix thread binding persistence could not be reconciled; restart the account", { cause: reconciliationError });
343
+ }
344
+ throw error;
345
+ }
346
+ };
347
+ const enqueuePersist = () => {
348
+ const next = persistQueue.catch(() => {}).then(async () => {
349
+ assertManagerCurrent();
350
+ const snapshot = listBindingsForAccount(params.accountId);
351
+ const committed = await persistSnapshot(snapshot, snapshot, assertManagerCurrent);
352
+ publishCommittedBindings(committed, snapshot);
353
+ await claimCurrentTokenStorageState({ rootDir: sqliteStateDir });
354
+ });
355
+ persistQueue = next;
356
+ return next;
357
+ };
358
+ const persist = async () => await enqueuePersist();
359
+ const persistSafely = (reason) => {
360
+ enqueuePersist().catch((err) => {
361
+ params.logVerboseMessage?.(`matrix: failed persisting thread bindings account=${params.accountId} action=${reason}: ${String(err)}`);
362
+ });
363
+ };
364
+ const defaults = {
365
+ idleTimeoutMs: params.idleTimeoutMs,
366
+ maxAgeMs: params.maxAgeMs
367
+ };
368
+ let persistTimer = null;
369
+ let touchPersistPending = false;
370
+ const schedulePersist = (delayMs) => {
371
+ touchPersistPending = true;
372
+ if (persistTimer || stopPromise) return;
373
+ persistTimer = setTimeout(() => {
374
+ persistTimer = null;
375
+ touchPersistPending = false;
376
+ persistSafely("delayed-touch");
377
+ }, delayMs);
378
+ persistTimer.unref?.();
379
+ };
380
+ const updateBindingsBySessionKey = (input) => {
381
+ const method = input.field === "idleTimeoutMs" ? "setIdleTimeoutBySessionKey" : "setMaxAgeBySessionKey";
382
+ warnPluginSdkDeprecation({
383
+ pluginId: "matrix",
384
+ family: "conversation-bindings",
385
+ method: `MatrixThreadBindingManager.${method}`,
386
+ replacement: `await ${method}Async()`,
387
+ compatibility: "Legacy methods return cached results synchronously and defer persistence."
388
+ });
389
+ const targetSessionKey = input.targetSessionKey.trim();
390
+ if (!targetSessionKey) return [];
391
+ const now = Date.now();
392
+ const nextBindings = listBindingsForAccount(params.accountId).filter((entry) => entry.targetSessionKey === targetSessionKey).map((entry) => Object.assign({}, entry, {
393
+ [input.field]: Math.max(0, Math.floor(input.value)),
394
+ lastActivityAt: now
395
+ }));
396
+ if (nextBindings.length === 0) return [];
397
+ for (const entry of nextBindings) setBindingRecord(entry);
398
+ persistSafely(input.persistReason);
399
+ return nextBindings;
400
+ };
401
+ let stopping = false;
402
+ let stopPromise;
403
+ const assertManagerCurrent = () => {
404
+ if (stopping || getMatrixThreadBindingManagerEntry(params.accountId)?.manager !== manager) throw new Error("Matrix thread binding manager was retired");
405
+ };
406
+ const assertAcceptingMutation = () => {
407
+ assertManagerCurrent();
408
+ if (stopPromise) throw new Error("Matrix thread binding manager is stopping");
409
+ };
410
+ const mutateBindings = (prepare, assertInputCurrent) => {
411
+ assertAcceptingMutation();
412
+ const operation = persistQueue.catch(() => {}).then(async () => {
413
+ assertManagerCurrent();
414
+ const before = listBindingsForAccount(params.accountId);
415
+ const next = prepare(before);
416
+ if (!next) return before;
417
+ const beforeByKey = new Map(before.map((record) => [resolveBindingKey(record), record]));
418
+ const assertCurrent = () => {
419
+ assertManagerCurrent();
420
+ assertInputCurrent?.();
421
+ const current = listBindingsForAccount(params.accountId);
422
+ if (current.length !== before.length || current.some((record) => beforeByKey.get(resolveBindingKey(record)) !== record)) throw new Error("Matrix thread bindings changed before persistence completed");
423
+ };
424
+ const committed = await persistSnapshot(next, before, assertCurrent);
425
+ publishCommittedBindings(committed, before);
426
+ await claimCurrentTokenStorageState({ rootDir: sqliteStateDir });
427
+ return committed;
428
+ });
429
+ persistQueue = operation.then(() => {});
430
+ persistQueue.catch(() => {});
431
+ return operation;
432
+ };
433
+ const removeBindingsAsync = async (records) => {
434
+ const requested = new Map(records.map((record) => [resolveBindingKey(record), record]));
435
+ let removed = [];
436
+ await mutateBindings((current) => {
437
+ removed = current.filter((record) => {
438
+ const expected = requested.get(resolveBindingKey(record));
439
+ return expected && sameBindingIncarnation(record, expected);
440
+ });
441
+ const removedKeys = new Set(removed.map(resolveBindingKey));
442
+ return removed.length ? current.filter((record) => !removedKeys.has(resolveBindingKey(record))) : null;
443
+ });
444
+ return removed;
445
+ };
446
+ const touchBinding = (bindingId, at) => {
447
+ warnPluginSdkDeprecation({
448
+ pluginId: "matrix",
449
+ family: "conversation-bindings",
450
+ method: "MatrixThreadBindingManager.touchBinding",
451
+ replacement: "await touchBindingAsync()",
452
+ compatibility: "Legacy methods return cached results synchronously and defer persistence."
453
+ });
454
+ assertAcceptingMutation();
455
+ const record = listBindingsForAccount(params.accountId).find((entry) => resolveBindingKey(entry) === bindingId.trim());
456
+ if (!record) return null;
457
+ const nextRecord = {
458
+ ...record,
459
+ lastActivityAt: typeof at === "number" && Number.isFinite(at) ? Math.max(record.lastActivityAt, Math.floor(at)) : Date.now()
460
+ };
461
+ setBindingRecord(nextRecord);
462
+ schedulePersist(TOUCH_PERSIST_DELAY_MS);
463
+ return nextRecord;
464
+ };
465
+ const touchBindingAsync = (bindingId, at) => {
466
+ assertAcceptingMutation();
467
+ const expected = listBindingsForAccount(params.accountId).find((entry) => resolveBindingKey(entry) === bindingId.trim());
468
+ if (!expected) return Promise.resolve();
469
+ const requestedAt = typeof at === "number" && Number.isFinite(at) ? Math.floor(at) : Date.now();
470
+ const next = persistQueue.catch(() => {}).then(async () => {
471
+ assertManagerCurrent();
472
+ const previous = listBindingsForAccount(params.accountId).find((entry) => resolveBindingKey(entry) === bindingId.trim());
473
+ if (!previous || !sameBindingIncarnation(previous, expected)) return;
474
+ const current = {
475
+ ...previous,
476
+ lastActivityAt: Math.max(previous.lastActivityAt, requestedAt)
477
+ };
478
+ setBindingRecord(current);
479
+ const committed = committedBindings.get(resolveBindingKey(current));
480
+ if (committed && sameBindingIncarnation(committed, current) && current.lastActivityAt - committed.lastActivityAt < TOUCH_PERSIST_DELAY_MS) {
481
+ if (current.lastActivityAt > committed.lastActivityAt) schedulePersist(TOUCH_PERSIST_DELAY_MS);
482
+ return;
483
+ }
484
+ const assertCurrent = () => {
485
+ assertManagerCurrent();
486
+ if (!listBindingsForAccount(params.accountId).includes(current)) throw new Error("Matrix thread binding changed while recording activity");
487
+ };
488
+ await createThreadBindingStore({
489
+ env: params.env,
490
+ stateDir: sqliteStateDir,
491
+ assertCurrent
492
+ }).register(buildThreadBindingStoreKey(current), toPluginJsonValue(current));
493
+ assertCurrent();
494
+ committedBindings.set(resolveBindingKey(current), current);
495
+ });
496
+ persistQueue = next;
497
+ return next;
498
+ };
499
+ const updateBindingsBySessionKeyAsync = async (input) => {
500
+ const targetSessionKey = input.targetSessionKey.trim();
501
+ const value = Math.max(0, Math.floor(input.value));
502
+ const now = Date.now();
503
+ return (await mutateBindings((current) => {
504
+ if (!targetSessionKey || !current.some((record) => record.targetSessionKey === targetSessionKey)) return null;
505
+ return current.map((record) => record.targetSessionKey === targetSessionKey ? {
506
+ ...record,
507
+ [input.field]: value,
508
+ lastActivityAt: now
509
+ } : record);
510
+ })).filter((record) => record.targetSessionKey === targetSessionKey);
511
+ };
512
+ const manager = {
513
+ accountId: params.accountId,
514
+ getIdleTimeoutMs: () => defaults.idleTimeoutMs,
515
+ getMaxAgeMs: () => defaults.maxAgeMs,
516
+ persist,
517
+ getByConversation: ({ conversationId, parentConversationId }) => listBindingsForAccount(params.accountId).find((entry) => {
518
+ if (entry.conversationId !== conversationId.trim()) return false;
519
+ if (!parentConversationId) return true;
520
+ return (entry.parentConversationId ?? "") === parentConversationId.trim();
521
+ }),
522
+ listBySessionKey: (targetSessionKey) => listBindingsForAccount(params.accountId).filter((entry) => entry.targetSessionKey === targetSessionKey.trim()),
523
+ listBindings: () => listBindingsForAccount(params.accountId),
524
+ touchBinding,
525
+ touchBindingAsync,
526
+ removeBindingsAsync,
527
+ setIdleTimeoutBySessionKey: ({ targetSessionKey, idleTimeoutMs }) => updateBindingsBySessionKey({
528
+ targetSessionKey,
529
+ field: "idleTimeoutMs",
530
+ value: idleTimeoutMs,
531
+ persistReason: "idle-timeout-update"
532
+ }),
533
+ setMaxAgeBySessionKey: ({ targetSessionKey, maxAgeMs }) => updateBindingsBySessionKey({
534
+ targetSessionKey,
535
+ field: "maxAgeMs",
536
+ value: maxAgeMs,
537
+ persistReason: "max-age-update"
538
+ }),
539
+ setIdleTimeoutBySessionKeyAsync: ({ targetSessionKey, idleTimeoutMs }) => updateBindingsBySessionKeyAsync({
540
+ targetSessionKey,
541
+ field: "idleTimeoutMs",
542
+ value: idleTimeoutMs,
543
+ persistReason: "idle-timeout-update"
544
+ }),
545
+ setMaxAgeBySessionKeyAsync: ({ targetSessionKey, maxAgeMs }) => updateBindingsBySessionKeyAsync({
546
+ targetSessionKey,
547
+ field: "maxAgeMs",
548
+ value: maxAgeMs,
549
+ persistReason: "max-age-update"
550
+ }),
551
+ stop: () => {
552
+ if (stopPromise) return stopPromise;
553
+ if (sweepTimer) clearInterval(sweepTimer);
554
+ if (persistTimer) {
555
+ clearTimeout(persistTimer);
556
+ persistTimer = null;
557
+ }
558
+ stopPromise = (async () => {
559
+ try {
560
+ await persistQueue;
561
+ if (touchPersistPending) {
562
+ touchPersistPending = false;
563
+ await enqueuePersist();
564
+ }
565
+ } finally {
566
+ stopping = true;
567
+ unregisterSessionBindingAdapter({
568
+ channel: "matrix",
569
+ accountId: params.accountId,
570
+ adapter: sessionBindingAdapter
571
+ });
572
+ if (getMatrixThreadBindingManagerEntry(params.accountId)?.manager === manager) {
573
+ deleteMatrixThreadBindingManagerEntry(params.accountId);
574
+ for (const record of listBindingsForAccount(params.accountId)) removeBindingRecord(record);
575
+ }
576
+ }
577
+ })();
578
+ return stopPromise;
579
+ }
580
+ };
581
+ let sweepTimer = null;
582
+ const { sessionBindingAdapter, unbindRecords } = createMatrixSessionBindingAdapter(params, {
583
+ manager,
584
+ defaults,
585
+ committedBindings,
586
+ assertManagerCurrent,
587
+ assertAcceptingMutation,
588
+ mutateBindings
589
+ });
590
+ registerSessionBindingAdapterV2(sessionBindingAdapter);
591
+ if (params.enableSweeper !== false) {
592
+ sweepTimer = setInterval(() => {
593
+ const now = Date.now();
594
+ const expired = listBindingsForAccount(params.accountId).map((record) => ({
595
+ record,
596
+ lifecycle: resolveThreadBindingLifecycle({
597
+ record,
598
+ defaultIdleTimeoutMs: defaults.idleTimeoutMs,
599
+ defaultMaxAgeMs: defaults.maxAgeMs
600
+ })
601
+ })).filter((entry) => typeof entry.lifecycle.expiresAt === "number" && entry.lifecycle.expiresAt <= now && Boolean(entry.lifecycle.reason));
602
+ if (expired.length === 0) return;
603
+ const reasonByBindingKey = new Map(expired.map(({ record, lifecycle }) => [resolveBindingKey(record), lifecycle.reason]));
604
+ unbindRecords(expired.map(({ record }) => record), (record) => reasonByBindingKey.get(resolveBindingKey(record)), (record) => {
605
+ const reason = reasonByBindingKey.get(resolveBindingKey(record));
606
+ params.logVerboseMessage?.(`matrix: auto-unbinding ${record.conversationId} due to ${reason}`);
607
+ }).catch((err) => {
608
+ params.logVerboseMessage?.(`matrix: failed auto-unbinding expired bindings account=${params.accountId}: ${String(err)}`);
609
+ });
610
+ }, THREAD_BINDINGS_SWEEP_INTERVAL_MS);
611
+ sweepTimer.unref?.();
612
+ }
613
+ setMatrixThreadBindingManagerEntry(params.accountId, {
614
+ storageKey,
615
+ manager
616
+ });
617
+ return manager;
618
+ }
619
+ //#endregion
620
+ export { createMatrixThreadBindingManager as t };
@@ -1,4 +1,4 @@
1
- import { projectThreadBindingRecord, resolveThreadBindingLifecycle } from "openclaw/plugin-sdk/thread-bindings-session-runtime";
1
+ import { projectThreadBindingRecord, resolveThreadBindingLifecycle, warnPluginSdkDeprecation } from "openclaw/plugin-sdk/thread-bindings-session-runtime";
2
2
  //#region extensions/matrix/src/matrix/thread-bindings-shared.ts
3
3
  const MANAGERS_BY_ACCOUNT_ID = /* @__PURE__ */ new Map();
4
4
  const BINDINGS_BY_ACCOUNT_CONVERSATION = /* @__PURE__ */ new Map();
@@ -55,8 +55,15 @@ function deleteMatrixThreadBindingManagerEntry(accountId) {
55
55
  function getMatrixThreadBindingManager(accountId) {
56
56
  return MANAGERS_BY_ACCOUNT_ID.get(accountId)?.manager ?? null;
57
57
  }
58
- function createMatrixThreadBindingTimeoutSetter(update) {
58
+ function createMatrixThreadBindingTimeoutSetter(method, update) {
59
59
  return (params) => {
60
+ warnPluginSdkDeprecation({
61
+ pluginId: "matrix",
62
+ family: "conversation-bindings",
63
+ method,
64
+ replacement: `await ${method}Async()`,
65
+ compatibility: "Legacy methods return cached results synchronously and defer persistence."
66
+ });
60
67
  const manager = MANAGERS_BY_ACCOUNT_ID.get(params.accountId)?.manager;
61
68
  if (!manager) return [];
62
69
  return update(manager, params).map((record) => toSessionBindingRecord(record, {
@@ -65,7 +72,21 @@ function createMatrixThreadBindingTimeoutSetter(update) {
65
72
  }));
66
73
  };
67
74
  }
68
- const setMatrixThreadBindingIdleTimeoutBySessionKey = createMatrixThreadBindingTimeoutSetter((manager, params) => manager.setIdleTimeoutBySessionKey(params));
69
- const setMatrixThreadBindingMaxAgeBySessionKey = createMatrixThreadBindingTimeoutSetter((manager, params) => manager.setMaxAgeBySessionKey(params));
75
+ /** @deprecated Use setMatrixThreadBindingIdleTimeoutBySessionKeyAsync. Final compatibility day: 2026-12-31. */
76
+ const setMatrixThreadBindingIdleTimeoutBySessionKey = createMatrixThreadBindingTimeoutSetter("setMatrixThreadBindingIdleTimeoutBySessionKey", (manager, params) => manager.setIdleTimeoutBySessionKey(params));
77
+ /** @deprecated Use setMatrixThreadBindingMaxAgeBySessionKeyAsync. Final compatibility day: 2026-12-31. */
78
+ const setMatrixThreadBindingMaxAgeBySessionKey = createMatrixThreadBindingTimeoutSetter("setMatrixThreadBindingMaxAgeBySessionKey", (manager, params) => manager.setMaxAgeBySessionKey(params));
79
+ function createMatrixThreadBindingAsyncTimeoutSetter(update) {
80
+ return async (params) => {
81
+ const manager = MANAGERS_BY_ACCOUNT_ID.get(params.accountId)?.manager;
82
+ if (!manager) return [];
83
+ return (await update(manager, params)).map((record) => toSessionBindingRecord(record, {
84
+ idleTimeoutMs: manager.getIdleTimeoutMs(),
85
+ maxAgeMs: manager.getMaxAgeMs()
86
+ }));
87
+ };
88
+ }
89
+ const setMatrixThreadBindingIdleTimeoutBySessionKeyAsync = createMatrixThreadBindingAsyncTimeoutSetter((manager, params) => manager.setIdleTimeoutBySessionKeyAsync(params));
90
+ const setMatrixThreadBindingMaxAgeBySessionKeyAsync = createMatrixThreadBindingAsyncTimeoutSetter((manager, params) => manager.setMaxAgeBySessionKeyAsync(params));
70
91
  //#endregion
71
- export { listBindingsForAccount as a, setBindingRecord as c, setMatrixThreadBindingMaxAgeBySessionKey as d, toSessionBindingRecord as f, listAllBindings as i, setMatrixThreadBindingIdleTimeoutBySessionKey as l, getMatrixThreadBindingManager as n, removeBindingRecord as o, getMatrixThreadBindingManagerEntry as r, resolveBindingKey as s, deleteMatrixThreadBindingManagerEntry as t, setMatrixThreadBindingManagerEntry as u };
92
+ export { listBindingsForAccount as a, setBindingRecord as c, setMatrixThreadBindingManagerEntry as d, setMatrixThreadBindingMaxAgeBySessionKey as f, listAllBindings as i, setMatrixThreadBindingIdleTimeoutBySessionKey as l, toSessionBindingRecord as m, getMatrixThreadBindingManager as n, removeBindingRecord as o, setMatrixThreadBindingMaxAgeBySessionKeyAsync as p, getMatrixThreadBindingManagerEntry as r, resolveBindingKey as s, deleteMatrixThreadBindingManagerEntry as t, setMatrixThreadBindingIdleTimeoutBySessionKeyAsync as u };