@openclaw/matrix 2026.10.10-beta.5 → 2026.11.5-beta.1

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 (711) hide show
  1. package/dist/.setup/{account-config-CRsKoMqJ.mjs → account-config-CVM2a28p.mjs} +1 -2
  2. package/dist/.setup/{account-selection-Bs_jCAaG.mjs → account-selection-Cow3TMFO.mjs} +15 -18
  3. package/dist/.setup/{approval-handler.runtime-6u08WKWh.mjs → approval-handler.runtime-_0gqiVgR.mjs} +19 -55
  4. package/dist/.setup/{approval-reactions-D2pEUrFS.mjs → approval-reactions-Bz_8XB01.mjs} +4 -5
  5. package/dist/.setup/{backup-health-Dm_YMVFT.mjs → backup-health-BxH69np2.mjs} +1 -2
  6. package/dist/.setup/{channel-CqkLHNdp.mjs → channel-ByHcZU28.mjs} +306 -385
  7. package/dist/.setup/channel.runtime-sNicWjmD.mjs +71 -0
  8. package/dist/.setup/{channel.setup-ClA7V_Ba.mjs → channel.setup-Bmba21y9.mjs} +30 -45
  9. package/dist/.setup/{cli-BLgMlO3I.mjs → cli-B26pps0Q.mjs} +264 -333
  10. package/dist/.setup/{cli-metadata-COWLWR3E.mjs → cli-metadata-CKGwVfmT.mjs} +3 -5
  11. package/dist/.setup/{client-C4Gibhzl.mjs → client-Bqu801rH.mjs} +98 -190
  12. package/dist/.setup/{client-C7pZ6gAl.mjs → client-N8TEwtmk.mjs} +7 -8
  13. package/dist/.setup/{client-bootstrap-kOIDV4z_.mjs → client-bootstrap-k6Zm1M8Y.mjs} +6 -12
  14. package/dist/.setup/{client-support-D-xHScuo.mjs → client-support-CqXAOZp3.mjs} +3 -18
  15. package/dist/.setup/{config-paths-CnREYb1Y.mjs → config-paths-DBpHxDyc.mjs} +1 -2
  16. package/dist/.setup/{create-client-BS8UYx6N.mjs → create-client-DaGljdrk.mjs} +8 -9
  17. package/dist/.setup/{credentials-CPnJZaZB.mjs → credentials-DVmY0miU.mjs} +9 -24
  18. package/dist/.setup/{credentials-read-D2ULV55A.mjs → credentials-read-rPqEpuxv.mjs} +7 -8
  19. package/dist/.setup/{credentials-state-B3cuUFwZ.mjs → credentials-state-jxq29yQw.mjs} +1 -2
  20. package/dist/.setup/{crypto-node.runtime-6Aj_ltHQ.mjs → crypto-node.runtime-E_hqXGxm.mjs} +1 -2
  21. package/dist/.setup/{crypto-runtime-D8yY7kjD.mjs → crypto-runtime-KQupbxSM.mjs} +80 -171
  22. package/dist/.setup/{crypto-state-store-D4wrCvFs.mjs → crypto-state-store-p1mdYTWH.mjs} +16 -12
  23. package/dist/.setup/{crypto-store-ownership-Z_Y5WRKr.mjs → crypto-store-ownership-7lVHeXWL.mjs} +3 -4
  24. package/dist/.setup/{crypto-unsafe-state-doctor-C8szCYmf.mjs → crypto-unsafe-state-doctor-CG2nJk8P.mjs} +10 -10
  25. package/dist/.setup/{deps-L_1bUAGL.mjs → deps-CVPT2Ros.mjs} +5 -5
  26. package/dist/.setup/device-health-D7n-lPeb.mjs +7 -0
  27. package/dist/.setup/{direct-management-B3wYhx_M.mjs → direct-management-D59C1WO-.mjs} +27 -37
  28. package/dist/.setup/{directory-live-BpSz-FQB.mjs → directory-live-YixmpyLW.mjs} +7 -8
  29. package/dist/.setup/doctor-contract-GiXgCj7k.mjs +37 -0
  30. package/dist/.setup/{draft-stream-K6Lu-JEI.mjs → draft-stream-C09OtoJZ.mjs} +11 -18
  31. package/dist/.setup/{encryption-guidance-D5_IsDIy.mjs → encryption-guidance-DfbEaKct.mjs} +3 -4
  32. package/dist/.setup/{env-vars-aEBngJPa.mjs → env-vars-Bh1iOXJ1.mjs} +1 -2
  33. package/dist/.setup/{errors-Bw4EHwKX.mjs → errors-CL3YJV8U.mjs} +1 -2
  34. package/dist/.setup/{event-helpers-CxNgMQqH.mjs → event-helpers-DDUjVVf7.mjs} +1 -2
  35. package/dist/.setup/{exec-approvals-DtNw0e04.mjs → exec-approvals-C3rCm0Sn.mjs} +35 -48
  36. package/dist/.setup/{file-sync-store-CUH8EAJq.mjs → file-sync-store-NW6eDuai.mjs} +54 -11
  37. package/dist/.setup/{http-client-ByR4STVQ.mjs → http-client-CqnKFKUH.mjs} +23 -38
  38. package/dist/.setup/{idb-persistence-BHTYPRe_.mjs → idb-persistence-CmoPtwDD.mjs} +25 -19
  39. package/dist/.setup/{idb-persistence-lock-Bh3ZLIsE.mjs → idb-persistence-lock-CH2K6d_3.mjs} +1 -2
  40. package/dist/.setup/{joined-room-encryption-BAD70N5n.mjs → joined-room-encryption-9sJK1kM-.mjs} +5 -5
  41. package/dist/.setup/{logger-CXQnpXCt.mjs → logger-B9TwnY6C.mjs} +4 -5
  42. package/dist/.setup/{logging-BKV8TYQq.mjs → logging-Bnsn7s4r.mjs} +21 -16
  43. package/dist/.setup/{messages-O6G0-_xr.mjs → messages-BjzsVgS6.mjs} +45 -33
  44. package/dist/.setup/{monitor-BSEZMFyq.mjs → monitor-D4vhbNUM.mjs} +675 -853
  45. package/dist/.setup/{onboarding-DQLF7huY.mjs → onboarding-DKmt3jpW.mjs} +119 -132
  46. package/dist/.setup/{outbound-C0bqZr89.mjs → outbound-wsXTF0z_.mjs} +3 -4
  47. package/dist/.setup/{profile-update-BbfEg9Fx.mjs → profile-update-DX060MnL.mjs} +18 -20
  48. package/dist/.setup/{reaction-events-51DOeO0I.mjs → reaction-events-BMsatzs4.mjs} +76 -102
  49. package/dist/.setup/{resolve-targets-BJ5sIKeM.mjs → resolve-targets-Yz_3aN_2.mjs} +4 -5
  50. package/dist/.setup/{retired-state-DOCruzWd.mjs → retired-state-Bs3Gqkge.mjs} +10 -10
  51. package/dist/.setup/{room-info-DAJKw-I8.mjs → room-info-OGKjk422.mjs} +24 -13
  52. package/dist/.setup/{runtime-1kn1P6io.mjs → runtime-Ck8TjD7L.mjs} +1 -2
  53. package/dist/.setup/{doctor-contract-CsTNmbMa.mjs → runtime-doctor-migrations-CSvRANPN.mjs} +17 -58
  54. package/dist/.setup/{runtime-setter-api-i2MOXoT3.mjs → runtime-setter-api-CpwhcBQK.mjs} +1 -1
  55. package/dist/.setup/{sdk-ByU8So5S.mjs → sdk-BXcIyN-I.mjs} +114 -141
  56. package/dist/.setup/{secret-contract-DxyzKSzf.mjs → secret-contract-AKnr45nw.mjs} +2 -3
  57. package/dist/.setup/{secret-contract-api-Dukgvike.mjs → secret-contract-api-DMSwMIxd.mjs} +1 -1
  58. package/dist/.setup/{send-CFx1h7xE.mjs → send-CWjH-l-T.mjs} +189 -287
  59. package/dist/.setup/{send-currentness-C2rMVVIQ.mjs → send-currentness-D1x6YP9O.mjs} +11 -19
  60. package/dist/.setup/{setup-bootstrap-DANlsW-o.mjs → setup-bootstrap-yKeGh4Iy.mjs} +4 -5
  61. package/dist/.setup/{setup-core-EQceJMZZ.mjs → setup-core-BaKffgBi.mjs} +28 -58
  62. package/dist/.setup/setup-plugin-api-B_t4waBw.mjs +2 -0
  63. package/dist/.setup/{startup-verification-UU8DUvi4.mjs → startup-verification-C-lhD0gk.mjs} +11 -25
  64. package/dist/.setup/{state-layout-walk-BQMgMykU.mjs → state-layout-walk-BqCZTHpp.mjs} +2 -3
  65. package/dist/.setup/{storage-l8V0XsGM.mjs → storage-BLLN9jYG.mjs} +22 -28
  66. package/dist/.setup/{storage-paths-B51JM-pC.mjs → storage-paths-e_Vq6cvw.mjs} +1 -2
  67. package/dist/.setup/{subagent-hooks-CSY4iwa_.mjs → subagent-hooks-D-lCcLGQ.mjs} +2 -3
  68. package/dist/.setup/{sync-cache-state-Cnm4TCEI.mjs → sync-cache-state-B4hJFIPw.mjs} +11 -12
  69. package/dist/.setup/sync-state-Cu1nagBV.mjs +11 -0
  70. package/dist/.setup/{target-ids-HhcaKX1n.mjs → target-ids-DltG_ZHJ.mjs} +1 -2
  71. package/dist/.setup/task-runner-CYyGHdNW.mjs +51 -0
  72. package/dist/.setup/{thread-binding-api-BvuaKpd0.mjs → thread-binding-api-OtSciHmZ.mjs} +2 -3
  73. package/dist/.setup/{thread-bindings-C0gv7BEN.mjs → thread-bindings-BA2xESjV.mjs} +37 -54
  74. package/dist/.setup/{thread-bindings-shared-CPjUA0Ib.mjs → thread-bindings-shared-CBlJu3Wz.mjs} +3 -4
  75. package/dist/.setup/{tool-actions-DGYRJDEV.mjs → tool-actions-CRuiVbqj.mjs} +67 -80
  76. package/dist/.setup/{url-validation-CF6pG6eE.mjs → url-validation-DesoKUns.mjs} +2 -4
  77. package/dist/.setup/{verification-DUxuApWC.mjs → verification-C5x4Hy5Y.mjs} +8 -9
  78. package/dist/.source-module-urls/1cd4d4ff8d44e1c8b830932b44d7cf8a7f3350e09e169910e1d7a85e131b7bea.json +1 -1
  79. package/dist/api.js +8 -8
  80. package/dist/auth-presence.js +3 -4
  81. package/dist/channel-plugin-api.js +1 -1
  82. package/dist/cli-metadata.js +1 -1
  83. package/dist/contract-api.js +2 -2
  84. package/dist/doctor-contract-api.js +155 -136
  85. package/dist/helper-api.js +3 -3
  86. package/dist/index.js +3 -4
  87. package/dist/plugin-entry.handlers.runtime.js +3 -4
  88. package/dist/runtime-api.js +7 -8
  89. package/dist/runtime-setter-api.js +1 -1
  90. package/dist/secret-contract-api.js +1 -1
  91. package/dist/session-binding-contract-api.js +2 -2
  92. package/dist/setup-entry.js +4 -5
  93. package/dist/setup-plugin-api.js +1 -1
  94. package/dist/subagent-hooks-api.js +2 -3
  95. package/dist/thread-binding-api.js +1 -1
  96. package/dist/thread-bindings-runtime.js +1 -1
  97. package/node_modules/@babel/runtime/helpers/asyncIterator.js +1 -1
  98. package/node_modules/@babel/runtime/helpers/createForOfIteratorHelper.js +12 -6
  99. package/node_modules/@babel/runtime/helpers/esm/asyncIterator.js +1 -1
  100. package/node_modules/@babel/runtime/helpers/esm/createForOfIteratorHelper.js +12 -6
  101. package/node_modules/@babel/runtime/helpers/esm/interopRequireWildcard.js +16 -19
  102. package/node_modules/@babel/runtime/helpers/esm/toPrimitive.js +5 -5
  103. package/node_modules/@babel/runtime/helpers/interopRequireWildcard.js +16 -19
  104. package/node_modules/@babel/runtime/helpers/toPrimitive.js +5 -5
  105. package/node_modules/@babel/runtime/package.json +1 -1
  106. package/node_modules/@openclaw/fs-safe/CHANGELOG.md +94 -0
  107. package/node_modules/@openclaw/fs-safe/dist/archive-parser.wasm +0 -0
  108. package/node_modules/@openclaw/fs-safe/dist/copy-file-input.d.ts +1 -1
  109. package/node_modules/@openclaw/fs-safe/dist/copy-file-input.js +3 -1
  110. package/node_modules/@openclaw/fs-safe/dist/copy-path-admission.js +2 -2
  111. package/node_modules/@openclaw/fs-safe/dist/copy-root-file-sync.js +8 -1
  112. package/node_modules/@openclaw/fs-safe/dist/file-open-error.d.ts +2 -0
  113. package/node_modules/@openclaw/fs-safe/dist/file-open-error.js +14 -0
  114. package/node_modules/@openclaw/fs-safe/dist/file-sync.d.ts +2 -1
  115. package/node_modules/@openclaw/fs-safe/dist/file-sync.js +6 -1
  116. package/node_modules/@openclaw/fs-safe/dist/guest-native-python.js +3 -0
  117. package/node_modules/@openclaw/fs-safe/dist/native-binding.d.ts +1 -0
  118. package/node_modules/@openclaw/fs-safe/dist/native-config.js +14 -3
  119. package/node_modules/@openclaw/fs-safe/dist/native-operations.js +2 -0
  120. package/node_modules/@openclaw/fs-safe/dist/native-pinned-write-windows.js +9 -2
  121. package/node_modules/@openclaw/fs-safe/dist/native-staged-file.js +40 -32
  122. package/node_modules/@openclaw/fs-safe/dist/output.js +6 -0
  123. package/node_modules/@openclaw/fs-safe/dist/owner-dacl.d.ts +2 -0
  124. package/node_modules/@openclaw/fs-safe/dist/owner-dacl.js +1 -0
  125. package/node_modules/@openclaw/fs-safe/dist/path.js +5 -1
  126. package/node_modules/@openclaw/fs-safe/dist/pinned-write-staged.js +25 -2
  127. package/node_modules/@openclaw/fs-safe/dist/publication-handle.d.ts +4 -0
  128. package/node_modules/@openclaw/fs-safe/dist/publication-handle.js +32 -0
  129. package/node_modules/@openclaw/fs-safe/dist/publish-copy-stage.d.ts +2 -1
  130. package/node_modules/@openclaw/fs-safe/dist/publish-copy-stage.js +19 -9
  131. package/node_modules/@openclaw/fs-safe/dist/publish-file.js +23 -24
  132. package/node_modules/@openclaw/fs-safe/dist/publish-rename-fallback.d.ts +21 -0
  133. package/node_modules/@openclaw/fs-safe/dist/publish-rename-fallback.js +102 -0
  134. package/node_modules/@openclaw/fs-safe/dist/root-create-native.js +2 -0
  135. package/node_modules/@openclaw/fs-safe/dist/root-directory-entry.d.ts +3 -1
  136. package/node_modules/@openclaw/fs-safe/dist/root-directory-entry.js +8 -5
  137. package/node_modules/@openclaw/fs-safe/dist/root-directory-list-types.d.ts +3 -0
  138. package/node_modules/@openclaw/fs-safe/dist/root-directory-list.d.ts +2 -1
  139. package/node_modules/@openclaw/fs-safe/dist/root-directory-list.js +19 -9
  140. package/node_modules/@openclaw/fs-safe/dist/root-file-final-admission.js +3 -3
  141. package/node_modules/@openclaw/fs-safe/dist/root-path-existing.d.ts +2 -2
  142. package/node_modules/@openclaw/fs-safe/dist/root-path-existing.js +27 -13
  143. package/node_modules/@openclaw/fs-safe/dist/root-path.js +2 -2
  144. package/node_modules/@openclaw/fs-safe/dist/sibling-staged-file.d.ts +3 -0
  145. package/node_modules/@openclaw/fs-safe/dist/sibling-staged-file.js +18 -3
  146. package/node_modules/@openclaw/fs-safe/dist/watch-hints.d.ts +1 -1
  147. package/node_modules/@openclaw/fs-safe/dist/watch-hints.js +68 -21
  148. package/node_modules/@openclaw/fs-safe/dist/watch-io-error.d.ts +2 -0
  149. package/node_modules/@openclaw/fs-safe/dist/watch-io-error.js +27 -0
  150. package/node_modules/@openclaw/fs-safe/dist/watch-io-worker.d.ts +1 -0
  151. package/node_modules/@openclaw/fs-safe/dist/watch-io-worker.js +93 -0
  152. package/node_modules/@openclaw/fs-safe/dist/watch-io.d.ts +47 -0
  153. package/node_modules/@openclaw/fs-safe/dist/watch-io.js +236 -0
  154. package/node_modules/@openclaw/fs-safe/dist/watch-native.d.ts +1 -1
  155. package/node_modules/@openclaw/fs-safe/dist/watch-native.js +3 -3
  156. package/node_modules/@openclaw/fs-safe/dist/watch-probe.d.ts +16 -0
  157. package/node_modules/@openclaw/fs-safe/dist/watch-probe.js +135 -0
  158. package/node_modules/@openclaw/fs-safe/dist/watch-rescan.d.ts +1 -1
  159. package/node_modules/@openclaw/fs-safe/dist/watch-rescan.js +86 -24
  160. package/node_modules/@openclaw/fs-safe/dist/watch-scan.d.ts +4 -0
  161. package/node_modules/@openclaw/fs-safe/dist/watch-scan.js +78 -16
  162. package/node_modules/@openclaw/fs-safe/dist/watch-stream.d.ts +2 -0
  163. package/node_modules/@openclaw/fs-safe/dist/watch-stream.js +23 -0
  164. package/node_modules/@openclaw/fs-safe/dist/watch-types.d.ts +3 -1
  165. package/node_modules/@openclaw/fs-safe/dist/watch.js +60 -13
  166. package/node_modules/@openclaw/fs-safe/dist/windows-security-facts.d.ts +1 -1
  167. package/node_modules/@openclaw/fs-safe/dist/windows-security-facts.js +1 -0
  168. package/node_modules/@openclaw/fs-safe/dist/windows-security-helper.exe +0 -0
  169. package/node_modules/@openclaw/fs-safe/docs/advanced.md +5 -2
  170. package/node_modules/@openclaw/fs-safe/docs/compiler-qualification.md +392 -0
  171. package/node_modules/@openclaw/fs-safe/docs/config.md +7 -1
  172. package/node_modules/@openclaw/fs-safe/docs/contributing.md +25 -5
  173. package/node_modules/@openclaw/fs-safe/docs/copy.md +10 -0
  174. package/node_modules/@openclaw/fs-safe/docs/durability.md +9 -3
  175. package/node_modules/@openclaw/fs-safe/docs/errors.md +13 -0
  176. package/node_modules/@openclaw/fs-safe/docs/migrating-to-0.5.md +6 -4
  177. package/node_modules/@openclaw/fs-safe/docs/native-helper.md +6 -4
  178. package/node_modules/@openclaw/fs-safe/docs/output.md +4 -2
  179. package/node_modules/@openclaw/fs-safe/docs/path.md +5 -2
  180. package/node_modules/@openclaw/fs-safe/docs/permissions.md +15 -0
  181. package/node_modules/@openclaw/fs-safe/docs/security-model.md +9 -0
  182. package/node_modules/@openclaw/fs-safe/docs/staged-file.md +2 -0
  183. package/node_modules/@openclaw/fs-safe/docs/testing.md +1 -1
  184. package/node_modules/@openclaw/fs-safe/docs/watch.md +62 -5
  185. package/node_modules/@openclaw/fs-safe/docs/writing.md +6 -1
  186. package/node_modules/@openclaw/fs-safe/package.json +18 -16
  187. package/node_modules/@openclaw/fs-safe-darwin-arm64/fs-safe-native.node +0 -0
  188. package/node_modules/@openclaw/fs-safe-darwin-arm64/package.json +1 -1
  189. package/node_modules/@openclaw/fs-safe-darwin-x64/fs-safe-native.node +0 -0
  190. package/node_modules/@openclaw/fs-safe-darwin-x64/package.json +1 -1
  191. package/node_modules/@openclaw/fs-safe-freebsd-arm64/fs-safe-native.node +0 -0
  192. package/node_modules/@openclaw/fs-safe-freebsd-arm64/package.json +1 -1
  193. package/node_modules/@openclaw/fs-safe-freebsd-x64/fs-safe-native.node +0 -0
  194. package/node_modules/@openclaw/fs-safe-freebsd-x64/package.json +1 -1
  195. package/node_modules/@openclaw/fs-safe-linux-arm64-gnu/fs-safe-native.node +0 -0
  196. package/node_modules/@openclaw/fs-safe-linux-arm64-gnu/package.json +1 -1
  197. package/node_modules/@openclaw/fs-safe-linux-arm64-musl/fs-safe-native.node +0 -0
  198. package/node_modules/@openclaw/fs-safe-linux-arm64-musl/package.json +1 -1
  199. package/node_modules/@openclaw/fs-safe-linux-x64-gnu/fs-safe-native.node +0 -0
  200. package/node_modules/@openclaw/fs-safe-linux-x64-gnu/package.json +1 -1
  201. package/node_modules/@openclaw/fs-safe-linux-x64-musl/fs-safe-native.node +0 -0
  202. package/node_modules/@openclaw/fs-safe-linux-x64-musl/package.json +1 -1
  203. package/node_modules/@openclaw/fs-safe-win32-arm64-msvc/fs-safe-native.node +0 -0
  204. package/node_modules/@openclaw/fs-safe-win32-arm64-msvc/package.json +1 -1
  205. package/node_modules/@openclaw/fs-safe-win32-x64-msvc/fs-safe-native.node +0 -0
  206. package/node_modules/@openclaw/fs-safe-win32-x64-msvc/package.json +1 -1
  207. package/node_modules/@tokenizer/inflate/README.md +30 -1
  208. package/node_modules/@tokenizer/inflate/lib/GzipHandler.js +1 -1
  209. package/node_modules/@tokenizer/inflate/lib/ZipHandler.d.ts +8 -3
  210. package/node_modules/@tokenizer/inflate/lib/ZipHandler.js +101 -26
  211. package/node_modules/@tokenizer/inflate/lib/ZipLimitError.d.ts +16 -0
  212. package/node_modules/@tokenizer/inflate/lib/ZipLimitError.js +10 -0
  213. package/node_modules/@tokenizer/inflate/lib/ZipToken.d.ts +1 -1
  214. package/node_modules/@tokenizer/inflate/lib/ZipToken.js +11 -7
  215. package/node_modules/@tokenizer/inflate/lib/index.d.ts +2 -1
  216. package/node_modules/@tokenizer/inflate/lib/index.js +2 -1
  217. package/node_modules/@tokenizer/inflate/package.json +16 -15
  218. package/node_modules/argparse/lib/argparse.js +1 -1
  219. package/node_modules/argparse/package.json +1 -1
  220. package/node_modules/fake-indexeddb/build/cjs/FDBCursor.js +20 -18
  221. package/node_modules/fake-indexeddb/build/cjs/FDBKeyRange.js +6 -6
  222. package/node_modules/fake-indexeddb/build/cjs/FDBTransaction.js +20 -2
  223. package/node_modules/fake-indexeddb/build/cjs/lib/RecordStore.js +3 -3
  224. package/node_modules/fake-indexeddb/build/cjs/lib/binarySearchTree.js +11 -13
  225. package/node_modules/fake-indexeddb/build/cjs/lib/cmp.js +44 -14
  226. package/node_modules/fake-indexeddb/build/cjs/test/fakeIndexedDB/auto.js +54 -0
  227. package/node_modules/fake-indexeddb/build/cjs/test/fakeIndexedDB/binarySearchTree.js +413 -0
  228. package/node_modules/fake-indexeddb/build/cjs/test/fakeIndexedDB/fakeIndexedDB.js +1018 -0
  229. package/node_modules/fake-indexeddb/build/cjs/test/fakeIndexedDB/forceCloseDatabase.js +99 -0
  230. package/node_modules/fake-indexeddb/build/cjs/test/fakeIndexedDB/getAll.js +707 -0
  231. package/node_modules/fake-indexeddb/build/cjs/test/fakeIndexedDB/memoryLeaks.js +42 -0
  232. package/node_modules/fake-indexeddb/build/esm/FDBCursor.js +19 -18
  233. package/node_modules/fake-indexeddb/build/esm/FDBKeyRange.js +6 -6
  234. package/node_modules/fake-indexeddb/build/esm/FDBTransaction.js +20 -2
  235. package/node_modules/fake-indexeddb/build/esm/lib/RecordStore.js +3 -3
  236. package/node_modules/fake-indexeddb/build/esm/lib/binarySearchTree.js +11 -13
  237. package/node_modules/fake-indexeddb/build/esm/lib/cmp.js +41 -11
  238. package/node_modules/fake-indexeddb/build/esm/test/fakeIndexedDB/auto.js +52 -0
  239. package/node_modules/fake-indexeddb/build/esm/test/fakeIndexedDB/binarySearchTree.js +409 -0
  240. package/node_modules/fake-indexeddb/build/esm/test/fakeIndexedDB/fakeIndexedDB.js +1014 -0
  241. package/node_modules/fake-indexeddb/build/esm/test/fakeIndexedDB/forceCloseDatabase.js +95 -0
  242. package/node_modules/fake-indexeddb/build/esm/test/fakeIndexedDB/getAll.js +703 -0
  243. package/node_modules/fake-indexeddb/build/esm/test/fakeIndexedDB/memoryLeaks.js +38 -0
  244. package/node_modules/fake-indexeddb/package.json +1 -1
  245. package/node_modules/file-type/node_modules/strtok3/LICENSE.txt +21 -0
  246. package/node_modules/file-type/node_modules/strtok3/README.md +591 -0
  247. package/node_modules/file-type/node_modules/strtok3/lib/AbortSignal.d.ts +2 -0
  248. package/node_modules/file-type/node_modules/strtok3/lib/AbortSignal.js +7 -0
  249. package/node_modules/file-type/node_modules/strtok3/lib/AbstractTokenizer.d.ts +114 -0
  250. package/node_modules/file-type/node_modules/strtok3/lib/AbstractTokenizer.js +196 -0
  251. package/node_modules/file-type/node_modules/strtok3/lib/BlobTokenizer.d.ts +29 -0
  252. package/node_modules/file-type/node_modules/strtok3/lib/BlobTokenizer.js +56 -0
  253. package/node_modules/file-type/node_modules/strtok3/lib/BufferSizeError.d.ts +19 -0
  254. package/node_modules/file-type/node_modules/strtok3/lib/BufferSizeError.js +27 -0
  255. package/node_modules/file-type/node_modules/strtok3/lib/BufferTokenizer.d.ts +29 -0
  256. package/node_modules/file-type/node_modules/strtok3/lib/BufferTokenizer.js +50 -0
  257. package/node_modules/file-type/node_modules/strtok3/lib/FileTokenizer.d.ts +47 -0
  258. package/node_modules/file-type/node_modules/strtok3/lib/FileTokenizer.js +83 -0
  259. package/node_modules/file-type/node_modules/strtok3/lib/NotRegularFileError.d.ts +5 -0
  260. package/node_modules/file-type/node_modules/strtok3/lib/NotRegularFileError.js +8 -0
  261. package/node_modules/file-type/node_modules/strtok3/lib/ReadStreamTokenizer.d.ts +34 -0
  262. package/node_modules/file-type/node_modules/strtok3/lib/ReadStreamTokenizer.js +125 -0
  263. package/node_modules/file-type/node_modules/strtok3/lib/core.d.ts +41 -0
  264. package/node_modules/file-type/node_modules/strtok3/lib/core.js +69 -0
  265. package/node_modules/file-type/node_modules/strtok3/lib/index.d.ts +17 -0
  266. package/node_modules/file-type/node_modules/strtok3/lib/index.js +23 -0
  267. package/node_modules/file-type/node_modules/strtok3/lib/stream/AbstractStreamReader.d.ts +54 -0
  268. package/node_modules/file-type/node_modules/strtok3/lib/stream/AbstractStreamReader.js +73 -0
  269. package/node_modules/file-type/node_modules/strtok3/lib/stream/Deferred.d.ts +6 -0
  270. package/node_modules/file-type/node_modules/strtok3/lib/stream/Deferred.js +10 -0
  271. package/node_modules/file-type/node_modules/strtok3/lib/stream/Errors.d.ts +10 -0
  272. package/node_modules/file-type/node_modules/strtok3/lib/stream/Errors.js +16 -0
  273. package/node_modules/file-type/node_modules/strtok3/lib/stream/StreamReader.d.ts +30 -0
  274. package/node_modules/file-type/node_modules/strtok3/lib/stream/StreamReader.js +104 -0
  275. package/node_modules/file-type/node_modules/strtok3/lib/stream/WebStreamByobReader.d.ts +14 -0
  276. package/node_modules/file-type/node_modules/strtok3/lib/stream/WebStreamByobReader.js +29 -0
  277. package/node_modules/file-type/node_modules/strtok3/lib/stream/WebStreamDefaultReader.d.ts +19 -0
  278. package/node_modules/file-type/node_modules/strtok3/lib/stream/WebStreamDefaultReader.js +67 -0
  279. package/node_modules/file-type/node_modules/strtok3/lib/stream/WebStreamReader.d.ts +14 -0
  280. package/node_modules/file-type/node_modules/strtok3/lib/stream/WebStreamReader.js +13 -0
  281. package/node_modules/file-type/node_modules/strtok3/lib/stream/WebStreamReaderFactory.d.ts +5 -0
  282. package/node_modules/file-type/node_modules/strtok3/lib/stream/WebStreamReaderFactory.js +19 -0
  283. package/node_modules/file-type/node_modules/strtok3/lib/stream/index.d.ts +6 -0
  284. package/node_modules/file-type/node_modules/strtok3/lib/stream/index.js +5 -0
  285. package/node_modules/file-type/node_modules/strtok3/lib/types.d.ts +146 -0
  286. package/node_modules/file-type/node_modules/strtok3/lib/types.js +1 -0
  287. package/node_modules/file-type/node_modules/strtok3/package.json +95 -0
  288. package/node_modules/file-type/package.json +28 -27
  289. package/node_modules/file-type/readme.md +32 -3
  290. package/node_modules/file-type/source/detectors/ebml.js +2 -2
  291. package/node_modules/file-type/source/detectors/png.js +1 -0
  292. package/node_modules/file-type/source/detectors/zip.js +71 -112
  293. package/node_modules/file-type/source/index.d.ts +18 -8
  294. package/node_modules/file-type/source/index.js +75 -49
  295. package/node_modules/file-type/source/index.test-d.ts +29 -21
  296. package/node_modules/file-type/source/supported.js +4 -0
  297. package/node_modules/file-type/source/tokens.js +2 -2
  298. package/node_modules/markdown-it/dist/browser/markdown-it.esm.min.mjs +737 -686
  299. package/node_modules/markdown-it/dist/browser/markdown-it.esm.min.mjs.map +1 -1
  300. package/node_modules/markdown-it/dist/browser/markdown-it.umd.min.js +8 -8
  301. package/node_modules/markdown-it/dist/browser/markdown-it.umd.min.js.map +1 -1
  302. package/node_modules/markdown-it/dist/markdown-it.cjs.js +660 -518
  303. package/node_modules/markdown-it/dist/markdown-it.cjs.js.map +1 -1
  304. package/node_modules/markdown-it/dist/markdown-it.d.mts +1 -0
  305. package/node_modules/markdown-it/dist/markdown-it.mjs +179 -124
  306. package/node_modules/markdown-it/dist/markdown-it.mjs.map +1 -1
  307. package/node_modules/markdown-it/package.json +11 -11
  308. package/node_modules/matrix-js-sdk/CHANGELOG.md +23 -0
  309. package/node_modules/matrix-js-sdk/lib/@types/PushRules.d.ts +3 -1
  310. package/node_modules/matrix-js-sdk/lib/@types/PushRules.d.ts.map +1 -1
  311. package/node_modules/matrix-js-sdk/lib/@types/PushRules.js +2 -0
  312. package/node_modules/matrix-js-sdk/lib/@types/PushRules.js.map +1 -1
  313. package/node_modules/matrix-js-sdk/lib/@types/event.d.ts +1 -0
  314. package/node_modules/matrix-js-sdk/lib/@types/event.d.ts.map +1 -1
  315. package/node_modules/matrix-js-sdk/lib/@types/event.js.map +1 -1
  316. package/node_modules/matrix-js-sdk/lib/@types/matrix-sdk-crypto-wasm.d.js.map +1 -1
  317. package/node_modules/matrix-js-sdk/lib/client.d.ts +88 -37
  318. package/node_modules/matrix-js-sdk/lib/client.d.ts.map +1 -1
  319. package/node_modules/matrix-js-sdk/lib/client.js +72 -47
  320. package/node_modules/matrix-js-sdk/lib/client.js.map +1 -1
  321. package/node_modules/matrix-js-sdk/lib/crypto-api/index.d.ts +3 -3
  322. package/node_modules/matrix-js-sdk/lib/crypto-api/index.d.ts.map +1 -1
  323. package/node_modules/matrix-js-sdk/lib/crypto-api/index.js.map +1 -1
  324. package/node_modules/matrix-js-sdk/lib/embedded.d.ts +17 -1
  325. package/node_modules/matrix-js-sdk/lib/embedded.d.ts.map +1 -1
  326. package/node_modules/matrix-js-sdk/lib/embedded.js +46 -1
  327. package/node_modules/matrix-js-sdk/lib/embedded.js.map +1 -1
  328. package/node_modules/matrix-js-sdk/lib/errors.d.ts +1 -1
  329. package/node_modules/matrix-js-sdk/lib/errors.d.ts.map +1 -1
  330. package/node_modules/matrix-js-sdk/lib/errors.js +2 -2
  331. package/node_modules/matrix-js-sdk/lib/errors.js.map +1 -1
  332. package/node_modules/matrix-js-sdk/lib/http-api/fetch.d.ts +7 -1
  333. package/node_modules/matrix-js-sdk/lib/http-api/fetch.d.ts.map +1 -1
  334. package/node_modules/matrix-js-sdk/lib/http-api/fetch.js +14 -5
  335. package/node_modules/matrix-js-sdk/lib/http-api/fetch.js.map +1 -1
  336. package/node_modules/matrix-js-sdk/lib/http-api/interface.d.ts +34 -8
  337. package/node_modules/matrix-js-sdk/lib/http-api/interface.d.ts.map +1 -1
  338. package/node_modules/matrix-js-sdk/lib/http-api/interface.js +10 -3
  339. package/node_modules/matrix-js-sdk/lib/http-api/interface.js.map +1 -1
  340. package/node_modules/matrix-js-sdk/lib/http-api/refresh.d.ts +30 -11
  341. package/node_modules/matrix-js-sdk/lib/http-api/refresh.d.ts.map +1 -1
  342. package/node_modules/matrix-js-sdk/lib/http-api/refresh.js +72 -5
  343. package/node_modules/matrix-js-sdk/lib/http-api/refresh.js.map +1 -1
  344. package/node_modules/matrix-js-sdk/lib/matrix.d.ts +1 -1
  345. package/node_modules/matrix-js-sdk/lib/matrix.d.ts.map +1 -1
  346. package/node_modules/matrix-js-sdk/lib/matrix.js.map +1 -1
  347. package/node_modules/matrix-js-sdk/lib/matrixrtc/CallMembership.d.ts.map +1 -1
  348. package/node_modules/matrix-js-sdk/lib/matrixrtc/CallMembership.js +20 -6
  349. package/node_modules/matrix-js-sdk/lib/matrixrtc/CallMembership.js.map +1 -1
  350. package/node_modules/matrix-js-sdk/lib/matrixrtc/IMembershipManager.d.ts +5 -0
  351. package/node_modules/matrix-js-sdk/lib/matrixrtc/IMembershipManager.d.ts.map +1 -1
  352. package/node_modules/matrix-js-sdk/lib/matrixrtc/IMembershipManager.js.map +1 -1
  353. package/node_modules/matrix-js-sdk/lib/matrixrtc/MatrixRTCSession.d.ts +27 -1
  354. package/node_modules/matrix-js-sdk/lib/matrixrtc/MatrixRTCSession.d.ts.map +1 -1
  355. package/node_modules/matrix-js-sdk/lib/matrixrtc/MatrixRTCSession.js +58 -36
  356. package/node_modules/matrix-js-sdk/lib/matrixrtc/MatrixRTCSession.js.map +1 -1
  357. package/node_modules/matrix-js-sdk/lib/matrixrtc/MatrixRTCSessionManager.js +1 -1
  358. package/node_modules/matrix-js-sdk/lib/matrixrtc/MatrixRTCSessionManager.js.map +1 -1
  359. package/node_modules/matrix-js-sdk/lib/matrixrtc/MembershipManager.d.ts +76 -0
  360. package/node_modules/matrix-js-sdk/lib/matrixrtc/MembershipManager.d.ts.map +1 -1
  361. package/node_modules/matrix-js-sdk/lib/matrixrtc/MembershipManager.js +264 -47
  362. package/node_modules/matrix-js-sdk/lib/matrixrtc/MembershipManager.js.map +1 -1
  363. package/node_modules/matrix-js-sdk/lib/matrixrtc/index.d.ts +1 -1
  364. package/node_modules/matrix-js-sdk/lib/matrixrtc/index.d.ts.map +1 -1
  365. package/node_modules/matrix-js-sdk/lib/matrixrtc/index.js +1 -1
  366. package/node_modules/matrix-js-sdk/lib/matrixrtc/index.js.map +1 -1
  367. package/node_modules/matrix-js-sdk/lib/matrixrtc/membershipData/common.d.ts +8 -0
  368. package/node_modules/matrix-js-sdk/lib/matrixrtc/membershipData/common.d.ts.map +1 -1
  369. package/node_modules/matrix-js-sdk/lib/matrixrtc/membershipData/common.js +10 -0
  370. package/node_modules/matrix-js-sdk/lib/matrixrtc/membershipData/common.js.map +1 -1
  371. package/node_modules/matrix-js-sdk/lib/matrixrtc/membershipData/index.d.ts +1 -1
  372. package/node_modules/matrix-js-sdk/lib/matrixrtc/membershipData/index.d.ts.map +1 -1
  373. package/node_modules/matrix-js-sdk/lib/matrixrtc/membershipData/index.js +1 -1
  374. package/node_modules/matrix-js-sdk/lib/matrixrtc/membershipData/index.js.map +1 -1
  375. package/node_modules/matrix-js-sdk/lib/matrixrtc/types.d.ts +104 -11
  376. package/node_modules/matrix-js-sdk/lib/matrixrtc/types.d.ts.map +1 -1
  377. package/node_modules/matrix-js-sdk/lib/matrixrtc/types.js +263 -19
  378. package/node_modules/matrix-js-sdk/lib/matrixrtc/types.js.map +1 -1
  379. package/node_modules/matrix-js-sdk/lib/matrixrtc/utils.d.ts +22 -1
  380. package/node_modules/matrix-js-sdk/lib/matrixrtc/utils.d.ts.map +1 -1
  381. package/node_modules/matrix-js-sdk/lib/matrixrtc/utils.js +38 -0
  382. package/node_modules/matrix-js-sdk/lib/matrixrtc/utils.js.map +1 -1
  383. package/node_modules/matrix-js-sdk/lib/models/room-sticky-events.d.ts +7 -0
  384. package/node_modules/matrix-js-sdk/lib/models/room-sticky-events.d.ts.map +1 -1
  385. package/node_modules/matrix-js-sdk/lib/models/room-sticky-events.js +27 -0
  386. package/node_modules/matrix-js-sdk/lib/models/room-sticky-events.js.map +1 -1
  387. package/node_modules/matrix-js-sdk/lib/models/thread.d.ts.map +1 -1
  388. package/node_modules/matrix-js-sdk/lib/models/thread.js +8 -0
  389. package/node_modules/matrix-js-sdk/lib/models/thread.js.map +1 -1
  390. package/node_modules/matrix-js-sdk/lib/oauth/authorize.js +1 -1
  391. package/node_modules/matrix-js-sdk/lib/oauth/authorize.js.map +1 -1
  392. package/node_modules/matrix-js-sdk/lib/oauth/index.d.ts +3 -5
  393. package/node_modules/matrix-js-sdk/lib/oauth/index.d.ts.map +1 -1
  394. package/node_modules/matrix-js-sdk/lib/oauth/index.js +7 -7
  395. package/node_modules/matrix-js-sdk/lib/oauth/index.js.map +1 -1
  396. package/node_modules/matrix-js-sdk/lib/oauth/tokenRefresher.d.ts +10 -4
  397. package/node_modules/matrix-js-sdk/lib/oauth/tokenRefresher.d.ts.map +1 -1
  398. package/node_modules/matrix-js-sdk/lib/oauth/tokenRefresher.js +34 -24
  399. package/node_modules/matrix-js-sdk/lib/oauth/tokenRefresher.js.map +1 -1
  400. package/node_modules/matrix-js-sdk/lib/receipt-accumulator.d.ts +10 -11
  401. package/node_modules/matrix-js-sdk/lib/receipt-accumulator.d.ts.map +1 -1
  402. package/node_modules/matrix-js-sdk/lib/receipt-accumulator.js +26 -25
  403. package/node_modules/matrix-js-sdk/lib/receipt-accumulator.js.map +1 -1
  404. package/node_modules/matrix-js-sdk/lib/room-summary-api.d.ts +71 -0
  405. package/node_modules/matrix-js-sdk/lib/room-summary-api.d.ts.map +1 -0
  406. package/node_modules/matrix-js-sdk/lib/room-summary-api.js +82 -0
  407. package/node_modules/matrix-js-sdk/lib/room-summary-api.js.map +1 -0
  408. package/node_modules/matrix-js-sdk/lib/rust-crypto/backup.d.ts +7 -0
  409. package/node_modules/matrix-js-sdk/lib/rust-crypto/backup.d.ts.map +1 -1
  410. package/node_modules/matrix-js-sdk/lib/rust-crypto/backup.js +41 -25
  411. package/node_modules/matrix-js-sdk/lib/rust-crypto/backup.js.map +1 -1
  412. package/node_modules/matrix-js-sdk/lib/sync.d.ts.map +1 -1
  413. package/node_modules/matrix-js-sdk/lib/sync.js +6 -1
  414. package/node_modules/matrix-js-sdk/lib/sync.js.map +1 -1
  415. package/node_modules/matrix-js-sdk/package.json +6 -6
  416. package/node_modules/matrix-js-sdk/src/@types/PushRules.ts +2 -0
  417. package/node_modules/matrix-js-sdk/src/@types/event.ts +1 -1
  418. package/node_modules/matrix-js-sdk/src/@types/matrix-sdk-crypto-wasm.d.ts +15 -12
  419. package/node_modules/matrix-js-sdk/src/client.ts +105 -62
  420. package/node_modules/matrix-js-sdk/src/crypto-api/index.ts +3 -3
  421. package/node_modules/matrix-js-sdk/src/embedded.ts +61 -2
  422. package/node_modules/matrix-js-sdk/src/errors.ts +2 -1
  423. package/node_modules/matrix-js-sdk/src/http-api/fetch.ts +14 -5
  424. package/node_modules/matrix-js-sdk/src/http-api/interface.ts +36 -8
  425. package/node_modules/matrix-js-sdk/src/http-api/refresh.ts +101 -17
  426. package/node_modules/matrix-js-sdk/src/matrix.ts +1 -1
  427. package/node_modules/matrix-js-sdk/src/matrixrtc/CallMembership.ts +22 -4
  428. package/node_modules/matrix-js-sdk/src/matrixrtc/IMembershipManager.ts +6 -0
  429. package/node_modules/matrix-js-sdk/src/matrixrtc/MatrixRTCSession.ts +72 -49
  430. package/node_modules/matrix-js-sdk/src/matrixrtc/MatrixRTCSessionManager.ts +1 -1
  431. package/node_modules/matrix-js-sdk/src/matrixrtc/MembershipManager.ts +284 -61
  432. package/node_modules/matrix-js-sdk/src/matrixrtc/index.ts +7 -1
  433. package/node_modules/matrix-js-sdk/src/matrixrtc/membershipData/common.ts +12 -0
  434. package/node_modules/matrix-js-sdk/src/matrixrtc/membershipData/index.ts +1 -1
  435. package/node_modules/matrix-js-sdk/src/matrixrtc/types.ts +351 -23
  436. package/node_modules/matrix-js-sdk/src/matrixrtc/utils.ts +54 -1
  437. package/node_modules/matrix-js-sdk/src/models/room-sticky-events.ts +26 -1
  438. package/node_modules/matrix-js-sdk/src/models/thread.ts +9 -0
  439. package/node_modules/matrix-js-sdk/src/oauth/authorize.ts +1 -1
  440. package/node_modules/matrix-js-sdk/src/oauth/index.ts +7 -8
  441. package/node_modules/matrix-js-sdk/src/oauth/tokenRefresher.ts +15 -5
  442. package/node_modules/matrix-js-sdk/src/receipt-accumulator.ts +30 -26
  443. package/node_modules/matrix-js-sdk/src/room-summary-api.ts +114 -0
  444. package/node_modules/matrix-js-sdk/src/rust-crypto/backup.ts +46 -33
  445. package/node_modules/matrix-js-sdk/src/sync.ts +9 -1
  446. package/node_modules/music-metadata/README.md +125 -37
  447. package/node_modules/music-metadata/lib/ParseError.d.ts +10 -3
  448. package/node_modules/music-metadata/lib/ParseError.js +2 -0
  449. package/node_modules/music-metadata/lib/ParserFactory.d.ts +1 -1
  450. package/node_modules/music-metadata/lib/ParserFactory.js +20 -8
  451. package/node_modules/music-metadata/lib/aiff/AiffParser.d.ts +1 -0
  452. package/node_modules/music-metadata/lib/aiff/AiffParser.js +25 -17
  453. package/node_modules/music-metadata/lib/aiff/AiffToken.d.ts +9 -3
  454. package/node_modules/music-metadata/lib/aiff/AiffToken.js +10 -0
  455. package/node_modules/music-metadata/lib/apev2/APEv2Parser.d.ts +4 -3
  456. package/node_modules/music-metadata/lib/apev2/APEv2Parser.js +6 -30
  457. package/node_modules/music-metadata/lib/asf/AsfGuid.js +49 -49
  458. package/node_modules/music-metadata/lib/asf/AsfObject.d.ts +12 -6
  459. package/node_modules/music-metadata/lib/asf/AsfObject.js +201 -58
  460. package/node_modules/music-metadata/lib/asf/AsfParser.d.ts +4 -0
  461. package/node_modules/music-metadata/lib/asf/AsfParser.js +119 -27
  462. package/node_modules/music-metadata/lib/caf/CafLoader.d.ts +2 -0
  463. package/node_modules/music-metadata/lib/caf/CafLoader.js +8 -0
  464. package/node_modules/music-metadata/lib/caf/CafParser.d.ts +37 -0
  465. package/node_modules/music-metadata/lib/caf/CafParser.js +253 -0
  466. package/node_modules/music-metadata/lib/caf/CafTagMap.d.ts +8 -0
  467. package/node_modules/music-metadata/lib/caf/CafTagMap.js +38 -0
  468. package/node_modules/music-metadata/lib/caf/CafToken.d.ts +75 -0
  469. package/node_modules/music-metadata/lib/caf/CafToken.js +135 -0
  470. package/node_modules/music-metadata/lib/common/Allocation.d.ts +14 -0
  471. package/node_modules/music-metadata/lib/common/Allocation.js +70 -0
  472. package/node_modules/music-metadata/lib/common/BasicParser.d.ts +2 -0
  473. package/node_modules/music-metadata/lib/common/BasicParser.js +8 -0
  474. package/node_modules/music-metadata/lib/common/CaseInsensitiveTagMap.d.ts +1 -1
  475. package/node_modules/music-metadata/lib/common/CaseInsensitiveTagMap.js +3 -3
  476. package/node_modules/music-metadata/lib/common/CombinedTagMapper.js +4 -3
  477. package/node_modules/music-metadata/lib/common/GenericTagMapper.d.ts +1 -1
  478. package/node_modules/music-metadata/lib/common/GenericTagMapper.js +4 -2
  479. package/node_modules/music-metadata/lib/common/GenericTagTypes.d.ts +2 -2
  480. package/node_modules/music-metadata/lib/common/MetadataCollector.d.ts +6 -5
  481. package/node_modules/music-metadata/lib/common/MetadataCollector.js +57 -30
  482. package/node_modules/music-metadata/lib/common/TrackInfo.d.ts +8 -0
  483. package/node_modules/music-metadata/lib/common/TrackInfo.js +68 -0
  484. package/node_modules/music-metadata/lib/common/Util.d.ts +1 -1
  485. package/node_modules/music-metadata/lib/common/Util.js +6 -12
  486. package/node_modules/music-metadata/lib/core.d.ts +1 -1
  487. package/node_modules/music-metadata/lib/core.js +10 -18
  488. package/node_modules/music-metadata/lib/dsdiff/DsdiffLoader.js +1 -1
  489. package/node_modules/music-metadata/lib/dsdiff/DsdiffParser.d.ts +7 -3
  490. package/node_modules/music-metadata/lib/dsdiff/DsdiffParser.js +69 -33
  491. package/node_modules/music-metadata/lib/dsf/DsfParser.d.ts +4 -3
  492. package/node_modules/music-metadata/lib/dsf/DsfParser.js +1 -1
  493. package/node_modules/music-metadata/lib/ebml/EbmlIterator.d.ts +28 -19
  494. package/node_modules/music-metadata/lib/ebml/EbmlIterator.js +97 -67
  495. package/node_modules/music-metadata/lib/ebml/types.d.ts +36 -8
  496. package/node_modules/music-metadata/lib/ebml/types.js +2 -1
  497. package/node_modules/music-metadata/lib/flac/FlacParser.js +10 -18
  498. package/node_modules/music-metadata/lib/id3v1/ID3v1Parser.d.ts +1 -1
  499. package/node_modules/music-metadata/lib/id3v1/ID3v1Parser.js +5 -1
  500. package/node_modules/music-metadata/lib/id3v2/AbstractID3Parser.js +1 -4
  501. package/node_modules/music-metadata/lib/id3v2/EmbeddedID3v2.d.ts +5 -0
  502. package/node_modules/music-metadata/lib/id3v2/EmbeddedID3v2.js +29 -0
  503. package/node_modules/music-metadata/lib/id3v2/FrameParser.d.ts +5 -3
  504. package/node_modules/music-metadata/lib/id3v2/FrameParser.js +59 -33
  505. package/node_modules/music-metadata/lib/id3v2/ID3v2Parser.js +15 -8
  506. package/node_modules/music-metadata/lib/index.d.ts +2 -0
  507. package/node_modules/music-metadata/lib/index.js +8 -4
  508. package/node_modules/music-metadata/lib/matroska/MatroskaDtd.d.ts +630 -2
  509. package/node_modules/music-metadata/lib/matroska/MatroskaDtd.js +58 -40
  510. package/node_modules/music-metadata/lib/matroska/MatroskaParser.d.ts +4 -0
  511. package/node_modules/music-metadata/lib/matroska/MatroskaParser.js +211 -68
  512. package/node_modules/music-metadata/lib/matroska/types.d.ts +33 -131
  513. package/node_modules/music-metadata/lib/matroska/types.js +1 -18
  514. package/node_modules/music-metadata/lib/mp4/Atom.js +7 -0
  515. package/node_modules/music-metadata/lib/mp4/AtomToken.d.ts +17 -4
  516. package/node_modules/music-metadata/lib/mp4/AtomToken.js +124 -21
  517. package/node_modules/music-metadata/lib/mp4/MP4Parser.d.ts +12 -3
  518. package/node_modules/music-metadata/lib/mp4/MP4Parser.js +559 -242
  519. package/node_modules/music-metadata/lib/mpeg/AdtsFrameHeader.d.ts +17 -0
  520. package/node_modules/music-metadata/lib/mpeg/AdtsFrameHeader.js +44 -0
  521. package/node_modules/music-metadata/lib/mpeg/MpegFrameHeader.d.ts +41 -0
  522. package/node_modules/music-metadata/lib/mpeg/MpegFrameHeader.js +84 -0
  523. package/node_modules/music-metadata/lib/mpeg/MpegParser.d.ts +11 -24
  524. package/node_modules/music-metadata/lib/mpeg/MpegParser.js +77 -337
  525. package/node_modules/music-metadata/lib/musepack/MusepackConentError.d.ts +4 -3
  526. package/node_modules/music-metadata/lib/musepack/sv7/BitReader.js +3 -2
  527. package/node_modules/music-metadata/lib/musepack/sv7/MpcSv7Parser.js +3 -6
  528. package/node_modules/music-metadata/lib/musepack/sv8/MpcSv8Parser.js +1 -4
  529. package/node_modules/music-metadata/lib/musepack/sv8/StreamVersion8.js +1 -0
  530. package/node_modules/music-metadata/lib/ogg/OggLoader.js +1 -1
  531. package/node_modules/music-metadata/lib/ogg/OggParser.d.ts +4 -3
  532. package/node_modules/music-metadata/lib/ogg/OggParser.js +54 -9
  533. package/node_modules/music-metadata/lib/ogg/OggStreamMetadata.d.ts +14 -0
  534. package/node_modules/music-metadata/lib/ogg/OggStreamMetadata.js +27 -0
  535. package/node_modules/music-metadata/lib/ogg/OggToken.d.ts +1 -0
  536. package/node_modules/music-metadata/lib/ogg/OggToken.js +3 -1
  537. package/node_modules/music-metadata/lib/ogg/flac/FlacStream.d.ts +3 -1
  538. package/node_modules/music-metadata/lib/ogg/flac/FlacStream.js +21 -3
  539. package/node_modules/music-metadata/lib/ogg/opus/Opus.d.ts +4 -3
  540. package/node_modules/music-metadata/lib/ogg/opus/Opus.js +1 -0
  541. package/node_modules/music-metadata/lib/ogg/opus/OpusStream.js +4 -2
  542. package/node_modules/music-metadata/lib/ogg/speex/SpeexStream.js +2 -1
  543. package/node_modules/music-metadata/lib/ogg/theora/Theora.d.ts +5 -0
  544. package/node_modules/music-metadata/lib/ogg/theora/Theora.js +7 -2
  545. package/node_modules/music-metadata/lib/ogg/theora/TheoraStream.d.ts +5 -2
  546. package/node_modules/music-metadata/lib/ogg/theora/TheoraStream.js +43 -3
  547. package/node_modules/music-metadata/lib/ogg/vorbis/Vorbis.js +4 -3
  548. package/node_modules/music-metadata/lib/ogg/vorbis/VorbisDecoder.d.ts +11 -0
  549. package/node_modules/music-metadata/lib/ogg/vorbis/VorbisDecoder.js +29 -0
  550. package/node_modules/music-metadata/lib/ogg/vorbis/VorbisStream.d.ts +6 -4
  551. package/node_modules/music-metadata/lib/ogg/vorbis/VorbisStream.js +24 -18
  552. package/node_modules/music-metadata/lib/riff/RiffChunk.js +3 -0
  553. package/node_modules/music-metadata/lib/type.d.ts +49 -6
  554. package/node_modules/music-metadata/lib/type.js +22 -1
  555. package/node_modules/music-metadata/lib/wav/WaveChunk.d.ts +4 -3
  556. package/node_modules/music-metadata/lib/wav/WaveChunk.js +2 -0
  557. package/node_modules/music-metadata/lib/wav/WaveParser.d.ts +0 -1
  558. package/node_modules/music-metadata/lib/wav/WaveParser.js +21 -23
  559. package/node_modules/music-metadata/lib/wavpack/WavPackParser.d.ts +4 -3
  560. package/node_modules/music-metadata/lib/wavpack/WavPackParser.js +6 -6
  561. package/node_modules/music-metadata/package.json +26 -22
  562. package/node_modules/strtok3/LICENSE.txt +21 -21
  563. package/node_modules/strtok3/README.md +712 -399
  564. package/node_modules/strtok3/lib/AbortSignal.d.ts +2 -0
  565. package/node_modules/strtok3/lib/AbortSignal.js +7 -0
  566. package/node_modules/strtok3/lib/AbstractTokenizer.d.ts +40 -2
  567. package/node_modules/strtok3/lib/AbstractTokenizer.js +101 -16
  568. package/node_modules/strtok3/lib/BlobTokenizer.d.ts +1 -1
  569. package/node_modules/strtok3/lib/BlobTokenizer.js +14 -11
  570. package/node_modules/strtok3/lib/BufferSizeError.d.ts +19 -0
  571. package/node_modules/strtok3/lib/BufferSizeError.js +27 -0
  572. package/node_modules/strtok3/lib/BufferTokenizer.d.ts +1 -1
  573. package/node_modules/strtok3/lib/BufferTokenizer.js +7 -9
  574. package/node_modules/strtok3/lib/FileTokenizer.d.ts +13 -3
  575. package/node_modules/strtok3/lib/FileTokenizer.js +29 -7
  576. package/node_modules/strtok3/lib/NotRegularFileError.d.ts +5 -0
  577. package/node_modules/strtok3/lib/NotRegularFileError.js +8 -0
  578. package/node_modules/strtok3/lib/ReadStreamTokenizer.js +32 -9
  579. package/node_modules/strtok3/lib/TokenizerBoundaryError.d.ts +7 -0
  580. package/node_modules/strtok3/lib/TokenizerBoundaryError.js +10 -0
  581. package/node_modules/strtok3/lib/TokenizerView.d.ts +9 -0
  582. package/node_modules/strtok3/lib/TokenizerView.js +184 -0
  583. package/node_modules/strtok3/lib/core.d.ts +10 -6
  584. package/node_modules/strtok3/lib/core.js +16 -22
  585. package/node_modules/strtok3/lib/index.d.ts +5 -4
  586. package/node_modules/strtok3/lib/index.js +3 -2
  587. package/node_modules/strtok3/lib/isRandomAccessTokenizer.d.ts +6 -0
  588. package/node_modules/strtok3/lib/isRandomAccessTokenizer.js +10 -0
  589. package/node_modules/strtok3/lib/stream/AbstractStreamReader.js +5 -3
  590. package/node_modules/strtok3/lib/stream/Errors.js +3 -3
  591. package/node_modules/strtok3/lib/stream/StreamReader.d.ts +4 -3
  592. package/node_modules/strtok3/lib/stream/StreamReader.js +46 -25
  593. package/node_modules/strtok3/lib/stream/WebStreamByobReader.js +5 -3
  594. package/node_modules/strtok3/lib/stream/WebStreamDefaultReader.d.ts +1 -1
  595. package/node_modules/strtok3/lib/stream/WebStreamDefaultReader.js +9 -4
  596. package/node_modules/strtok3/lib/stream/WebStreamReader.d.ts +13 -3
  597. package/node_modules/strtok3/lib/stream/WebStreamReader.js +1 -1
  598. package/node_modules/strtok3/lib/stream/WebStreamReaderFactory.js +1 -1
  599. package/node_modules/strtok3/lib/stream/index.d.ts +1 -1
  600. package/node_modules/strtok3/lib/types.d.ts +25 -1
  601. package/node_modules/strtok3/package.json +97 -94
  602. package/node_modules/typebox/build/format/duration.d.mts +2 -2
  603. package/node_modules/typebox/build/format/duration.mjs +2 -2
  604. package/node_modules/typebox/build/format/idn_email.d.mts +1 -0
  605. package/node_modules/typebox/build/format/idn_email.mjs +1 -0
  606. package/node_modules/typebox/build/format/idn_hostname.d.mts +1 -1
  607. package/node_modules/typebox/build/format/idn_hostname.mjs +1 -1
  608. package/node_modules/typebox/build/format/ipv4.d.mts +2 -2
  609. package/node_modules/typebox/build/format/ipv4.mjs +2 -2
  610. package/node_modules/typebox/build/format/ipv6.d.mts +1 -1
  611. package/node_modules/typebox/build/format/ipv6.mjs +1 -1
  612. package/node_modules/typebox/build/format/relative_json_pointer.d.mts +2 -2
  613. package/node_modules/typebox/build/format/relative_json_pointer.mjs +2 -2
  614. package/node_modules/typebox/build/schema/build.mjs +1 -0
  615. package/node_modules/typebox/build/schema/engine/_unique.d.mts +4 -2
  616. package/node_modules/typebox/build/schema/engine/_unique.mjs +7 -3
  617. package/node_modules/typebox/build/schema/engine/additionalItems.mjs +3 -3
  618. package/node_modules/typebox/build/schema/engine/additionalProperties.d.mts +0 -3
  619. package/node_modules/typebox/build/schema/engine/additionalProperties.mjs +15 -17
  620. package/node_modules/typebox/build/schema/engine/contains.mjs +3 -3
  621. package/node_modules/typebox/build/schema/engine/index.d.mts +1 -0
  622. package/node_modules/typebox/build/schema/engine/index.mjs +1 -0
  623. package/node_modules/typebox/build/schema/engine/items.mjs +7 -4
  624. package/node_modules/typebox/build/schema/engine/maxContains.mjs +2 -2
  625. package/node_modules/typebox/build/schema/engine/minContains.mjs +3 -3
  626. package/node_modules/typebox/build/schema/engine/oneOf.mjs +2 -2
  627. package/node_modules/typebox/build/schema/engine/patternProperties.mjs +2 -2
  628. package/node_modules/typebox/build/schema/engine/propertyNames.mjs +2 -2
  629. package/node_modules/typebox/build/schema/engine/unevaluatedItems.mjs +2 -2
  630. package/node_modules/typebox/build/schema/engine/unevaluatedProperties.mjs +2 -2
  631. package/node_modules/typebox/build/system/hashing/hash.mjs +63 -34
  632. package/node_modules/typebox/build/system/locale/en_US.mjs +2 -1
  633. package/node_modules/typebox/build/system/memory/assign.d.mts +2 -8
  634. package/node_modules/typebox/build/system/memory/assign.mjs +13 -6
  635. package/node_modules/typebox/build/system/memory/clone.d.mts +4 -5
  636. package/node_modules/typebox/build/system/memory/clone.mjs +8 -96
  637. package/node_modules/typebox/build/system/memory/create.d.mts +1 -5
  638. package/node_modules/typebox/build/system/memory/create.mjs +18 -13
  639. package/node_modules/typebox/build/system/memory/deep.d.mts +2 -0
  640. package/node_modules/typebox/build/system/memory/deep.mjs +108 -0
  641. package/node_modules/typebox/build/system/memory/discard.d.mts +1 -1
  642. package/node_modules/typebox/build/system/memory/discard.mjs +9 -8
  643. package/node_modules/typebox/build/system/memory/finalize.d.mts +4 -0
  644. package/node_modules/typebox/build/system/memory/finalize.mjs +30 -0
  645. package/node_modules/typebox/build/system/memory/keys.d.mts +2 -0
  646. package/node_modules/typebox/build/system/memory/keys.mjs +8 -0
  647. package/node_modules/typebox/build/system/memory/update.d.mts +1 -4
  648. package/node_modules/typebox/build/system/memory/update.mjs +43 -16
  649. package/node_modules/typebox/build/type/engine/call/index.d.mts +1 -0
  650. package/node_modules/typebox/build/type/engine/call/index.mjs +1 -0
  651. package/node_modules/typebox/build/type/engine/evaluate/composite.d.mts +2 -24
  652. package/node_modules/typebox/build/type/engine/evaluate/composite.mjs +2 -29
  653. package/node_modules/typebox/build/type/engine/evaluate/index.d.mts +1 -0
  654. package/node_modules/typebox/build/type/engine/evaluate/index.mjs +1 -0
  655. package/node_modules/typebox/build/type/engine/evaluate/narrow.d.mts +5 -1
  656. package/node_modules/typebox/build/type/engine/evaluate/narrow.mjs +6 -1
  657. package/node_modules/typebox/build/type/engine/evaluate/property.d.mts +30 -0
  658. package/node_modules/typebox/build/type/engine/evaluate/property.mjs +29 -0
  659. package/node_modules/typebox/build/type/engine/immutable/instantiate_add.d.mts +1 -3
  660. package/node_modules/typebox/build/type/engine/immutable/instantiate_add.mjs +1 -4
  661. package/node_modules/typebox/build/type/engine/object/from_intersect.d.mts +2 -2
  662. package/node_modules/typebox/build/type/engine/object/from_intersect.mjs +2 -2
  663. package/node_modules/typebox/build/type/engine/object/from_union.d.mts +2 -2
  664. package/node_modules/typebox/build/type/engine/object/from_union.mjs +2 -2
  665. package/node_modules/typebox/build/type/engine/optional/instantiate_add.d.mts +1 -3
  666. package/node_modules/typebox/build/type/engine/optional/instantiate_add.mjs +1 -4
  667. package/node_modules/typebox/build/type/engine/readonly/instantiate_add.d.mts +1 -3
  668. package/node_modules/typebox/build/type/engine/readonly/instantiate_add.mjs +1 -4
  669. package/node_modules/typebox/build/type/engine/this/index.d.mts +1 -0
  670. package/node_modules/typebox/build/type/engine/this/index.mjs +1 -0
  671. package/node_modules/typebox/build/value/clone/clone.d.mts +4 -3
  672. package/node_modules/typebox/build/value/clone/clone.mjs +5 -7
  673. package/node_modules/typebox/build/value/repair/from_cyclic.d.mts +2 -0
  674. package/node_modules/typebox/build/value/repair/from_cyclic.mjs +6 -0
  675. package/node_modules/typebox/build/value/shared/union_priority_sort.mjs +25 -14
  676. package/node_modules/typebox/package.json +1 -1
  677. package/node_modules/typebox/readme.md +1 -1
  678. package/node_modules/zod/package.json +1 -1
  679. package/node_modules/zod/src/v4/classic/tests/array.test.ts +27 -0
  680. package/node_modules/zod/src/v4/classic/tests/map.test.ts +7 -0
  681. package/node_modules/zod/src/v4/classic/tests/set.test.ts +6 -0
  682. package/node_modules/zod/src/v4/core/compile.ts +9 -0
  683. package/node_modules/zod/src/v4/core/schemas.ts +35 -1
  684. package/node_modules/zod/src/v4/core/util.ts +13 -0
  685. package/node_modules/zod/src/v4/core/versions.ts +1 -1
  686. package/node_modules/zod/v4/core/compile.cjs +8 -0
  687. package/node_modules/zod/v4/core/compile.js +8 -0
  688. package/node_modules/zod/v4/core/schemas.cjs +30 -0
  689. package/node_modules/zod/v4/core/schemas.d.cts +3 -1
  690. package/node_modules/zod/v4/core/schemas.d.ts +3 -1
  691. package/node_modules/zod/v4/core/schemas.js +30 -0
  692. package/node_modules/zod/v4/core/util.cjs +15 -0
  693. package/node_modules/zod/v4/core/util.d.cts +2 -0
  694. package/node_modules/zod/v4/core/util.d.ts +2 -0
  695. package/node_modules/zod/v4/core/util.js +14 -0
  696. package/node_modules/zod/v4/core/versions.cjs +1 -1
  697. package/node_modules/zod/v4/core/versions.js +1 -1
  698. package/openclaw.plugin.json +11 -0
  699. package/package.json +11 -11
  700. package/dist/.setup/channel.runtime-BfZdvlho.mjs +0 -76
  701. package/dist/.setup/device-health-Be60VF1w.mjs +0 -21
  702. package/dist/.setup/inbound-dedupe-C-EBGY0B.mjs +0 -48
  703. package/dist/.setup/setup-plugin-api-f8mWghxf.mjs +0 -2
  704. package/node_modules/music-metadata/node_modules/content-type/LICENSE +0 -22
  705. package/node_modules/music-metadata/node_modules/content-type/README.md +0 -71
  706. package/node_modules/music-metadata/node_modules/content-type/dist/index.d.ts +0 -46
  707. package/node_modules/music-metadata/node_modules/content-type/dist/index.js +0 -176
  708. package/node_modules/music-metadata/node_modules/content-type/dist/index.js.map +0 -1
  709. package/node_modules/music-metadata/node_modules/content-type/package.json +0 -52
  710. package/node_modules/typebox/build/system/memory/freeze.d.mts +0 -4
  711. package/node_modules/typebox/build/system/memory/freeze.mjs +0 -6
@@ -1,36 +1,38 @@
1
- import { t as getMatrixRuntime } from "./runtime-1kn1P6io.mjs";
2
- import { a as resolveMatrixAccountConfig, i as resolveMatrixAccountAllowlistConfig } from "./account-config-CRsKoMqJ.mjs";
3
- import { h as resolveConfiguredMatrixBotUserIds } from "./setup-core-EQceJMZZ.mjs";
4
- import { a as resolveMatrixThreadRouting, i as resolveMatrixInboundRouteAsync, n as resolveMatrixStoredSessionMeta, o as resolveMatrixRoomConfig } from "./channel-CqkLHNdp.mjs";
5
- import { a as resolveMatrixAllowListMatch, i as normalizeMatrixUserId, r as normalizeMatrixAllowList } from "./channel.setup-ClA7V_Ba.mjs";
6
- import { n as isMatrixQualifiedUserId, r as isMatrixRoomId, t as isMatrixInviteAutoJoinTarget } from "./target-ids-HhcaKX1n.mjs";
7
- import { a as MATRIX_REACTION_EVENT_TYPE } from "./send-currentness-C2rMVVIQ.mjs";
8
- import { c as isStrictDirectMembership, f as resolveMatrixReplyToEventId, h as MATRIX_OPENCLAW_FINALIZED_PREVIEW_KEY, i as promoteMatrixDirectRoomCandidate, p as resolveMatrixThreadRootId, s as hasDirectMatrixMemberFlag, u as readJoinedMatrixMembers, v as RelationType } from "./direct-management-B3wYhx_M.mjs";
9
- import { _ as isPollEventType, c as formatMatrixMessageText, d as resolveMatrixReplacementContent, h as formatPollAsText, l as isLikelyBareFilename, r as sendMessageMatrix, u as resolveMatrixMessageAttachment, v as isPollStartType, w as setBoundedMap, y as parsePollStart } from "./send-CFx1h7xE.mjs";
10
- import { t as createMatrixThreadBindingManager } from "./thread-bindings-C0gv7BEN.mjs";
11
- import { a as isMatrixStartupAbortError, c as getMatrixMonitorTaskSignal, d as resolveMatrixAuthContext, l as backfillMatrixAuthDeviceIdAfterStartup, n as acquireSharedMatrixClient, o as throwIfMatrixStartupAborted, s as createMatrixMonitorTaskRunner, u as resolveMatrixAuth } from "./client-C4Gibhzl.mjs";
12
- import { i as readMatrixMessages, l as fetchMatrixPollSnapshot } from "./messages-O6G0-_xr.mjs";
13
- import { i as isMatrixMediaSizeLimitError, r as MatrixMediaSizeLimitError } from "./http-client-ByR4STVQ.mjs";
14
- import { n as prepareMatrixReplyPayload, r as resolveMatrixExtraContent } from "./outbound-C0bqZr89.mjs";
15
- import { t as resolveMatrixTargets } from "./resolve-targets-BJ5sIKeM.mjs";
16
- import { t as formatMatrixEncryptedEventDisabledWarning } from "./encryption-guidance-D5_IsDIy.mjs";
17
- import { createMatrixInboundEventDeduper } from "./inbound-dedupe-C-EBGY0B.mjs";
18
- import { a as isMatrixAccessTokenInvalidatedError, d as isMatrixDisconnectedSyncState, f as isMatrixReadySyncState, p as isMatrixTerminalSyncState } from "./client-support-D-xHScuo.mjs";
19
- import { r as getMatrixRoomInfo, t as createMatrixRoomInfoResolver } from "./room-info-DAJKw-I8.mjs";
1
+ import { t as getMatrixRuntime } from "./runtime-Ck8TjD7L.mjs";
2
+ import { a as resolveMatrixAccountConfig, i as resolveMatrixAccountAllowlistConfig } from "./account-config-CVM2a28p.mjs";
3
+ import { h as resolveConfiguredMatrixBotUserIds } from "./setup-core-BaKffgBi.mjs";
4
+ import { a as resolveMatrixInboundRouteAsync, i as resolveMatrixRoomConfig, n as resolveMatrixStoredSessionMeta, o as resolveMatrixThreadRouting } from "./channel-ByHcZU28.mjs";
5
+ import { a as resolveMatrixAllowListMatch, i as normalizeMatrixUserId, r as normalizeMatrixAllowList } from "./channel.setup-Bmba21y9.mjs";
6
+ import { n as isMatrixQualifiedUserId, r as isMatrixRoomId, t as isMatrixInviteAutoJoinTarget } from "./target-ids-DltG_ZHJ.mjs";
7
+ import { a as MATRIX_REACTION_EVENT_TYPE, n as withMatrixSendCurrentness } from "./send-currentness-D1x6YP9O.mjs";
8
+ import { c as isStrictDirectMembership, f as resolveMatrixReplyToEventId, h as MATRIX_OPENCLAW_FINALIZED_PREVIEW_KEY, i as promoteMatrixDirectRoomCandidate, p as resolveMatrixThreadRootId, s as hasDirectMatrixMemberFlag, u as readJoinedMatrixMembers, v as RelationType } from "./direct-management-D59C1WO-.mjs";
9
+ import { n as getMatrixMonitorTaskSignal, t as createMatrixMonitorTaskRunner } from "./task-runner-CYyGHdNW.mjs";
10
+ import { _ as isPollEventType, c as formatMatrixMessageText, d as resolveMatrixReplacementContent, h as formatPollAsText, l as isLikelyBareFilename, r as sendMessageMatrix, u as resolveMatrixMessageAttachment, v as isPollStartType, w as setBoundedMap, y as parsePollStart } from "./send-CWjH-l-T.mjs";
11
+ import { n as getMatrixEventProjection } from "./event-helpers-DDUjVVf7.mjs";
12
+ import { t as createMatrixThreadBindingManager } from "./thread-bindings-BA2xESjV.mjs";
13
+ import { a as isMatrixAccessTokenInvalidatedError } from "./client-support-CqXAOZp3.mjs";
14
+ import { a as isMatrixStartupAbortError, c as resolveMatrixAuth, l as resolveMatrixAuthContext, n as acquireSharedMatrixClient, o as throwIfMatrixStartupAborted, s as backfillMatrixAuthDeviceIdAfterStartup } from "./client-Bqu801rH.mjs";
15
+ import { i as readMatrixMessages, l as fetchMatrixPollSnapshot } from "./messages-BjzsVgS6.mjs";
16
+ import { a as isMatrixMediaSizeLimitError, i as MatrixMediaSizeLimitError } from "./http-client-CqnKFKUH.mjs";
17
+ import { n as prepareMatrixReplyPayload, r as resolveMatrixExtraContent } from "./outbound-wsXTF0z_.mjs";
18
+ import { t as resolveMatrixTargets } from "./resolve-targets-Yz_3aN_2.mjs";
19
+ import { t as formatMatrixEncryptedEventDisabledWarning } from "./encryption-guidance-DfbEaKct.mjs";
20
+ import { n as isMatrixReadySyncState, r as isMatrixTerminalSyncState, t as isMatrixDisconnectedSyncState } from "./sync-state-Cu1nagBV.mjs";
21
+ import { r as getMatrixRoomInfo, t as createMatrixRoomInfoResolver } from "./room-info-OGKjk422.mjs";
20
22
  import { channelBlockedPatch, channelReadyPatch, channelStoppedPatch, createTransportActivityStatusPatch } from "openclaw/plugin-sdk/gateway-runtime";
21
23
  import { createLazyRuntimeModule } from "openclaw/plugin-sdk/lazy-runtime";
22
- import { createChannelDeliveryAccumulator, createChannelProgressDraftCompositor, createLivePreviewLifecycle, createPreviewMessageReceipt, createReplyPrefixOptions, createTypingCallbacks, logTypingFailure, resolveChannelStreamingBlockEnabled, waitUntilAbort } from "openclaw/plugin-sdk/channel-outbound";
24
+ import { createChannelDeliveryAccumulator, createChannelIngressError, createChannelIngressMonitor, createChannelProgressDraftCompositor, createLivePreviewLifecycle, createPreviewMessageReceipt, createReplyPrefixOptions, createTypingCallbacks, logTypingFailure, resolveChannelStreamingBlockEnabled, waitUntilAbort } from "openclaw/plugin-sdk/channel-outbound";
23
25
  import { extractErrorCode, formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
24
26
  import { normalizeLowercaseStringOrEmpty, normalizeNullableString, normalizeOptionalString, normalizeStringifiedEntries, normalizeUniqueTrimmedStringList, readStringValue, uniqueStrings } from "openclaw/plugin-sdk/string-coerce-runtime";
25
27
  import { stripReasoningTagsFromText } from "openclaw/plugin-sdk/text-chunking";
26
28
  import { CHANNEL_APPROVAL_NATIVE_RUNTIME_CONTEXT_CAPABILITY } from "openclaw/plugin-sdk/approval-handler-adapter-runtime";
27
29
  import { addAllowlistUserEntriesFromConfigEntry, buildAllowlistResolutionSummary, canonicalizeAllowlistWithResolvedIds, patchAllowlistUsersInConfigEntries, summarizeMapping } from "openclaw/plugin-sdk/allow-from";
28
- import { normalizeStringEntries as normalizeStringEntries$1 } from "openclaw/plugin-sdk/string-normalization-runtime";
29
- import { isFutureDateTimestampMs, parseStrictFiniteNumber, resolveExpiresAtMsFromDurationMs, resolveOptionalIntegerOption, resolvePromptHistoryLimit } from "openclaw/plugin-sdk/number-runtime";
30
+ import { normalizeStringEntries as normalizeStringEntries$1, truncateWithMarker } from "openclaw/plugin-sdk/string-normalization-runtime";
31
+ import { parseStrictFiniteNumber, resolveOptionalIntegerOption, resolvePromptHistoryLimit } from "openclaw/plugin-sdk/number-runtime";
30
32
  import { resolveAgentRoute, resolveInboundLastRouteSessionKey } from "openclaw/plugin-sdk/routing";
31
33
  import { getSessionEntryAsync, resolveStorePath } from "openclaw/plugin-sdk/session-store-runtime";
32
34
  import { KeyedAsyncQueue } from "openclaw/plugin-sdk/keyed-async-queue";
33
- import { escapeRegExp, sliceUtf16Safe, truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
35
+ import { escapeRegExp, truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
34
36
  import { buildTtsSupplementMediaPayload, getReplyPayloadTtsSupplement, resolveSendableOutboundReplyParts } from "openclaw/plugin-sdk/reply-payload";
35
37
  import { format } from "node:util";
36
38
  import { resolvePinnedMainDmOwnerFromAllowlist } from "openclaw/plugin-sdk/security-runtime";
@@ -50,7 +52,7 @@ import { createChannelPreflightAudio, formatAudioTranscriptForAgent } from "open
50
52
  import { mergePairLoopGuardConfig } from "openclaw/plugin-sdk/pair-loop-guard-runtime";
51
53
  import { buildInboundHistoryFromEntries } from "openclaw/plugin-sdk/reply-history";
52
54
  import { decodeHtmlEntities } from "openclaw/plugin-sdk/html-entity-runtime";
53
- //#region extensions/matrix/src/matrix/monitor/auto-join.ts
55
+ // extensions/matrix/src/matrix/monitor/auto-join.ts
54
56
  function registerMatrixAutoJoin(params) {
55
57
  const { client, accountConfig, runtime } = params;
56
58
  const core = getMatrixRuntime();
@@ -65,14 +67,13 @@ function registerMatrixAutoJoin(params) {
65
67
  const allowedAliases = rawAllowlist.filter((entry) => entry.startsWith("#"));
66
68
  const resolvedAliasRoomIds = /* @__PURE__ */ new Map();
67
69
  if (autoJoin === "off") return () => {};
68
- if (autoJoin === "always") logVerbose("matrix: auto-join enabled for all invites");
69
- else {
70
- logVerbose("matrix: auto-join enabled for allowlist invites");
70
+ if (autoJoin === "allowlist") {
71
71
  const inertEntries = rawAllowlist.filter((entry) => !isMatrixInviteAutoJoinTarget(entry));
72
72
  if (inertEntries.length > 0) core.logging.getChildLogger({ module: "matrix-auto-join" }).warn(`matrix: autoJoinAllowlist entries cannot match an invited room and are ignored: ${inertEntries.join(", ")}`);
73
73
  }
74
74
  const resolveAllowedAliasRoomId = async (alias) => {
75
- if (resolvedAliasRoomIds.has(alias)) return resolvedAliasRoomIds.get(alias) ?? null;
75
+ const cached = resolvedAliasRoomIds.get(alias);
76
+ if (cached !== void 0) return cached;
76
77
  const resolved = await params.client.resolveRoom(alias);
77
78
  if (resolved) resolvedAliasRoomIds.set(alias, resolved);
78
79
  return resolved;
@@ -89,17 +90,23 @@ function registerMatrixAutoJoin(params) {
89
90
  };
90
91
  const onInvite = (roomId, _inviteEvent) => {
91
92
  params.runDetachedTask(`auto-join invite handler room=${roomId}`, async () => {
93
+ const monitorSignal = getMatrixMonitorTaskSignal();
92
94
  if (autoJoin === "allowlist") {
93
95
  const allowedAliasRoomIds = await resolveAllowedAliasRoomIds();
96
+ if (monitorSignal?.aborted) return;
94
97
  if (!(autoJoinAllowlist.has("*") || allowedRoomIds.has(roomId) || allowedAliasRoomIds.some((resolvedRoomId) => resolvedRoomId === roomId))) {
95
98
  logVerbose(`matrix: invite ignored (not in allowlist) room=${roomId}`);
96
99
  return;
97
100
  }
98
101
  }
102
+ if (monitorSignal?.aborted) return;
99
103
  try {
100
- await client.joinRoom(roomId);
104
+ await withMatrixSendCurrentness(client, () => {
105
+ monitorSignal?.throwIfAborted();
106
+ }, () => client.joinRoom(roomId));
101
107
  logVerbose(`matrix: joined room ${roomId}`);
102
108
  } catch (err) {
109
+ if (monitorSignal?.aborted) return;
103
110
  runtime.error?.(`matrix: failed to join room ${roomId}: ${String(err)}`);
104
111
  }
105
112
  });
@@ -109,8 +116,7 @@ function registerMatrixAutoJoin(params) {
109
116
  client.off("room.invite", onInvite);
110
117
  };
111
118
  }
112
- //#endregion
113
- //#region extensions/matrix/src/matrix/monitor/config.ts
119
+ // extensions/matrix/src/matrix/monitor/config.ts
114
120
  function normalizeMatrixUserLookupEntry(raw) {
115
121
  return raw.replace(/^matrix:/i, "").replace(/^user:/i, "").trim();
116
122
  }
@@ -179,7 +185,7 @@ async function resolveMatrixMonitorUserEntries(params) {
179
185
  resolved: false
180
186
  });
181
187
  }
182
- (pending.length === 0 ? [] : await params.resolveTargets({
188
+ (pending.length === 0 ? [] : await resolveMatrixTargets({
183
189
  cfg: params.cfg,
184
190
  accountId: params.accountId,
185
191
  inputs: pending.map((entry) => entry.query),
@@ -208,7 +214,6 @@ async function resolveMatrixMonitorUserAllowlist(params) {
208
214
  accountId: params.accountId,
209
215
  entries: allowList,
210
216
  runtime: params.runtime,
211
- resolveTargets: params.resolveTargets,
212
217
  allowNameMatching
213
218
  });
214
219
  const canonicalized = canonicalizeAllowlistWithResolvedIds({
@@ -276,7 +281,6 @@ async function resolveMatrixMonitorLiveUserAllowlist(params) {
276
281
  accountId: params.accountId,
277
282
  entries: pending,
278
283
  runtime: params.runtime,
279
- resolveTargets: params.resolveTargets ?? resolveMatrixTargets,
280
284
  allowNameMatching
281
285
  });
282
286
  const resolvedEntries = filterMatrixAllowlistEntries(canonicalizeAllowlistWithResolvedIds({
@@ -287,93 +291,90 @@ async function resolveMatrixMonitorLiveUserAllowlist(params) {
287
291
  for (const entry of resolvedEntries) addEntry(entry);
288
292
  return effective;
289
293
  }
290
- async function resolveMatrixMonitorRoomsConfig(params) {
291
- const roomsConfig = params.roomsConfig;
292
- if (!roomsConfig || Object.keys(roomsConfig).length === 0) return roomsConfig;
293
- const mapping = [];
294
- const unresolved = [];
295
- const nextRooms = {};
296
- const allowNameMatching = isMatrixDangerousNameMatchingEnabled({
297
- cfg: params.cfg,
298
- accountId: params.accountId
299
- });
300
- if (roomsConfig["*"]) nextRooms["*"] = roomsConfig["*"];
301
- const pending = [];
302
- for (const [entry, roomConfig] of Object.entries(roomsConfig)) {
303
- if (entry === "*") continue;
304
- const input = entry.trim();
305
- if (!input) continue;
306
- const cleaned = normalizeMatrixRoomLookupEntry(input);
307
- if (!cleaned) {
308
- unresolved.push(entry);
309
- continue;
310
- }
311
- if (isMatrixRoomId(cleaned)) {
312
- if (!nextRooms[cleaned]) nextRooms[cleaned] = roomConfig;
313
- if (cleaned !== input) mapping.push(`${input}→${cleaned}`);
314
- continue;
315
- }
316
- if (!cleaned.startsWith("#") && !allowNameMatching) {
317
- unresolved.push(input);
318
- continue;
294
+ async function resolveMatrixMonitorConfig(params) {
295
+ async function resolveMatrixMonitorRoomsConfig() {
296
+ const sourceRooms = params.roomsConfig;
297
+ if (!sourceRooms || Object.keys(sourceRooms).length === 0) return sourceRooms;
298
+ const mapping = [];
299
+ const unresolved = [];
300
+ const nextRooms = {};
301
+ const allowNameMatching = isMatrixDangerousNameMatchingEnabled({
302
+ cfg: params.cfg,
303
+ accountId: params.accountId
304
+ });
305
+ if (sourceRooms["*"]) nextRooms["*"] = sourceRooms["*"];
306
+ const pending = [];
307
+ for (const [entry, roomConfig] of Object.entries(sourceRooms)) {
308
+ if (entry === "*") continue;
309
+ const input = entry.trim();
310
+ if (!input) continue;
311
+ const cleaned = normalizeMatrixRoomLookupEntry(input);
312
+ if (!cleaned) {
313
+ unresolved.push(entry);
314
+ continue;
315
+ }
316
+ if (isMatrixRoomId(cleaned)) {
317
+ if (!nextRooms[cleaned]) nextRooms[cleaned] = roomConfig;
318
+ if (cleaned !== input) mapping.push(`${input}→${cleaned}`);
319
+ continue;
320
+ }
321
+ if (!cleaned.startsWith("#") && !allowNameMatching) {
322
+ unresolved.push(input);
323
+ continue;
324
+ }
325
+ pending.push({
326
+ input,
327
+ query: cleaned,
328
+ config: roomConfig
329
+ });
319
330
  }
320
- pending.push({
321
- input,
322
- query: cleaned,
323
- config: roomConfig
331
+ if (pending.length > 0) (await resolveMatrixTargets({
332
+ cfg: params.cfg,
333
+ accountId: params.accountId,
334
+ inputs: pending.map((entry) => entry.query),
335
+ kind: "group",
336
+ runtime: params.runtime
337
+ })).forEach((entry, index) => {
338
+ const source = pending[index];
339
+ if (!source) return;
340
+ if (entry.resolved && entry.id) {
341
+ const roomKey = normalizeMatrixRoomLookupEntry(entry.id);
342
+ if (!nextRooms[roomKey]) nextRooms[roomKey] = source.config;
343
+ mapping.push(`${source.input}→${roomKey}`);
344
+ } else unresolved.push(source.input);
345
+ });
346
+ summarizeMapping("matrix rooms", mapping, unresolved, params.runtime);
347
+ if (unresolved.length > 0) params.runtime.log?.("matrix rooms must be room IDs or aliases (example: !room:server, the suffixless !room form on room version 12+, or #alias:server). Unresolved entries are ignored.");
348
+ const roomUsers = /* @__PURE__ */ new Set();
349
+ for (const roomConfig of Object.values(nextRooms)) addAllowlistUserEntriesFromConfigEntry(roomUsers, roomConfig);
350
+ if (roomUsers.size === 0) return nextRooms;
351
+ const resolution = await resolveMatrixMonitorUserEntries({
352
+ cfg: params.cfg,
353
+ accountId: params.accountId,
354
+ entries: Array.from(roomUsers),
355
+ runtime: params.runtime,
356
+ allowNameMatching
357
+ });
358
+ logMatrixAllowlistResolution({
359
+ label: "matrix room users",
360
+ resolution,
361
+ allowNameMatching,
362
+ runtime: params.runtime
363
+ });
364
+ return patchAllowlistUsersInConfigEntries({
365
+ entries: nextRooms,
366
+ resolvedMap: resolution.resolvedMap,
367
+ strategy: "canonicalize",
368
+ entryKey: normalizeMatrixUserId
324
369
  });
325
370
  }
326
- if (pending.length > 0) (await params.resolveTargets({
327
- cfg: params.cfg,
328
- accountId: params.accountId,
329
- inputs: pending.map((entry) => entry.query),
330
- kind: "group",
331
- runtime: params.runtime
332
- })).forEach((entry, index) => {
333
- const source = pending[index];
334
- if (!source) return;
335
- if (entry.resolved && entry.id) {
336
- const roomKey = normalizeMatrixRoomLookupEntry(entry.id);
337
- if (!nextRooms[roomKey]) nextRooms[roomKey] = source.config;
338
- mapping.push(`${source.input}→${roomKey}`);
339
- } else unresolved.push(source.input);
340
- });
341
- summarizeMapping("matrix rooms", mapping, unresolved, params.runtime);
342
- if (unresolved.length > 0) params.runtime.log?.("matrix rooms must be room IDs or aliases (example: !room:server, the suffixless !room form on room version 12+, or #alias:server). Unresolved entries are ignored.");
343
- const roomUsers = /* @__PURE__ */ new Set();
344
- for (const roomConfig of Object.values(nextRooms)) addAllowlistUserEntriesFromConfigEntry(roomUsers, roomConfig);
345
- if (roomUsers.size === 0) return nextRooms;
346
- const resolution = await resolveMatrixMonitorUserEntries({
347
- cfg: params.cfg,
348
- accountId: params.accountId,
349
- entries: Array.from(roomUsers),
350
- runtime: params.runtime,
351
- resolveTargets: params.resolveTargets,
352
- allowNameMatching
353
- });
354
- logMatrixAllowlistResolution({
355
- label: "matrix room users",
356
- resolution,
357
- allowNameMatching,
358
- runtime: params.runtime
359
- });
360
- return patchAllowlistUsersInConfigEntries({
361
- entries: nextRooms,
362
- resolvedMap: resolution.resolvedMap,
363
- strategy: "canonicalize",
364
- entryKey: normalizeMatrixUserId
365
- });
366
- }
367
- async function resolveMatrixMonitorConfig(params) {
368
- const resolveTargets = params.resolveTargets ?? resolveMatrixTargets;
369
371
  const [allowFrom, groupAllowFrom, roomsConfig] = await Promise.all([
370
372
  resolveMatrixMonitorUserAllowlist({
371
373
  cfg: params.cfg,
372
374
  accountId: params.accountId,
373
375
  label: "matrix dm allowlist",
374
376
  list: params.allowFrom,
375
- runtime: params.runtime,
376
- resolveTargets
377
+ runtime: params.runtime
377
378
  }),
378
379
  resolveMatrixMonitorUserAllowlist({
379
380
  cfg: params.cfg,
@@ -381,16 +382,9 @@ async function resolveMatrixMonitorConfig(params) {
381
382
  label: "matrix group allowlist",
382
383
  list: params.groupAllowFrom,
383
384
  failClosedOnUnresolved: true,
384
- runtime: params.runtime,
385
- resolveTargets
385
+ runtime: params.runtime
386
386
  }),
387
- resolveMatrixMonitorRoomsConfig({
388
- cfg: params.cfg,
389
- accountId: params.accountId,
390
- roomsConfig: params.roomsConfig,
391
- runtime: params.runtime,
392
- resolveTargets
393
- })
387
+ resolveMatrixMonitorRoomsConfig()
394
388
  ]);
395
389
  return {
396
390
  allowFrom: allowFrom.entries,
@@ -400,8 +394,7 @@ async function resolveMatrixMonitorConfig(params) {
400
394
  roomsConfig
401
395
  };
402
396
  }
403
- //#endregion
404
- //#region extensions/matrix/src/matrix/monitor/direct.ts
397
+ // extensions/matrix/src/matrix/monitor/direct.ts
405
398
  const DM_CACHE_TTL_MS = 3e4;
406
399
  const RECENT_INVITE_TTL_MS = 3e4;
407
400
  const MAX_DM_ROOMS = 1024;
@@ -410,20 +403,10 @@ function createDirectRoomTracker(client, opts = {}) {
410
403
  const log = opts.log ?? (() => {});
411
404
  let lastDmUpdateMs = 0;
412
405
  let hasSeededDmCache = false;
413
- let cachedSelfUserId = null;
414
406
  const joinedMembersCache = /* @__PURE__ */ new Map();
415
407
  const directMemberFlagCache = /* @__PURE__ */ new Map();
416
408
  const recentInviteCandidates = /* @__PURE__ */ new Map();
417
409
  const locallyPromotedDirectRooms = /* @__PURE__ */ new Map();
418
- const ensureSelfUserId = async () => {
419
- if (cachedSelfUserId) return cachedSelfUserId;
420
- try {
421
- cachedSelfUserId = await client.getUserId();
422
- } catch {
423
- cachedSelfUserId = null;
424
- }
425
- return cachedSelfUserId;
426
- };
427
410
  const refreshDmCache = async () => {
428
411
  const now = Date.now();
429
412
  if (now - lastDmUpdateMs < DM_CACHE_TTL_MS) return;
@@ -530,12 +513,11 @@ function createDirectRoomTracker(client, opts = {}) {
530
513
  log(`matrix: remembered invite candidate room=${roomId} sender=${normalizedRemoteUserId}`);
531
514
  },
532
515
  isDirectMessage: async (params) => {
533
- const { roomId, senderId } = params;
516
+ const { roomId, senderId, selfUserId } = params;
534
517
  if (await checkRoomPolicy("isExplicitlyConfiguredRoom", roomId)) {
535
518
  log(`matrix: dm rejected via explicit room config room=${roomId}`);
536
519
  return false;
537
520
  }
538
- const selfUserId = params.selfUserId ?? await ensureSelfUserId();
539
521
  const joinedMembers = params.joinedMembers ?? await resolveJoinedMembers(roomId);
540
522
  const strictDirectMembership = isStrictDirectMembership({
541
523
  selfUserId,
@@ -579,12 +561,12 @@ function createDirectRoomTracker(client, opts = {}) {
579
561
  const promoteDirectRoom = async (source) => {
580
562
  const promotion = await promoteMatrixDirectRoomCandidate({
581
563
  client,
582
- remoteUserId: senderId ?? "",
564
+ remoteUserId: senderId,
583
565
  roomId,
584
566
  selfUserId
585
567
  });
586
568
  if (promotion.classifyAsDirect) {
587
- rememberLocallyPromotedDirectRoom(roomId, senderId ?? "");
569
+ rememberLocallyPromotedDirectRoom(roomId, senderId);
588
570
  log(`matrix: dm detected via ${source} room=${roomId} reason=${promotion.reason} repaired=${String(promotion.repaired)}`);
589
571
  }
590
572
  return promotion.classifyAsDirect;
@@ -597,17 +579,16 @@ function createDirectRoomTracker(client, opts = {}) {
597
579
  }
598
580
  };
599
581
  }
600
- //#endregion
601
- //#region extensions/matrix/src/matrix/monitor/types.ts
582
+ // extensions/matrix/src/matrix/monitor/types.ts
602
583
  const EventType = {
603
584
  RoomMessage: "m.room.message",
604
585
  RoomMessageEncrypted: "m.room.encrypted",
605
586
  RoomMember: "m.room.member",
587
+ RoomName: "m.room.name",
606
588
  Location: "m.location",
607
589
  Reaction: MATRIX_REACTION_EVENT_TYPE
608
590
  };
609
- //#endregion
610
- //#region extensions/matrix/src/matrix/monitor/access-state.ts
591
+ // extensions/matrix/src/matrix/monitor/access-state.ts
611
592
  function normalizeMatrixEntry(raw) {
612
593
  return normalizeMatrixAllowList([raw ?? ""])[0] ?? null;
613
594
  }
@@ -616,7 +597,7 @@ const matrixIngressIdentity = defineStableChannelIngressIdentity({
616
597
  normalize: normalizeMatrixEntry,
617
598
  matchEntry({ subject, entry }) {
618
599
  const senderId = subject.identifiers[0]?.value;
619
- return entry.value === "*" || resolveMatrixAllowListMatch({
600
+ return resolveMatrixAllowListMatch({
620
601
  allowList: [entry.value],
621
602
  userId: senderId ?? ""
622
603
  }).allowed;
@@ -705,7 +686,7 @@ async function resolveMatrixMonitorCommandAccess(state, params) {
705
686
  allowFrom: commandAllowFrom,
706
687
  groupAllowFrom: commandGroupAllowFrom,
707
688
  command: {
708
- useAccessGroups: params.useAccessGroups,
689
+ useAccessGroups: true,
709
690
  allowTextCommands: params.allowTextCommands,
710
691
  hasControlCommand: params.hasControlCommand,
711
692
  groupOwnerAllowFrom: "none",
@@ -713,8 +694,7 @@ async function resolveMatrixMonitorCommandAccess(state, params) {
713
694
  }
714
695
  })).commandAccess;
715
696
  }
716
- //#endregion
717
- //#region extensions/matrix/src/matrix/monitor/verification-utils.ts
697
+ // extensions/matrix/src/matrix/monitor/verification-utils.ts
718
698
  const VERIFICATION_EVENT_PREFIX = "m.key.verification.";
719
699
  const VERIFICATION_REQUEST_MSGTYPE = "m.key.verification.request";
720
700
  const VERIFICATION_NOTICE_PREFIXES = [
@@ -742,12 +722,11 @@ const matrixVerificationConstants = {
742
722
  eventPrefix: VERIFICATION_EVENT_PREFIX,
743
723
  requestMsgtype: VERIFICATION_REQUEST_MSGTYPE
744
724
  };
745
- //#endregion
746
- //#region extensions/matrix/src/matrix/monitor/verification-events.ts
725
+ // extensions/matrix/src/matrix/monitor/verification-events.ts
747
726
  const MAX_TRACKED_VERIFICATION_EVENTS = 1024;
748
727
  const SAS_NOTICE_RETRY_DELAY_MS = 750;
749
728
  const VERIFICATION_EVENT_STARTUP_GRACE_MS = 3e4;
750
- const loadMatrixDirectRoomDeps = createLazyRuntimeModule(() => Promise.all([import("./direct-management-B3wYhx_M.mjs").then((n) => n.t), import("./direct-management-B3wYhx_M.mjs").then((n) => n.o)]).then(([directManagementModule, directRoomModule]) => ({
729
+ const loadMatrixDirectRoomDeps = createLazyRuntimeModule(() => Promise.all([import("./direct-management-D59C1WO-.mjs").then((n) => n.t), import("./direct-management-D59C1WO-.mjs").then((n) => n.o)]).then(([directManagementModule, directRoomModule]) => ({
751
730
  inspectMatrixDirectRooms: directManagementModule.inspectMatrixDirectRooms,
752
731
  isStrictDirectRoom: directRoomModule.isStrictDirectRoom
753
732
  })));
@@ -809,8 +788,8 @@ function formatVerificationStageNotice(params) {
809
788
  function formatVerificationSasNotice(summary) {
810
789
  const sas = summary.sas;
811
790
  if (!sas) return null;
812
- const emojiLine = Array.isArray(sas.emoji) && sas.emoji.length > 0 ? `SAS emoji: ${sas.emoji.map(([emoji, name]) => `${normalizeNullableString(emoji) ?? "?"} ${normalizeNullableString(name) ?? "?"}`).join(" | ")}` : null;
813
- const decimalLine = Array.isArray(sas.decimal) && sas.decimal.length === 3 ? `SAS decimal: ${sas.decimal.join(" ")}` : null;
791
+ const emojiLine = sas.emoji?.length ? `SAS emoji: ${sas.emoji.map(([emoji, name]) => `${normalizeNullableString(emoji) ?? "?"} ${normalizeNullableString(name) ?? "?"}`).join(" | ")}` : null;
792
+ const decimalLine = sas.decimal ? `SAS decimal: ${sas.decimal.join(" ")}` : null;
814
793
  if (!emojiLine && !decimalLine) return null;
815
794
  const lines = [`Matrix verification SAS with ${summary.otherUserId}:`];
816
795
  if (emojiLine) lines.push(emojiLine);
@@ -828,65 +807,18 @@ function resolveVerificationFlowCandidates(params) {
828
807
  content["m.relates_to"]?.event_id
829
808
  ]);
830
809
  }
831
- function resolveSummaryRecency(summary) {
832
- const ts = Date.parse(summary.updatedAt ?? "");
833
- return Number.isFinite(ts) ? ts : 0;
834
- }
835
810
  function isActiveVerificationSummary(summary) {
836
811
  if (summary.completed) return false;
837
812
  if (summary.phaseName === "cancelled" || summary.phaseName === "done") return false;
838
- if (typeof summary.phase === "number" && summary.phase >= 4) return false;
813
+ if (summary.phase >= 4) return false;
839
814
  return true;
840
815
  }
841
- async function resolveVerificationSummaryForSignal(client, params) {
842
- if (!client.crypto) return null;
843
- await client.crypto.ensureVerificationDmTracked({
844
- roomId: params.roomId,
845
- userId: params.senderId
846
- }).catch(() => null);
847
- const list = await client.crypto.listVerifications();
848
- if (list.length === 0) return null;
849
- const candidates = resolveVerificationFlowCandidates({
850
- event: params.event,
851
- flowId: params.flowId
852
- });
853
- const byTransactionId = list.find((entry) => candidates.some((candidate) => entry.transactionId === candidate));
854
- if (byTransactionId) return byTransactionId;
855
- const { inspectMatrixDirectRooms, isStrictDirectRoom } = await loadMatrixDirectRoomDeps();
856
- const inspection = await inspectMatrixDirectRooms({
857
- client,
858
- remoteUserId: params.senderId
859
- }).catch(() => null);
860
- const activeRoomId = normalizeNullableString(inspection?.activeRoomId);
861
- if (activeRoomId) {
862
- if (activeRoomId !== params.roomId) return null;
863
- } else if (!await isStrictDirectRoom({
864
- client,
865
- roomId: params.roomId,
866
- remoteUserId: params.senderId
867
- })) return null;
868
- const activeByUser = list.filter((entry) => entry.otherUserId === params.senderId && isActiveVerificationSummary(entry)).toSorted((a, b) => resolveSummaryRecency(b) - resolveSummaryRecency(a));
869
- return activeByUser.find((entry) => normalizeNullableString(entry.roomId) === params.roomId) ?? activeByUser[0] ?? null;
870
- }
871
- async function resolveVerificationSasNoticeForSignal(client, params) {
872
- for (let attempt = 0;; attempt += 1) {
873
- const summary = await resolveVerificationSummaryForSignal(client, params);
874
- const sasNotice = summary && isActiveVerificationSummary(summary) ? formatVerificationSasNotice(summary) : null;
875
- if (sasNotice || attempt > 0 || params.stage !== "ready" && params.stage !== "start") return {
876
- summary,
877
- sasNotice
878
- };
879
- await new Promise((resolve) => {
880
- setTimeout(resolve, params.sasNoticeRetryDelayMs ?? SAS_NOTICE_RETRY_DELAY_MS);
881
- });
882
- }
883
- }
884
816
  function trackBounded(set, value) {
885
817
  if (!value || set.has(value)) return false;
886
818
  set.add(value);
887
819
  if (set.size > MAX_TRACKED_VERIFICATION_EVENTS) {
888
820
  const oldest = set.values().next().value;
889
- if (typeof oldest === "string") set.delete(oldest);
821
+ if (oldest !== void 0) set.delete(oldest);
890
822
  }
891
823
  return true;
892
824
  }
@@ -1012,14 +944,51 @@ function createMatrixVerificationEventRouter(params) {
1012
944
  senderId,
1013
945
  event
1014
946
  });
1015
- const { summary, sasNotice } = await resolveVerificationSasNoticeForSignal(params.client, {
1016
- roomId,
1017
- event,
1018
- senderId,
1019
- flowId,
1020
- stage: signal.stage,
1021
- sasNoticeRetryDelayMs: params.sasNoticeRetryDelayMs
1022
- }).catch(() => ({
947
+ const { client, sasNoticeRetryDelayMs } = params;
948
+ const resolveSummary = async () => {
949
+ if (!client.crypto) return null;
950
+ await client.crypto.ensureVerificationDmTracked({
951
+ roomId,
952
+ userId: senderId
953
+ }).catch(() => null);
954
+ const list = await client.crypto.listVerifications();
955
+ if (list.length === 0) return null;
956
+ const candidates = resolveVerificationFlowCandidates({
957
+ event,
958
+ flowId
959
+ });
960
+ const byTransactionId = list.find((entry) => candidates.some((candidate) => entry.transactionId === candidate));
961
+ if (byTransactionId) return byTransactionId;
962
+ const { inspectMatrixDirectRooms, isStrictDirectRoom } = await loadMatrixDirectRoomDeps();
963
+ const inspection = await inspectMatrixDirectRooms({
964
+ client,
965
+ remoteUserId: senderId
966
+ }).catch(() => null);
967
+ const activeRoomId = normalizeNullableString(inspection?.activeRoomId);
968
+ if (activeRoomId) {
969
+ if (activeRoomId !== roomId) return null;
970
+ } else if (!await isStrictDirectRoom({
971
+ client,
972
+ roomId,
973
+ remoteUserId: senderId
974
+ })) return null;
975
+ const activeByUser = list.filter((entry) => entry.otherUserId === senderId && isActiveVerificationSummary(entry));
976
+ return activeByUser.find((entry) => normalizeNullableString(entry.roomId) === roomId) ?? activeByUser[0] ?? null;
977
+ };
978
+ const resolveSasNotice = async () => {
979
+ for (let attempt = 0;; attempt += 1) {
980
+ const summary = await resolveSummary();
981
+ const sasNotice = summary && isActiveVerificationSummary(summary) ? formatVerificationSasNotice(summary) : null;
982
+ if (sasNotice || attempt > 0 || signal.stage !== "ready" && signal.stage !== "start") return {
983
+ summary,
984
+ sasNotice
985
+ };
986
+ await new Promise((resolve) => {
987
+ setTimeout(resolve, sasNoticeRetryDelayMs ?? SAS_NOTICE_RETRY_DELAY_MS);
988
+ });
989
+ }
990
+ };
991
+ const { summary, sasNotice } = await resolveSasNotice().catch(() => ({
1023
992
  summary: null,
1024
993
  sasNotice: null
1025
994
  }));
@@ -1034,10 +1003,7 @@ function createMatrixVerificationEventRouter(params) {
1034
1003
  }
1035
1004
  for (const body of notices) await sendVerificationNotice(roomId, body);
1036
1005
  };
1037
- if (params.runDetachedTask) params.runDetachedTask(`verification event handler room=${roomId} id=${event.event_id ?? "unknown"}`, routeTask);
1038
- else routeTask().catch((err) => {
1039
- params.logVerboseMessage(`matrix: failed routing verification event: ${String(err)}`);
1040
- });
1006
+ params.runDetachedTask(`verification event handler room=${roomId} id=${event.event_id ?? "unknown"}`, routeTask);
1041
1007
  return true;
1042
1008
  }
1043
1009
  return {
@@ -1045,23 +1011,13 @@ function createMatrixVerificationEventRouter(params) {
1045
1011
  routeVerificationSummary
1046
1012
  };
1047
1013
  }
1048
- //#endregion
1049
- //#region extensions/matrix/src/matrix/monitor/events.ts
1014
+ // extensions/matrix/src/matrix/monitor/events.ts
1050
1015
  const MATRIX_POST_HEALTHY_SYNC_DECRYPT_FAILURE_WINDOW_MS = 12e4;
1051
1016
  const MATRIX_POST_HEALTHY_SYNC_DECRYPT_FAILURE_THRESHOLD = 3;
1052
1017
  const MATRIX_POST_HEALTHY_SYNC_DECRYPT_FAILURE_SAMPLE_LIMIT = 3;
1053
1018
  function formatMatrixPostHealthySyncDecryptionHint(accountId) {
1054
1019
  return `matrix: repeated fresh encrypted messages are still failing to decrypt after Matrix resumed healthy sync. This device may still be missing new room keys. Check 'openclaw matrix verify status --verbose --account ${accountId}' and 'openclaw matrix devices list --account ${accountId}'.`;
1055
1020
  }
1056
- function isFreshPostHealthySyncDecryptFailure(params) {
1057
- const { event, healthySyncSinceMs, nowMs } = params;
1058
- if (typeof healthySyncSinceMs !== "number" || !Number.isFinite(healthySyncSinceMs)) return false;
1059
- const eventTs = event.origin_server_ts;
1060
- if (!Number.isFinite(eventTs) || eventTs <= 0) return false;
1061
- if (eventTs < healthySyncSinceMs) return false;
1062
- if (eventTs > nowMs + 6e4) return false;
1063
- return true;
1064
- }
1065
1021
  function createMatrixPostHealthySyncDecryptFailureTracker(params) {
1066
1022
  let observations = [];
1067
1023
  let warningEmitted = false;
@@ -1081,11 +1037,12 @@ function createMatrixPostHealthySyncDecryptFailureTracker(params) {
1081
1037
  trackedHealthySyncSinceMs = healthySyncSinceMs;
1082
1038
  resetObservations();
1083
1039
  }
1084
- if (!isFreshPostHealthySyncDecryptFailure({
1085
- event,
1086
- healthySyncSinceMs,
1087
- nowMs
1088
- })) return {
1040
+ if (typeof healthySyncSinceMs !== "number" || !Number.isFinite(healthySyncSinceMs)) return {
1041
+ freshAfterHealthySync: false,
1042
+ failureCount: 0
1043
+ };
1044
+ const eventTs = event.origin_server_ts;
1045
+ if (!Number.isFinite(eventTs) || eventTs <= 0 || eventTs < healthySyncSinceMs || eventTs > nowMs + 6e4) return {
1089
1046
  freshAfterHealthySync: false,
1090
1047
  failureCount: 0
1091
1048
  };
@@ -1128,7 +1085,6 @@ function formatMatrixSelfDecryptionHint(accountId) {
1128
1085
  return `matrix: failed to decrypt a message from this same Matrix user. This usually means another Matrix device did not share the room key, or another OpenClaw runtime is using the same account. Check 'openclaw matrix verify status --verbose --account ${accountId}' and 'openclaw matrix devices list --account ${accountId}'.`;
1129
1086
  }
1130
1087
  async function resolveMatrixSelfUserId(client, logVerboseMessage) {
1131
- if (typeof client.getUserId !== "function") return null;
1132
1088
  try {
1133
1089
  return await client.getUserId() ?? null;
1134
1090
  } catch (err) {
@@ -1137,7 +1093,7 @@ async function resolveMatrixSelfUserId(client, logVerboseMessage) {
1137
1093
  }
1138
1094
  }
1139
1095
  function registerMatrixMonitorEvents(params) {
1140
- const { cfg, client, auth, allowFrom, dmEnabled, dmPolicy, readStoreAllowFrom, directTracker, invalidateMemberDisplayName, logVerboseMessage, warnedEncryptedRooms, warnedCryptoMissingRooms, logger, getHealthySyncSinceMs, formatNativeDependencyHint, onRoomMessage, runDetachedTask, sasNoticeRetryDelayMs } = params;
1096
+ const { cfg, client, auth, allowFrom, dmEnabled, dmPolicy, readStoreAllowFrom, directTracker, invalidateMemberDisplayName, invalidateRoomName, logVerboseMessage, warnedEncryptedRooms, warnedCryptoMissingRooms, logger, getHealthySyncSinceMs, formatNativeDependencyHint, runDetachedTask, sasNoticeRetryDelayMs } = params;
1141
1097
  const postHealthySyncDecryptFailureTracker = createMatrixPostHealthySyncDecryptFailureTracker({ getHealthySyncSinceMs });
1142
1098
  const { routeVerificationEvent, routeVerificationSummary } = createMatrixVerificationEventRouter({
1143
1099
  client,
@@ -1149,20 +1105,8 @@ function registerMatrixMonitorEvents(params) {
1149
1105
  runDetachedTask,
1150
1106
  sasNoticeRetryDelayMs
1151
1107
  });
1152
- const runMonitorTask = (label, task) => {
1153
- if (runDetachedTask) return runDetachedTask(label, task);
1154
- return Promise.resolve().then(task).catch((error) => {
1155
- logVerboseMessage(`matrix: ${label} failed (${String(error)})`);
1156
- });
1157
- };
1158
- const dispatchRoomMessage = (label, roomId, event) => {
1159
- runMonitorTask(`${label} room=${roomId} id=${event.event_id ?? "unknown"}`, async () => {
1160
- await onRoomMessage(roomId, event);
1161
- });
1162
- };
1163
1108
  const onRoomMessageEvent = (roomId, event) => {
1164
- if (routeVerificationEvent(roomId, event)) return;
1165
- dispatchRoomMessage("room message handler", roomId, event);
1109
+ routeVerificationEvent(roomId, event);
1166
1110
  };
1167
1111
  const onEncryptedEvent = (roomId, event) => {
1168
1112
  const eventId = event?.event_id ?? "unknown";
@@ -1173,12 +1117,10 @@ function registerMatrixMonitorEvents(params) {
1173
1117
  const eventId = event?.event_id ?? "unknown";
1174
1118
  const eventType = event?.type ?? "unknown";
1175
1119
  logVerboseMessage(`matrix: decrypted event room=${roomId} type=${eventType} id=${eventId}`);
1176
- if (routeVerificationEvent(roomId, event)) return;
1177
- if (eventType !== EventType.RoomMessage) return;
1178
- dispatchRoomMessage("decrypted room message handler", roomId, event);
1120
+ routeVerificationEvent(roomId, event);
1179
1121
  };
1180
1122
  const onFailedDecryption = (roomId, event, error) => {
1181
- runMonitorTask(`failed decryption handler room=${roomId} id=${event.event_id ?? "unknown"}`, async () => {
1123
+ runDetachedTask(`failed decryption handler room=${roomId} id=${event.event_id ?? "unknown"}`, async () => {
1182
1124
  const failureState = postHealthySyncDecryptFailureTracker.recordFailure(roomId, event, error);
1183
1125
  const selfUserId = await resolveMatrixSelfUserId(client, logVerboseMessage);
1184
1126
  const sender = typeof event.sender === "string" ? event.sender : null;
@@ -1213,7 +1155,7 @@ function registerMatrixMonitorEvents(params) {
1213
1155
  });
1214
1156
  };
1215
1157
  const onVerificationSummary = (summary) => {
1216
- runMonitorTask("verification summary handler", async () => {
1158
+ runDetachedTask("verification summary handler", async () => {
1217
1159
  await routeVerificationSummary(summary);
1218
1160
  });
1219
1161
  };
@@ -1222,9 +1164,9 @@ function registerMatrixMonitorEvents(params) {
1222
1164
  const eventId = event?.event_id ?? "unknown";
1223
1165
  const sender = event?.sender ?? "unknown";
1224
1166
  const invitee = normalizeOptionalString(event?.state_key) ?? "";
1225
- const senderIsInvitee = Boolean(invitee) && (normalizeOptionalString(event?.sender) ?? "") === invitee;
1226
- const isDirect = (event?.content)?.is_direct === true;
1227
1167
  const rememberedSender = normalizeOptionalString(event?.sender);
1168
+ const senderIsInvitee = Boolean(invitee) && rememberedSender === invitee;
1169
+ const isDirect = (event?.content)?.is_direct === true;
1228
1170
  if (rememberedSender && !senderIsInvitee) directTracker?.rememberInvite?.(roomId, rememberedSender);
1229
1171
  logVerboseMessage(`matrix: invite room=${roomId} sender=${sender} direct=${String(isDirect)} id=${eventId}`);
1230
1172
  };
@@ -1233,7 +1175,7 @@ function registerMatrixMonitorEvents(params) {
1233
1175
  const eventId = event?.event_id ?? "unknown";
1234
1176
  logVerboseMessage(`matrix: join room=${roomId} id=${eventId}`);
1235
1177
  if (event.membershipProvenance !== "transition" || event.state_key !== auth.userId) return;
1236
- runMonitorTask(`join introduction room=${roomId}`, async () => {
1178
+ runDetachedTask(`join introduction room=${roomId}`, async () => {
1237
1179
  const members = await readJoinedMatrixMembers(client, roomId);
1238
1180
  const remoteUserId = members?.find((member) => member !== auth.userId);
1239
1181
  if (!members?.includes(auth.userId) || !remoteUserId || await directTracker.isDirectMessage({
@@ -1321,10 +1263,7 @@ function registerMatrixMonitorEvents(params) {
1321
1263
  if (stateKey) invalidateMemberDisplayName?.(roomId, stateKey);
1322
1264
  logVerboseMessage(`matrix: member event room=${roomId} stateKey=${stateKey} membership=${membership ?? "unknown"}`);
1323
1265
  }
1324
- if (eventType === EventType.Reaction) {
1325
- dispatchRoomMessage("reaction handler", roomId, event);
1326
- return;
1327
- }
1266
+ if (eventType === EventType.RoomName) invalidateRoomName?.(roomId);
1328
1267
  routeVerificationEvent(roomId, event);
1329
1268
  };
1330
1269
  client.on("room.message", onRoomMessageEvent);
@@ -1346,13 +1285,7 @@ function registerMatrixMonitorEvents(params) {
1346
1285
  client.off("room.event", onRoomEvent);
1347
1286
  };
1348
1287
  }
1349
- //#endregion
1350
- //#region extensions/matrix/src/matrix/monitor/context-summary.ts
1351
- const MAX_CONTEXT_BODY_LENGTH = 500;
1352
- function truncateMatrixContextBody(value) {
1353
- if (value.length <= MAX_CONTEXT_BODY_LENGTH) return value;
1354
- return `${sliceUtf16Safe(value, 0, 497)}...`;
1355
- }
1288
+ // extensions/matrix/src/matrix/monitor/event-context.ts
1356
1289
  function summarizeMatrixMessageContextEvent(event) {
1357
1290
  if (isPollStartType(event.type)) {
1358
1291
  const pollSummary = parsePollStart(event.content);
@@ -1365,8 +1298,7 @@ function summarizeMatrixMessageContextEvent(event) {
1365
1298
  msgtype: normalizeOptionalString(content.msgtype)
1366
1299
  });
1367
1300
  }
1368
- //#endregion
1369
- //#region extensions/matrix/src/matrix/monitor/event-context.ts
1301
+ const MAX_CONTEXT_BODY_LENGTH = 500;
1370
1302
  function createMatrixEventContextResolver(params) {
1371
1303
  const cache = /* @__PURE__ */ new Map();
1372
1304
  const isThread = params.kind === "thread";
@@ -1388,7 +1320,11 @@ function createMatrixEventContextResolver(params) {
1388
1320
  const context = {};
1389
1321
  if (isThread || !event.unsigned?.redacted_because) {
1390
1322
  const body = summarizeMatrixMessageContextEvent(event);
1391
- let summary = body ? truncateMatrixContextBody(body) : void 0;
1323
+ let summary = body ? truncateWithMarker(body, MAX_CONTEXT_BODY_LENGTH, {
1324
+ marker: "...",
1325
+ reserve: 3,
1326
+ trimEnd: false
1327
+ }) : void 0;
1392
1328
  if (isThread && !summary) {
1393
1329
  const msgtype = normalizeOptionalString(event.content.msgtype);
1394
1330
  const eventType = normalizeOptionalString(event.type);
@@ -1413,8 +1349,7 @@ function createMatrixEventContextResolver(params) {
1413
1349
  return context;
1414
1350
  };
1415
1351
  }
1416
- //#endregion
1417
- //#region extensions/matrix/src/matrix/monitor/ack-config.ts
1352
+ // extensions/matrix/src/matrix/monitor/ack-config.ts
1418
1353
  function resolveMatrixAckReactionConfig(params) {
1419
1354
  const matrixConfig = params.cfg.channels?.matrix;
1420
1355
  const accountConfig = resolveMatrixAccountConfig({
@@ -1429,8 +1364,7 @@ function resolveMatrixAckReactionConfig(params) {
1429
1364
  ackReactionScope: accountConfig.ackReactionScope ?? matrixConfig?.ackReactionScope ?? params.cfg.messages?.ackReactionScope ?? "group-mentions"
1430
1365
  };
1431
1366
  }
1432
- //#endregion
1433
- //#region extensions/matrix/src/matrix/monitor/preflight-audio.ts
1367
+ // extensions/matrix/src/matrix/monitor/preflight-audio.ts
1434
1368
  function isMatrixAudioContent(params) {
1435
1369
  if (params.msgtype === "m.audio") return true;
1436
1370
  if (params.msgtype === "m.file" && typeof params.mimetype === "string") return params.mimetype.toLowerCase().startsWith("audio/");
@@ -1440,30 +1374,7 @@ const matrixPreflightAudio = createChannelPreflightAudio({
1440
1374
  channel: "matrix",
1441
1375
  isAudio: isMatrixAudioContent
1442
1376
  });
1443
- async function resolveMatrixPreflightAudioTranscript(params) {
1444
- return await matrixPreflightAudio.resolve({
1445
- request: {
1446
- ctx: {
1447
- media: [{
1448
- path: params.mediaPath,
1449
- contentType: params.mediaContentType
1450
- }],
1451
- Provider: "matrix",
1452
- Surface: "matrix",
1453
- OriginatingChannel: "matrix",
1454
- OriginatingTo: params.originatingTo,
1455
- AccountId: params.accountId,
1456
- MessageThreadId: params.messageThreadId,
1457
- ChatType: params.chatType,
1458
- SessionKey: params.sessionKey
1459
- },
1460
- cfg: params.cfg
1461
- },
1462
- abortSignal: params.abortSignal
1463
- });
1464
- }
1465
- //#endregion
1466
- //#region extensions/matrix/src/matrix/monitor/handler-helpers.ts
1377
+ // extensions/matrix/src/matrix/monitor/handler-helpers.ts
1467
1378
  const MATRIX_TOOL_PROGRESS_MAX_CHARS = 300;
1468
1379
  const MAX_TRACKED_SHARED_DM_CONTEXT_NOTICES = 512;
1469
1380
  function resolveMatrixMentionPrecheckText(params) {
@@ -1480,27 +1391,6 @@ function hasBundledMatrixReplacementRelation(event) {
1480
1391
  if (!relations || typeof relations !== "object") return false;
1481
1392
  return relations[RelationType.Replace] !== void 0;
1482
1393
  }
1483
- function resolveMatrixInboundBodyText(params) {
1484
- if (params.mediaPlaceholder) {
1485
- if (params.filename?.trim()) {
1486
- const attachment = resolveMatrixMessageAttachment({
1487
- body: params.rawBody,
1488
- filename: params.filename,
1489
- msgtype: params.msgtype
1490
- });
1491
- if (attachment && !attachment.caption) return params.mediaPlaceholder;
1492
- }
1493
- return params.rawBody || params.mediaPlaceholder;
1494
- }
1495
- if (!params.mediaDownloadFailed || !params.hadMediaUrl) return params.rawBody;
1496
- return formatMatrixMessageText({
1497
- body: params.rawBody,
1498
- filename: params.filename,
1499
- msgtype: params.msgtype,
1500
- tooLarge: params.mediaSizeLimitExceeded,
1501
- unavailable: true
1502
- }) ?? "";
1503
- }
1504
1394
  function markTrackedRoomIfFirst(set, roomId) {
1505
1395
  if (set.has(roomId)) return false;
1506
1396
  set.add(roomId);
@@ -1572,13 +1462,12 @@ function resolveMatrixAllowBotsMode(value) {
1572
1462
  function formatMatrixToolProgressMarkdownCode(text) {
1573
1463
  return `\`${(text.length <= MATRIX_TOOL_PROGRESS_MAX_CHARS ? text : `${truncateUtf16Safe(text, 299).trimEnd()}...`).replaceAll("`", "'")}\``;
1574
1464
  }
1575
- //#endregion
1576
- //#region extensions/matrix/src/matrix/monitor/handler-runtime.ts
1577
- const loadMatrixSendModule = createLazyRuntimeModule(() => import("./send-CFx1h7xE.mjs").then((n) => n.s));
1465
+ // extensions/matrix/src/matrix/monitor/handler-runtime.ts
1466
+ const loadMatrixSendModule = createLazyRuntimeModule(() => import("./send-CWjH-l-T.mjs").then((n) => n.s));
1578
1467
  const loadAcpBindingRuntime = createLazyRuntimeModule(() => import("openclaw/plugin-sdk/acp-binding-runtime"));
1579
1468
  const loadSessionBindingRuntime = createLazyRuntimeModule(() => import("openclaw/plugin-sdk/session-binding-runtime"));
1580
- const loadMatrixReactionEvents = createLazyRuntimeModule(() => import("./reaction-events-51DOeO0I.mjs"));
1581
- const loadMatrixDraftStream = createLazyRuntimeModule(() => import("./draft-stream-K6Lu-JEI.mjs"));
1469
+ const loadMatrixReactionEvents = createLazyRuntimeModule(() => import("./reaction-events-BMsatzs4.mjs"));
1470
+ const loadMatrixDraftStream = createLazyRuntimeModule(() => import("./draft-stream-C09OtoJZ.mjs"));
1582
1471
  async function matrixTextWouldActivateMentions(client, text) {
1583
1472
  const { resolveMatrixMentionsForBody } = await loadMatrixSendModule();
1584
1473
  const mentions = await resolveMatrixMentionsForBody({
@@ -1587,11 +1476,10 @@ async function matrixTextWouldActivateMentions(client, text) {
1587
1476
  });
1588
1477
  return mentions.room === true || (mentions.user_ids?.length ?? 0) > 0;
1589
1478
  }
1590
- //#endregion
1591
- //#region extensions/matrix/src/matrix/monitor/handler-context.ts
1479
+ // extensions/matrix/src/matrix/monitor/handler-context.ts
1592
1480
  async function resolveMatrixInboundContext(config) {
1593
1481
  const { handler, ingress, roomId, event, eventTs, resolveThreadContext, resolveReplyContext, senderId, sharedDmContextNoticeRooms } = config;
1594
- const { client, core, accountId, runtime, logVerboseMessage, groupPolicy, getRoomInfo, historyLimit, dmSessionScope, resolveStorePath: resolveStorePathImpl, createChannelInboundEnvelopeBuilderAsync: createChannelInboundEnvelopeBuilderImpl, finalizeInboundContext } = handler;
1482
+ const { client, core, accountId, runtime, logVerboseMessage, groupPolicy, getRoomInfo, historyLimit, dmSessionScope } = handler;
1595
1483
  const { cfg, resolveMessageIngress, route: _route, isDirectMessage, isRoom, effectiveRoomUsers, effectiveGroupAllowFrom, threadRootId, thread, senderName, bodyText, commandBodyText, roomConfig, messageId, inboundHistory, wasMentioned, effectiveWasMentioned, shouldBypassMention, canDetectMention, shouldRequireMention, commandAuthorized, isControlCommand, locationPayload, media, preflightAudioTranscript, hasExplicitSessionBinding } = ingress;
1596
1484
  const contextVisibilityMode = resolveChannelContextVisibilityMode({
1597
1485
  cfg,
@@ -1612,16 +1500,16 @@ async function resolveMatrixInboundContext(config) {
1612
1500
  }).allowed;
1613
1501
  return true;
1614
1502
  };
1615
- const shouldIncludeRoomContextSender = (kind, contextSenderId) => evaluateSupplementalContextVisibility({
1503
+ const shouldIncludeRoomContextSender = (contextSenderId) => evaluateSupplementalContextVisibility({
1616
1504
  mode: contextVisibilityMode,
1617
- kind,
1505
+ kind: "thread",
1618
1506
  senderAllowed: isRoomContextSenderAllowed(contextSenderId)
1619
1507
  }).include;
1620
1508
  let threadContext = ingress.threadContext ?? (threadRootId ? await resolveThreadContext({
1621
1509
  roomId,
1622
1510
  eventId: threadRootId
1623
1511
  }) : void 0);
1624
- if (threadContext?.senderId && !shouldIncludeRoomContextSender("thread", threadContext.senderId)) {
1512
+ if (threadContext?.senderId && !shouldIncludeRoomContextSender(threadContext.senderId)) {
1625
1513
  logVerboseMessage(`matrix: drop thread root context (mode=${contextVisibilityMode})`);
1626
1514
  threadContext = void 0;
1627
1515
  }
@@ -1636,11 +1524,11 @@ async function resolveMatrixInboundContext(config) {
1636
1524
  eventId: replyToEventId
1637
1525
  }) : void 0;
1638
1526
  const replySenderAllowed = !replyContext?.senderId || isRoomContextSenderAllowed(replyContext.senderId);
1639
- const roomName = (isRoom ? await getRoomInfo(roomId) : void 0)?.name;
1527
+ const roomName = (isRoom ? await getRoomInfo(roomId, { currentName: true }) : void 0)?.name;
1640
1528
  const envelopeFrom = isDirectMessage ? senderName : roomName ?? roomId;
1641
1529
  const textWithId = `${bodyText}\n[matrix event id: ${messageId} room: ${roomId}]`;
1642
- const storePath = resolveStorePathImpl(cfg.session?.store, { agentId: _route.agentId });
1643
- const buildEnvelope = await createChannelInboundEnvelopeBuilderImpl({
1530
+ const storePath = resolveStorePath(cfg.session?.store, { agentId: _route.agentId });
1531
+ const buildEnvelope = await createChannelInboundEnvelopeBuilderAsync({
1644
1532
  cfg,
1645
1533
  route: _route
1646
1534
  });
@@ -1681,7 +1569,6 @@ async function resolveMatrixInboundContext(config) {
1681
1569
  channelIngress,
1682
1570
  channel: "matrix",
1683
1571
  contextVisibility: contextVisibilityMode,
1684
- finalize: finalizeInboundContext,
1685
1572
  supplemental: {
1686
1573
  quote: replyContext ? {
1687
1574
  id: threadTarget ? void 0 : replyToEventId ?? void 0,
@@ -1754,7 +1641,7 @@ async function resolveMatrixInboundContext(config) {
1754
1641
  }
1755
1642
  });
1756
1643
  if (quoteHidden) logVerboseMessage(`matrix: drop reply context (mode=${contextVisibilityMode})`);
1757
- logVerboseMessage(`matrix inbound: room=${roomId} from=${senderId} preview="${truncateUtf16Safe(bodyText, 200).replace(/\n/g, "\\n")}"`);
1644
+ logVerboseMessage(`matrix inbound: room=${roomId} from=${senderId} chars=${bodyText.length}`);
1758
1645
  const replyTarget = ctxPayload.To;
1759
1646
  if (!replyTarget) {
1760
1647
  runtime.error?.("matrix: missing reply target");
@@ -1788,8 +1675,7 @@ async function resolveMatrixInboundContext(config) {
1788
1675
  sharedDmContextNotice
1789
1676
  };
1790
1677
  }
1791
- //#endregion
1792
- //#region extensions/matrix/src/matrix/monitor/handler-draft-controller.ts
1678
+ // extensions/matrix/src/matrix/monitor/handler-draft-controller.ts
1793
1679
  async function createMatrixDraftController(params) {
1794
1680
  const { streaming, previewToolProgressEnabled, replyToMode, messageId, threadTarget, accountConfig, cfg, accountId, roomId, client, logVerboseMessage } = params;
1795
1681
  const draftStreamingEnabled = streaming !== "off";
@@ -1811,7 +1697,6 @@ async function createMatrixDraftController(params) {
1811
1697
  let currentDraftMessageGeneration = 0;
1812
1698
  let currentDraftBlockOffset = 0;
1813
1699
  let latestDraftFullText = "";
1814
- const pendingDraftBoundaries = [];
1815
1700
  let currentDraftReplyToId = draftReplyToId;
1816
1701
  const progressConfigEntry = accountConfig ?? cfg.channels?.matrix;
1817
1702
  const progressSeed = `${accountId}:${roomId}`;
@@ -1863,26 +1748,17 @@ async function createMatrixDraftController(params) {
1863
1748
  };
1864
1749
  };
1865
1750
  const updateDraftFromLatestFullText = () => {
1866
- const nextDraftBoundaryOffset = pendingDraftBoundaries.find((boundary) => boundary.messageGeneration === currentDraftMessageGeneration)?.endOffset;
1867
- const blockText = latestDraftFullText.slice(currentDraftBlockOffset, nextDraftBoundaryOffset);
1751
+ const blockText = latestDraftFullText.slice(currentDraftBlockOffset);
1868
1752
  if (blockText) draftStream?.update(blockText);
1869
1753
  };
1870
- const queueDraftBlockBoundary = (payload, context) => {
1871
- const payloadTextLength = payload.text?.length ?? 0;
1872
- const messageGeneration = context?.assistantMessageIndex ?? currentDraftMessageGeneration;
1873
- const nextDraftBoundaryOffset = (pendingDraftBoundaries.findLast((entry) => entry.messageGeneration === messageGeneration)?.endOffset ?? 0) + payloadTextLength;
1874
- pendingDraftBoundaries.push({
1875
- messageGeneration,
1876
- endOffset: nextDraftBoundaryOffset
1877
- });
1878
- };
1879
- const advanceDraftBlockBoundary = (options) => {
1880
- const completedBoundary = pendingDraftBoundaries.shift();
1881
- if (completedBoundary) {
1882
- if (completedBoundary.messageGeneration === currentDraftMessageGeneration) currentDraftBlockOffset = completedBoundary.endOffset;
1883
- return;
1884
- }
1885
- if (options?.fallbackToLatestEnd) currentDraftBlockOffset = latestDraftFullText.length;
1754
+ const captureDraftBlockBoundary = (text, info) => ({
1755
+ messageGeneration: info.assistantMessageIndex ?? currentDraftMessageGeneration,
1756
+ previewMessageGeneration: currentDraftMessageGeneration,
1757
+ previewEndOffset: latestDraftFullText.length,
1758
+ endOffset: info.blockSourceRange?.[1] ?? currentDraftBlockOffset + (text?.length ?? 0)
1759
+ });
1760
+ const advanceDraftBlockBoundary = (boundary) => {
1761
+ if (boundary.messageGeneration === currentDraftMessageGeneration) currentDraftBlockOffset = Math.max(currentDraftBlockOffset, boundary.endOffset);
1886
1762
  };
1887
1763
  const resetDraftBlockOffsets = () => {
1888
1764
  currentDraftMessageGeneration += 1;
@@ -1896,7 +1772,6 @@ async function createMatrixDraftController(params) {
1896
1772
  currentDraftMessageGeneration = 0;
1897
1773
  currentDraftBlockOffset = 0;
1898
1774
  latestDraftFullText = "";
1899
- pendingDraftBoundaries.length = 0;
1900
1775
  currentDraftReplyToId = draftReplyToId;
1901
1776
  progressDraft.beginNewTurn({ force: true });
1902
1777
  };
@@ -1905,7 +1780,7 @@ async function createMatrixDraftController(params) {
1905
1780
  previewLifecycle,
1906
1781
  cancelProgressDraft: () => progressDraft.cancel(),
1907
1782
  buildPreviewToolProgressReplyOptions,
1908
- queueDraftBlockBoundary,
1783
+ captureDraftBlockBoundary,
1909
1784
  advanceDraftBlockBoundary,
1910
1785
  resetDraftBlockOffsets,
1911
1786
  beginAssistantMessage: () => progressDraft.beginAssistantMessage(),
@@ -1928,8 +1803,7 @@ async function createMatrixDraftController(params) {
1928
1803
  }
1929
1804
  };
1930
1805
  }
1931
- //#endregion
1932
- //#region extensions/matrix/src/matrix/monitor/room-history.ts
1806
+ // extensions/matrix/src/matrix/monitor/room-history.ts
1933
1807
  /** Maximum entries retained per room (hard cap to bound memory). */
1934
1808
  const DEFAULT_MAX_QUEUE_SIZE = 200;
1935
1809
  /** Maximum number of rooms to retain queues for (FIFO eviction beyond this). */
@@ -2021,7 +1895,7 @@ function createRoomHistoryTracker(maxQueueSize = DEFAULT_MAX_QUEUE_SIZE, maxRoom
2021
1895
  }
2022
1896
  function rememberWatermark(key, snapshotIdx) {
2023
1897
  const nextSnapshotIdx = Math.max(agentWatermarks.get(key) ?? 0, snapshotIdx);
2024
- if (agentWatermarks.has(key)) agentWatermarks.delete(key);
1898
+ agentWatermarks.delete(key);
2025
1899
  setBoundedMap(agentWatermarks, key, nextSnapshotIdx, maxWatermarkEntries);
2026
1900
  }
2027
1901
  function markConsumedAfterReservedGap(queue, key, firstReservedRel, snapshotIdx) {
@@ -2034,19 +1908,10 @@ function createRoomHistoryTracker(maxQueueSize = DEFAULT_MAX_QUEUE_SIZE, maxRoom
2034
1908
  }
2035
1909
  }
2036
1910
  function rememberPreparedTrigger(queue, retryKey, prepared) {
2037
- if (queue.preparedTriggers.has(retryKey)) queue.preparedTriggers.delete(retryKey);
1911
+ queue.preparedTriggers.delete(retryKey);
2038
1912
  setBoundedMap(queue.preparedTriggers, retryKey, prepared, maxPreparedTriggerEntries);
2039
1913
  return prepared;
2040
1914
  }
2041
- function computePendingHistory(queue, agentId, roomId, limit, endAbsExclusive = queue.baseIndex + queue.entries.length, startAbsOverride, threadRootId) {
2042
- if (limit <= 0 || queue.entries.length === 0) return [];
2043
- const key = wmKey(agentId, roomId, threadRootId);
2044
- const wm = startAbsOverride ?? agentWatermarks.get(key) ?? 0;
2045
- const startRel = Math.max(wm, queue.baseIndex) - queue.baseIndex;
2046
- const endRel = Math.max(startRel, Math.min(endAbsExclusive - queue.baseIndex, queue.entries.length));
2047
- const available = queue.entries.slice(startRel, endRel).filter((entry) => !entry.discarded && !entry.reserved && !entry.consumedBy?.has(key));
2048
- return available.length > limit ? available.slice(-limit) : available;
2049
- }
2050
1915
  function prepareTrigger(agentId, roomId, limit, entry, threadRootId, reservedSlot) {
2051
1916
  let slot = reservedSlot;
2052
1917
  const queue = getScopedQueue(roomId, threadRootId);
@@ -2063,8 +1928,20 @@ function createRoomHistoryTracker(maxQueueSize = DEFAULT_MAX_QUEUE_SIZE, maxRoom
2063
1928
  }
2064
1929
  }
2065
1930
  if (slot) queue.entries[slot.slotIdx - queue.baseIndex] = entry;
1931
+ const requestedEndAbsExclusive = slot?.slotIdx;
1932
+ const startAbsOverride = slot?.watermarkIdx;
1933
+ const endAbsExclusive = requestedEndAbsExclusive ?? queue.baseIndex + queue.entries.length;
1934
+ let history = [];
1935
+ if (!(limit <= 0 || queue.entries.length === 0)) {
1936
+ const key = wmKey(agentId, roomId, threadRootId);
1937
+ const wm = startAbsOverride ?? agentWatermarks.get(key) ?? 0;
1938
+ const startRel = Math.max(wm, queue.baseIndex) - queue.baseIndex;
1939
+ const endRel = Math.max(startRel, Math.min(endAbsExclusive - queue.baseIndex, queue.entries.length));
1940
+ const available = queue.entries.slice(startRel, endRel).filter((queued) => !queued.discarded && !queued.reserved && !queued.consumedBy?.has(key));
1941
+ history = available.length > limit ? available.slice(-limit) : available;
1942
+ }
2066
1943
  const prepared = {
2067
- history: computePendingHistory(queue, agentId, roomId, limit, slot?.slotIdx, slot?.watermarkIdx, threadRootId),
1944
+ history,
2068
1945
  ...slot ? { snapshotIdx: slot.slotIdx + 1 } : appendToQueue(queue, entry)
2069
1946
  };
2070
1947
  if (retryKey) return rememberPreparedTrigger(queue, retryKey, prepared);
@@ -2118,10 +1995,9 @@ function createRoomHistoryTracker(maxQueueSize = DEFAULT_MAX_QUEUE_SIZE, maxRoom
2118
1995
  }
2119
1996
  };
2120
1997
  }
2121
- //#endregion
2122
- //#region extensions/matrix/src/matrix/monitor/handler-ingress-access.ts
1998
+ // extensions/matrix/src/matrix/monitor/handler-ingress-access.ts
2123
1999
  async function resolveMatrixIngressAccess(config) {
2124
- const { handler, params: paramsLocal, roomId, event, eventTs, senderId, isReactionEvent, readStoreAllowFrom, shouldSendPairingReply, resolveLiveAccountAllowlists, roomHistoryTracker, commitInboundEventIfClaimed } = config;
2000
+ const { handler, params: paramsLocal, roomId, event, eventTs, senderId, isReactionEvent, readStoreAllowFrom, shouldSendPairingReply, resolveLiveAccountAllowlists, roomHistoryTracker } = config;
2125
2001
  const { core, cfg, accountId, accountConfig, client, logVerboseMessage, groupPolicy, dmEnabled, dmPolicy, dmThreadReplies, threadReplies, roomsConfig, accountAllowBots, configuredBotUserIds, needsRoomAliasesForConfig, getRoomInfo, getMemberDisplayName } = handler;
2126
2002
  const content = paramsLocal.content;
2127
2003
  const isDirectMessage = paramsLocal.isDirectMessage;
@@ -2147,12 +2023,8 @@ async function resolveMatrixIngressAccess(config) {
2147
2023
  const markReservedHistorySlotConsumed = () => {
2148
2024
  reservedHistorySlotConsumed = true;
2149
2025
  };
2150
- const commitInboundEventIfClaimedAndDiscardReserved = async () => {
2151
- discardReservedHistorySlot();
2152
- await commitInboundEventIfClaimed();
2153
- };
2154
2026
  if (isRoom && groupPolicy === "disabled") {
2155
- await commitInboundEventIfClaimedAndDiscardReserved();
2027
+ discardReservedHistorySlot();
2156
2028
  return;
2157
2029
  }
2158
2030
  const roomInfoForConfig = isRoom && needsRoomAliasesForConfig ? await getRoomInfo(roomId, { includeAliases: true }) : void 0;
@@ -2168,7 +2040,7 @@ async function resolveMatrixIngressAccess(config) {
2168
2040
  const roomMatchMeta = roomConfigInfo ? `matchKey=${roomConfigInfo.matchKey ?? "none"} matchSource=${roomConfigInfo.matchSource ?? "none"}` : "matchKey=none matchSource=none";
2169
2041
  if (isConfiguredBotSender && allowBotsMode === "off") {
2170
2042
  logVerboseMessage(`matrix: drop configured bot sender=${senderId} (allowBots=false${isDirectMessage ? "" : `, ${roomMatchMeta}`})`);
2171
- await commitInboundEventIfClaimedAndDiscardReserved();
2043
+ discardReservedHistorySlot();
2172
2044
  return;
2173
2045
  }
2174
2046
  const botLoopProtection = isConfiguredBotSender && senderId !== selfUserId ? {
@@ -2183,18 +2055,18 @@ async function resolveMatrixIngressAccess(config) {
2183
2055
  } : void 0;
2184
2056
  if (isRoom && roomConfig && !roomConfigInfo?.allowed) {
2185
2057
  logVerboseMessage(`matrix: room disabled room=${roomId} (${roomMatchMeta})`);
2186
- await commitInboundEventIfClaimedAndDiscardReserved();
2058
+ discardReservedHistorySlot();
2187
2059
  return;
2188
2060
  }
2189
2061
  if (isRoom && groupPolicy === "allowlist") {
2190
2062
  if (!roomConfigInfo?.allowlistConfigured) {
2191
2063
  logVerboseMessage(`matrix: drop room message (no allowlist, ${roomMatchMeta})`);
2192
- await commitInboundEventIfClaimedAndDiscardReserved();
2064
+ discardReservedHistorySlot();
2193
2065
  return;
2194
2066
  }
2195
2067
  if (!roomConfig) {
2196
2068
  logVerboseMessage(`matrix: drop room message (not in allowlist, ${roomMatchMeta})`);
2197
- await commitInboundEventIfClaimedAndDiscardReserved();
2069
+ discardReservedHistorySlot();
2198
2070
  return;
2199
2071
  }
2200
2072
  }
@@ -2223,7 +2095,7 @@ async function resolveMatrixIngressAccess(config) {
2223
2095
  const ingressDecision = messageIngress.ingress;
2224
2096
  if (isDirectMessage) {
2225
2097
  if (!dmEnabled || dmPolicy === "disabled") {
2226
- await commitInboundEventIfClaimedAndDiscardReserved();
2098
+ discardReservedHistorySlot();
2227
2099
  return;
2228
2100
  }
2229
2101
  const senderReason = messageIngress.senderAccess.reasonCode;
@@ -2238,7 +2110,7 @@ async function resolveMatrixIngressAccess(config) {
2238
2110
  });
2239
2111
  if (!code) {
2240
2112
  logVerboseMessage(`matrix pairing request ignored sender=${senderId} (pending limit reached)`);
2241
- await commitInboundEventIfClaimedAndDiscardReserved();
2113
+ discardReservedHistorySlot();
2242
2114
  return;
2243
2115
  }
2244
2116
  if (shouldSendPairingReply(senderId, created)) {
@@ -2255,27 +2127,26 @@ async function resolveMatrixIngressAccess(config) {
2255
2127
  cfg,
2256
2128
  accountId
2257
2129
  });
2258
- await commitInboundEventIfClaimed();
2259
2130
  } catch (err) {
2260
2131
  logVerboseMessage(`matrix pairing reply failed for ${senderId}: ${String(err)}`);
2261
2132
  discardReservedHistorySlot();
2262
- return;
2133
+ throw err;
2263
2134
  }
2264
2135
  } else {
2265
2136
  logVerboseMessage(`matrix pairing reminder suppressed sender=${senderId} (cooldown)`);
2266
- await commitInboundEventIfClaimedAndDiscardReserved();
2137
+ discardReservedHistorySlot();
2267
2138
  }
2268
2139
  }
2269
2140
  if (isReactionEvent || dmPolicy !== "pairing") {
2270
2141
  logVerboseMessage(`matrix: blocked ${isReactionEvent ? "reaction" : "dm"} sender ${senderId} (dmPolicy=${dmPolicy}, reason=${senderReason})`);
2271
- await commitInboundEventIfClaimedAndDiscardReserved();
2142
+ discardReservedHistorySlot();
2272
2143
  }
2273
2144
  return;
2274
2145
  }
2275
2146
  }
2276
2147
  if (isRoom && ingressDecision.decision !== "allow") {
2277
2148
  logVerboseMessage(`matrix: blocked sender ${senderId} (ingress=${ingressDecision.reasonCode}, ${roomMatchMeta})`);
2278
- await commitInboundEventIfClaimedAndDiscardReserved();
2149
+ discardReservedHistorySlot();
2279
2150
  return;
2280
2151
  }
2281
2152
  if (isRoom) logVerboseMessage(`matrix: allow room ${roomId} (${roomMatchMeta})`);
@@ -2295,7 +2166,7 @@ async function resolveMatrixIngressAccess(config) {
2295
2166
  isDirectMessage,
2296
2167
  logVerboseMessage
2297
2168
  });
2298
- await commitInboundEventIfClaimedAndDiscardReserved();
2169
+ discardReservedHistorySlot();
2299
2170
  return;
2300
2171
  }
2301
2172
  return {
@@ -2313,7 +2184,6 @@ async function resolveMatrixIngressAccess(config) {
2313
2184
  historyThreadId,
2314
2185
  discardReservedHistorySlot,
2315
2186
  markReservedHistorySlotConsumed,
2316
- commitInboundEventIfClaimedAndDiscardReserved,
2317
2187
  roomConfig,
2318
2188
  allowBotsMode,
2319
2189
  isConfiguredBotSender,
@@ -2326,8 +2196,7 @@ async function resolveMatrixIngressAccess(config) {
2326
2196
  effectiveRoomUsers
2327
2197
  };
2328
2198
  }
2329
- //#endregion
2330
- //#region src/channels/mention-gating.ts
2199
+ // src/channels/mention-gating.ts
2331
2200
  function resolveBotThreadMentionPolicy(params) {
2332
2201
  if (!params.isBotOwnedThread || params.requireMentionInBotThreads === void 0) return {
2333
2202
  requireMention: params.requireMention,
@@ -2338,8 +2207,7 @@ function resolveBotThreadMentionPolicy(params) {
2338
2207
  implicitMentionKinds: params.requireMentionInBotThreads ? params.implicitMentionKinds?.filter((kind) => kind === "native") : params.implicitMentionKinds
2339
2208
  };
2340
2209
  }
2341
- //#endregion
2342
- //#region extensions/matrix/src/matrix/monitor/media.ts
2210
+ // extensions/matrix/src/matrix/monitor/media.ts
2343
2211
  const MATRIX_MEDIA_DOWNLOAD_IDLE_TIMEOUT_MS = 3e4;
2344
2212
  async function downloadMatrixMedia(params) {
2345
2213
  if (typeof params.sizeBytes === "number" && params.sizeBytes > params.maxBytes) throw new MatrixMediaSizeLimitError();
@@ -2365,8 +2233,7 @@ async function downloadMatrixMedia(params) {
2365
2233
  placeholder: "[matrix media]"
2366
2234
  };
2367
2235
  }
2368
- //#endregion
2369
- //#region extensions/matrix/src/matrix/monitor/mentions.ts
2236
+ // extensions/matrix/src/matrix/monitor/mentions.ts
2370
2237
  const MATRIX_HTML_ENTITY_RE = /&(?:#x?[0-9a-f]+|amp|apos|gt|lt|nbsp|quot);/gi;
2371
2238
  function decodeVisibleHtmlEntities(value) {
2372
2239
  return value.replace(MATRIX_HTML_ENTITY_RE, (entity) => {
@@ -2389,7 +2256,13 @@ function hasVisibleNativeMatrixUserMention(text, userId) {
2389
2256
  if (!text || !localpart) return false;
2390
2257
  return new RegExp(String.raw`(?:^|\p{White_Space})(?:${escapeRegExp(userId)}(?=$|\p{White_Space}|:\p{White_Space}|[,!?;](?=$|\p{White_Space}))|${escapeRegExp(`@${localpart}`)}(?=$|\p{White_Space}|:\p{White_Space}))`, "u").test(text);
2391
2258
  }
2392
- function resolveMatrixMentionPrefixCandidates(params) {
2259
+ function stripMatchedMatrixMentionPrefix(text, source, flags) {
2260
+ const match = text.match(new RegExp(`^\\s*${source}(?:\\s*[:,])?(?:\\s+|$)`, flags));
2261
+ return match ? text.slice(match[0].length).trimStart() : null;
2262
+ }
2263
+ function stripMatrixMentionPrefix(params) {
2264
+ const text = params.text;
2265
+ if (!text) return text;
2393
2266
  const candidates = [];
2394
2267
  const seen = /* @__PURE__ */ new Set();
2395
2268
  const localpart = params.userId ? resolveMatrixUserLocalpart(params.userId) : null;
@@ -2407,16 +2280,7 @@ function resolveMatrixMentionPrefixCandidates(params) {
2407
2280
  seen.add(normalized);
2408
2281
  candidates.push(trimmed);
2409
2282
  }
2410
- return candidates;
2411
- }
2412
- function stripMatchedMatrixMentionPrefix(text, source, flags) {
2413
- const match = text.match(new RegExp(`^\\s*${source}(?:\\s*[:,])?(?:\\s+|$)`, flags));
2414
- return match ? text.slice(match[0].length).trimStart() : null;
2415
- }
2416
- function stripMatrixMentionPrefix(params) {
2417
- const text = params.text;
2418
- if (!text) return text;
2419
- for (const candidate of resolveMatrixMentionPrefixCandidates(params)) {
2283
+ for (const candidate of candidates) {
2420
2284
  const stripped = stripMatchedMatrixMentionPrefix(text, escapeRegExp(candidate), "i");
2421
2285
  if (stripped !== null) return stripped;
2422
2286
  }
@@ -2426,63 +2290,52 @@ function stripMatrixMentionPrefix(params) {
2426
2290
  }
2427
2291
  return text;
2428
2292
  }
2429
- function isVisibleMentionLabel(params) {
2430
- const cleaned = extractVisibleMentionText(params.text);
2431
- if (!cleaned) return false;
2432
- if (params.mentionRegexes.some((pattern) => pattern.test(cleaned))) return true;
2433
- const localpart = resolveMatrixUserLocalpart(params.userId);
2434
- return [
2435
- extractVisibleMentionText(params.userId),
2436
- localpart ? extractVisibleMentionText(localpart) : null,
2437
- localpart ? extractVisibleMentionText(`@${localpart}`) : null,
2438
- params.displayName ? extractVisibleMentionText(params.displayName) : null,
2439
- params.displayName ? extractVisibleMentionText(`@${params.displayName}`) : null,
2440
- params.displayName ? extractVisibleMentionText(`@[${params.displayName}]`) : null
2441
- ].filter((value) => Boolean(value)).includes(cleaned);
2442
- }
2443
2293
  function hasVisibleRoomMention(value) {
2444
2294
  const cleaned = extractVisibleMentionText(value);
2445
2295
  return /(^|[^a-z0-9_])@room\b/i.test(cleaned);
2446
2296
  }
2447
- /**
2448
- * Check if formatted_body contains a matrix.to link whose visible label still
2449
- * looks like a real mention for the given user. Do not trust href alone, since
2450
- * senders can hide arbitrary matrix.to links behind unrelated link text.
2451
- * Many Matrix clients (including Element) use HTML links in formatted_body instead of
2452
- * or in addition to the m.mentions field.
2453
- */
2454
- function checkFormattedBodyMention(params) {
2455
- if (!params.formattedBody || !params.userId) return false;
2456
- for (const match of params.formattedBody.matchAll(/<a\b[^>]*href=(["'])(https:\/\/matrix\.to\/#[^"']+)\1[^>]*>(.*?)<\/a>/gis)) {
2457
- const href = match[2];
2458
- const visibleLabel = match[3] ?? "";
2459
- if (!href) continue;
2460
- try {
2461
- const parsed = new URL(href);
2462
- if (decodeURIComponent(parsed.hash.replace(/^#\/?/, "").trim()) !== params.userId.trim()) continue;
2463
- if (isVisibleMentionLabel({
2464
- text: visibleLabel,
2465
- userId: params.userId,
2466
- mentionRegexes: params.mentionRegexes,
2467
- displayName: params.displayName
2468
- })) return true;
2469
- } catch {
2470
- continue;
2471
- }
2472
- }
2473
- return false;
2474
- }
2475
2297
  function resolveMentions(params) {
2476
2298
  const mentions = params.content["m.mentions"];
2477
2299
  const mentionedUsers = Array.isArray(mentions?.user_ids) ? new Set(mentions.user_ids) : /* @__PURE__ */ new Set();
2478
2300
  const textMentioned = getMatrixRuntime().channel.mentions.matchesMentionPatterns(params.text ?? "", params.mentionRegexes);
2479
2301
  const visibleRoomMention = hasVisibleRoomMention(params.text) || hasVisibleRoomMention(params.content.formatted_body);
2480
- const mentionedInFormattedBody = params.userId ? checkFormattedBodyMention({
2481
- formattedBody: params.content.formatted_body,
2482
- userId: params.userId,
2483
- displayName: params.displayName,
2484
- mentionRegexes: params.mentionRegexes
2485
- }) : false;
2302
+ /**
2303
+ * Check if formatted_body contains a matrix.to link whose visible label still
2304
+ * looks like a real mention for the given user. Do not trust href alone, since
2305
+ * senders can hide arbitrary matrix.to links behind unrelated link text.
2306
+ * Many Matrix clients (including Element) use HTML links in formatted_body instead of
2307
+ * or in addition to the m.mentions field.
2308
+ */
2309
+ function checkFormattedBodyMention(userId) {
2310
+ const formattedBody = params.content.formatted_body;
2311
+ const { displayName, mentionRegexes } = params;
2312
+ if (!formattedBody || !userId) return false;
2313
+ for (const match of formattedBody.matchAll(/<a\b[^>]*href=(["'])(https:\/\/matrix\.to\/#[^"']+)\1[^>]*>(.*?)<\/a>/gis)) {
2314
+ const href = match[2];
2315
+ const visibleLabel = match[3] ?? "";
2316
+ if (!href) continue;
2317
+ try {
2318
+ const parsed = new URL(href);
2319
+ if (decodeURIComponent(parsed.hash.replace(/^#\/?/, "").trim()) !== userId.trim()) continue;
2320
+ const cleaned = extractVisibleMentionText(visibleLabel);
2321
+ if (!cleaned) continue;
2322
+ if (mentionRegexes.some((pattern) => pattern.test(cleaned))) return true;
2323
+ const localpart = resolveMatrixUserLocalpart(userId);
2324
+ if ([
2325
+ extractVisibleMentionText(userId),
2326
+ localpart ? extractVisibleMentionText(localpart) : null,
2327
+ localpart ? extractVisibleMentionText(`@${localpart}`) : null,
2328
+ displayName ? extractVisibleMentionText(displayName) : null,
2329
+ displayName ? extractVisibleMentionText(`@${displayName}`) : null,
2330
+ displayName ? extractVisibleMentionText(`@[${displayName}]`) : null
2331
+ ].filter((value) => Boolean(value)).includes(cleaned)) return true;
2332
+ } catch {
2333
+ continue;
2334
+ }
2335
+ }
2336
+ return false;
2337
+ }
2338
+ const mentionedInFormattedBody = params.userId ? checkFormattedBodyMention(params.userId) : false;
2486
2339
  const metadataBackedUserMention = Boolean(params.userId && mentionedUsers.has(params.userId) && (mentionedInFormattedBody || textMentioned || hasVisibleNativeMatrixUserMention(params.text, params.userId)));
2487
2340
  const metadataBackedRoomMention = Boolean(mentions?.room) && visibleRoomMention;
2488
2341
  const explicitMention = mentionedInFormattedBody || metadataBackedUserMention || metadataBackedRoomMention;
@@ -2491,12 +2344,11 @@ function resolveMentions(params) {
2491
2344
  hasExplicitMention: explicitMention
2492
2345
  };
2493
2346
  }
2494
- //#endregion
2495
- //#region extensions/matrix/src/matrix/monitor/handler-ingress-content.ts
2347
+ // extensions/matrix/src/matrix/monitor/handler-ingress-content.ts
2496
2348
  async function resolveMatrixIngressContent(config) {
2497
- const { handler, params: paramsLocal, access, roomId, event, eventType, isPollEvent, eventTs, senderId, roomHistoryTracker, resolveThreadContext, commitInboundEventIfClaimed } = config;
2349
+ const { handler, params: paramsLocal, access, roomId, event, eventType, isPollEvent, eventTs, senderId, roomHistoryTracker, resolveThreadContext } = config;
2498
2350
  const { client, core, accountId, accountConfig, logger, logVerboseMessage, historyLimit, mediaMaxBytes, dmSessionScope, getMemberDisplayName } = handler;
2499
- const { cfg, content: accessContent, messageId, audioPreflightMode, isDirectMessage, isRoom, locationPayload, reservedHistorySlot, threadRootId, thread, historyThreadId, discardReservedHistorySlot, markReservedHistorySlotConsumed, commitInboundEventIfClaimedAndDiscardReserved, roomConfig, allowBotsMode, isConfiguredBotSender, selfUserId, roomMatchMeta, getSenderName, accessState } = access;
2351
+ const { cfg, content: accessContent, messageId, audioPreflightMode, isDirectMessage, isRoom, locationPayload, reservedHistorySlot, threadRootId, thread, historyThreadId, discardReservedHistorySlot, markReservedHistorySlotConsumed, roomConfig, allowBotsMode, isConfiguredBotSender, selfUserId, roomMatchMeta, getSenderName, accessState } = access;
2500
2352
  const { resolveMessageIngress } = accessState;
2501
2353
  let content = accessContent;
2502
2354
  let pollSnapshotPromise = null;
@@ -2522,7 +2374,7 @@ async function resolveMatrixIngressContent(config) {
2522
2374
  });
2523
2375
  const pendingHistoryPollText = !pendingHistoryText && isPollEvent && historyLimit > 0 ? (await getPollSnapshot())?.text : "";
2524
2376
  if (!mentionPrecheckText && !mediaUrl && !isPollEvent) {
2525
- await commitInboundEventIfClaimedAndDiscardReserved();
2377
+ discardReservedHistorySlot();
2526
2378
  return;
2527
2379
  }
2528
2380
  let preflightMedia = null;
@@ -2586,16 +2438,23 @@ async function resolveMatrixIngressContent(config) {
2586
2438
  }
2587
2439
  if (shouldRunMatrixAudioPreflight) {
2588
2440
  preflightMedia = await downloadMedia(preflightAudioMediaUrl);
2589
- if (preflightMedia) preflightAudioTranscript = await resolveMatrixPreflightAudioTranscript({
2590
- mediaPath: preflightMedia.path,
2591
- mediaContentType: preflightMedia.contentType,
2592
- cfg,
2593
- accountId,
2594
- chatType: isDirectMessage ? "direct" : "channel",
2595
- originatingTo: `room:${roomId}`,
2596
- messageThreadId: thread.threadId,
2597
- sessionKey: _route.sessionKey
2598
- });
2441
+ if (preflightMedia) preflightAudioTranscript = await matrixPreflightAudio.resolve({ request: {
2442
+ ctx: {
2443
+ media: [{
2444
+ path: preflightMedia.path,
2445
+ contentType: preflightMedia.contentType
2446
+ }],
2447
+ Provider: "matrix",
2448
+ Surface: "matrix",
2449
+ OriginatingChannel: "matrix",
2450
+ OriginatingTo: `room:${roomId}`,
2451
+ AccountId: accountId,
2452
+ MessageThreadId: thread.threadId,
2453
+ ChatType: isDirectMessage ? "direct" : "channel",
2454
+ SessionKey: _route.sessionKey
2455
+ },
2456
+ cfg
2457
+ } });
2599
2458
  }
2600
2459
  const agentMentionRegexes = core.channel.mentions.buildMentionRegexes(cfg, _route.agentId, {
2601
2460
  provider: "matrix",
@@ -2613,7 +2472,7 @@ async function resolveMatrixIngressContent(config) {
2613
2472
  });
2614
2473
  if (isConfiguredBotSender && allowBotsMode === "mentions" && !isDirectMessage && !wasMentioned) {
2615
2474
  logVerboseMessage(`matrix: drop configured bot sender=${senderId} (allowBots=mentions, missing mention, ${roomMatchMeta})`);
2616
- await commitInboundEventIfClaimedAndDiscardReserved();
2475
+ discardReservedHistorySlot();
2617
2476
  return;
2618
2477
  }
2619
2478
  const allowTextCommands = core.channel.commands.shouldHandleTextCommands({
@@ -2628,7 +2487,6 @@ async function resolveMatrixIngressContent(config) {
2628
2487
  });
2629
2488
  const hasControlCommandInMessage = core.channel.text.hasControlCommand(commandCheckText, cfg);
2630
2489
  const commandAccess = await resolveMatrixMonitorCommandAccess(accessState, {
2631
- useAccessGroups: true,
2632
2490
  allowTextCommands,
2633
2491
  hasControlCommand: hasControlCommandInMessage
2634
2492
  });
@@ -2640,7 +2498,7 @@ async function resolveMatrixIngressContent(config) {
2640
2498
  reason: "control command (unauthorized)",
2641
2499
  target: senderId
2642
2500
  });
2643
- await commitInboundEventIfClaimedAndDiscardReserved();
2501
+ discardReservedHistorySlot();
2644
2502
  return;
2645
2503
  }
2646
2504
  const configuredRequireMention = isRoom ? roomConfig?.autoReply === true ? false : roomConfig?.autoReply === false ? true : typeof roomConfig?.requireMention === "boolean" ? roomConfig?.requireMention : true : false;
@@ -2688,7 +2546,6 @@ async function resolveMatrixIngressContent(config) {
2688
2546
  roomId,
2689
2547
  reason: "no-mention"
2690
2548
  });
2691
- await commitInboundEventIfClaimed();
2692
2549
  return;
2693
2550
  }
2694
2551
  if (preflightAudioTranscript) await matrixPreflightAudio.send({
@@ -2713,40 +2570,47 @@ async function resolveMatrixIngressContent(config) {
2713
2570
  let media = preflightMedia;
2714
2571
  const finalMediaUrl = mediaContent.url;
2715
2572
  if (!media && !mediaDownloadFailed && finalMediaUrl?.startsWith("mxc://")) media = await downloadMedia(finalMediaUrl);
2716
- let bodyText = resolveMatrixInboundBodyText({
2717
- rawBody: locationPayload?.text ?? mediaContent.body,
2718
- filename: typeof content.filename === "string" ? content.filename : void 0,
2719
- mediaPlaceholder: media?.placeholder,
2573
+ const rawBody = locationPayload?.text ?? mediaContent.body;
2574
+ const filename = typeof content.filename === "string" ? content.filename : void 0;
2575
+ const mediaPlaceholder = media?.placeholder;
2576
+ let bodyText = rawBody;
2577
+ if (mediaPlaceholder) {
2578
+ bodyText = rawBody || mediaPlaceholder;
2579
+ if (filename?.trim()) {
2580
+ const attachment = resolveMatrixMessageAttachment({
2581
+ body: rawBody,
2582
+ filename,
2583
+ msgtype: content.msgtype
2584
+ });
2585
+ if (attachment && !attachment.caption) bodyText = mediaPlaceholder;
2586
+ }
2587
+ } else if (mediaDownloadFailed && Boolean(finalMediaUrl)) bodyText = formatMatrixMessageText({
2588
+ body: rawBody,
2589
+ filename,
2720
2590
  msgtype: content.msgtype,
2721
- hadMediaUrl: Boolean(finalMediaUrl),
2722
- mediaDownloadFailed,
2723
- mediaSizeLimitExceeded
2724
- });
2591
+ tooLarge: mediaSizeLimitExceeded,
2592
+ unavailable: true
2593
+ }) ?? "";
2725
2594
  if (preflightMedia && bodyText && bodyText !== preflightMedia.placeholder && isLikelyBareFilename(bodyText)) bodyText = preflightMedia.placeholder;
2726
2595
  if (preflightAudioTranscript) {
2727
2596
  const transcriptBody = formatAudioTranscriptForAgent(preflightAudioTranscript);
2728
2597
  bodyText = !bodyText || bodyText === media?.placeholder ? transcriptBody : `${bodyText}\n${transcriptBody}`;
2729
2598
  }
2730
2599
  if (!bodyText) {
2731
- await commitInboundEventIfClaimedAndDiscardReserved();
2600
+ discardReservedHistorySlot();
2732
2601
  return;
2733
2602
  }
2734
2603
  const commandBodyText = hasControlCommandInMessage ? commandCheckText : bodyText;
2735
2604
  const senderName = await getSenderName();
2736
2605
  if (_configuredBinding) {
2737
2606
  const { ensureConfiguredAcpBindingReady } = await loadAcpBindingRuntime();
2738
- if (!(await ensureConfiguredAcpBindingReady({
2607
+ const ensured = await ensureConfiguredAcpBindingReady({
2739
2608
  cfg,
2740
2609
  configuredBinding: _configuredBinding
2741
- })).ok) {
2742
- logInboundDrop({
2743
- log: logVerboseMessage,
2744
- channel: "matrix",
2745
- reason: "configured ACP binding unavailable",
2746
- target: _configuredBinding.spec.conversationId
2747
- });
2610
+ });
2611
+ if (!ensured.ok) {
2748
2612
  discardReservedHistorySlot();
2749
- return;
2613
+ throw new Error(`Matrix configured ACP binding is unavailable: ${ensured.error}`);
2750
2614
  }
2751
2615
  }
2752
2616
  if (_runtimeBindingId) {
@@ -2789,116 +2653,7 @@ async function resolveMatrixIngressContent(config) {
2789
2653
  threadContext
2790
2654
  };
2791
2655
  }
2792
- //#endregion
2793
- //#region extensions/matrix/src/matrix/monitor/location.ts
2794
- function decodeGeoUriParamValue(value) {
2795
- try {
2796
- return decodeURIComponent(value);
2797
- } catch {
2798
- return value;
2799
- }
2800
- }
2801
- function parseGeoUri(value) {
2802
- if (!value.toLowerCase().startsWith("geo:")) return null;
2803
- const [coordsPart, ...paramParts] = value.slice(4).split(";");
2804
- if (!coordsPart) return null;
2805
- const coords = coordsPart.split(",");
2806
- if (coords.length < 2) return null;
2807
- const latitude = parseStrictFiniteNumber(coords[0] ?? "");
2808
- const longitude = parseStrictFiniteNumber(coords[1] ?? "");
2809
- if (latitude === void 0 || longitude === void 0) return null;
2810
- const params = /* @__PURE__ */ new Map();
2811
- for (const part of paramParts) {
2812
- const segment = part.trim();
2813
- if (!segment) continue;
2814
- const eqIndex = segment.indexOf("=");
2815
- const rawKey = eqIndex === -1 ? segment : segment.slice(0, eqIndex);
2816
- const rawValue = eqIndex === -1 ? "" : segment.slice(eqIndex + 1);
2817
- const key = normalizeLowercaseStringOrEmpty(rawKey);
2818
- if (!key) continue;
2819
- const valuePart = rawValue.trim();
2820
- params.set(key, valuePart ? decodeGeoUriParamValue(valuePart) : "");
2821
- }
2822
- const accuracyRaw = params.get("u");
2823
- return {
2824
- latitude,
2825
- longitude,
2826
- accuracy: accuracyRaw ? parseStrictFiniteNumber(accuracyRaw) : void 0
2827
- };
2828
- }
2829
- function resolveMatrixLocation(params) {
2830
- const { eventType, content } = params;
2831
- if (!(eventType === EventType.Location || eventType === EventType.RoomMessage && content.msgtype === EventType.Location)) return null;
2832
- const geoUri = normalizeOptionalString(content.geo_uri) ?? "";
2833
- if (!geoUri) return null;
2834
- const parsed = parseGeoUri(geoUri);
2835
- if (!parsed) return null;
2836
- const caption = normalizeOptionalString(content.body) ?? "";
2837
- const location = {
2838
- latitude: parsed.latitude,
2839
- longitude: parsed.longitude,
2840
- accuracy: parsed.accuracy,
2841
- caption: caption || void 0,
2842
- source: "pin",
2843
- isLive: false
2844
- };
2845
- return {
2846
- text: formatLocationText(location),
2847
- context: toLocationContext(location)
2848
- };
2849
- }
2850
- //#endregion
2851
- //#region extensions/matrix/src/matrix/monitor/handler-ingress-prefix.ts
2852
- async function readMatrixIngressPrefix(config) {
2853
- const { client, senderId, dropPreStartupMessages, eventTs, eventAge, startupMs, event, eventType, eventId, inboundDeduper, roomId, logVerboseMessage, directTracker, claimInboundReplay } = config;
2854
- const selfUserId = await client.getUserId();
2855
- if (senderId === selfUserId) return;
2856
- if (dropPreStartupMessages) {
2857
- if (typeof eventTs === "number" && eventTs < startupMs) return;
2858
- if (typeof eventTs !== "number" && typeof eventAge === "number" && eventAge > 0) return;
2859
- }
2860
- const content = event.content;
2861
- if (eventType === EventType.RoomMessage && isMatrixVerificationRoomMessage({
2862
- msgtype: content.msgtype,
2863
- body: content.body
2864
- })) {
2865
- logVerboseMessage(`matrix: skip verification/system room message room=${roomId}`);
2866
- return;
2867
- }
2868
- const locationPayload = resolveMatrixLocation({
2869
- eventType,
2870
- content
2871
- });
2872
- const relates = content["m.relates_to"];
2873
- if (relates && "rel_type" in relates && relates.rel_type === RelationType.Replace) return;
2874
- if (hasBundledMatrixReplacementRelation(event)) return;
2875
- if (eventId && inboundDeduper) {
2876
- const claim = await inboundDeduper.claim({
2877
- roomId,
2878
- eventId
2879
- });
2880
- if (claim.kind === "claimed") claimInboundReplay(claim.handle);
2881
- else if (claim.kind !== "invalid") {
2882
- logVerboseMessage(`matrix: skip duplicate inbound event room=${roomId} id=${eventId}`);
2883
- return;
2884
- }
2885
- }
2886
- return {
2887
- content,
2888
- isDirectMessage: await directTracker.isDirectMessage({
2889
- roomId,
2890
- senderId,
2891
- selfUserId
2892
- }),
2893
- locationPayload,
2894
- selfUserId
2895
- };
2896
- }
2897
- //#endregion
2898
- //#region extensions/matrix/src/matrix/monitor/replies.ts
2899
- function joinMatrixVisibleContent(contents) {
2900
- return contents.filter((content) => Boolean(content)).join("\n");
2901
- }
2656
+ // extensions/matrix/src/matrix/monitor/handler-reply-dispatcher.ts
2902
2657
  function mergeMatrixReplyDeliveryResults(results) {
2903
2658
  const single = results.length === 1 ? results[0] : void 0;
2904
2659
  if (single?.visibleReplySent) return single;
@@ -2907,7 +2662,7 @@ function mergeMatrixReplyDeliveryResults(results) {
2907
2662
  visibleReplySent: false,
2908
2663
  suppression: { reason: "no_visible_result" }
2909
2664
  };
2910
- const content = joinMatrixVisibleContent(visibleResults.map((result) => result.content));
2665
+ const content = visibleResults.map((result) => result.content).filter(Boolean).join("\n");
2911
2666
  if (visibleResults.some((result) => result.receipt || result.messageIds?.length)) return createAcceptedChannelDeliveryResult({
2912
2667
  deliveryResults: visibleResults,
2913
2668
  content
@@ -2936,84 +2691,63 @@ function resolveVisibleMatrixReplyText(text) {
2936
2691
  });
2937
2692
  return visibleText.trim() ? visibleText : void 0;
2938
2693
  }
2939
- async function deliverMatrixReplies(params) {
2940
- const core = getMatrixRuntime();
2941
- const logVerbose = (message) => {
2942
- if (core.logging.shouldLogVerbose()) params.runtime.log?.(message);
2943
- };
2944
- const hasRepliedRef = params.hasRepliedRef ?? { value: false };
2945
- const accepted = createChannelDeliveryAccumulator();
2946
- try {
2947
- for (const reply of params.replies) {
2948
- const visibleText = resolveVisibleMatrixReplyText(reply.text);
2949
- const { hasMedia, hasText, mediaUrls } = resolveSendableOutboundReplyParts(reply);
2950
- if (reply.isReasoning === true || !hasMedia && reply.text && visibleText === void 0) {
2951
- logVerbose("matrix reply suppressed as reasoning-only");
2952
- continue;
2953
- }
2954
- if (!hasText && !hasMedia) {
2955
- if (reply?.audioAsVoice) {
2956
- logVerbose("matrix reply has audioAsVoice without media/text; skipping");
2957
- continue;
2958
- }
2959
- params.runtime.error?.("matrix reply missing text/media");
2960
- continue;
2961
- }
2962
- const explicitReplyToId = reply.replyToTag || reply.replyToCurrent ? reply.replyToId?.trim() : void 0;
2963
- const rawText = visibleText ?? "";
2964
- const replyToIdForReply = explicitReplyToId || (!params.threadId && params.replyToMode !== "off" && (params.replyToMode === "all" || !hasRepliedRef.value) ? (reply.replyToId ?? params.replyToId)?.trim() : void 0);
2965
- const fallbackReplyToId = params.threadId ? (reply.replyToId ?? params.replyToId)?.trim() : void 0;
2966
- const onDeliveryResult = (result) => {
2967
- accepted.add({ receipt: result.receipt }, result.content);
2968
- if (replyToIdForReply) hasRepliedRef.value = true;
2969
- };
2970
- const extraContent = resolveMatrixExtraContent(reply);
2971
- const targets = mediaUrls.length > 0 ? mediaUrls : [void 0];
2972
- for (const [index, mediaUrl] of targets.entries()) await sendMessageMatrix(params.roomId, index === 0 ? rawText : "", {
2973
- client: params.client,
2974
- cfg: params.cfg,
2694
+ function createMatrixReplyDispatcher(config) {
2695
+ const { cfg, prefixOptions, humanDelay, typingCallbacks, streaming, draftStream, draftController, client, roomId, runtime, replyToMode, threadTarget, replyToEventId, accountId, mediaLocalRoots, logVerboseMessage } = config;
2696
+ const quietDraftStreaming = streaming === "quiet" || streaming === "progress";
2697
+ let hasReplied = false;
2698
+ const deliverPayload = async (reply) => {
2699
+ const core = getMatrixRuntime();
2700
+ const logVerbose = (message) => {
2701
+ if (core.logging.shouldLogVerbose()) runtime.log?.(message);
2702
+ };
2703
+ const accepted = createChannelDeliveryAccumulator();
2704
+ const visibleText = resolveVisibleMatrixReplyText(reply.text);
2705
+ const { hasMedia, hasText, mediaUrls } = resolveSendableOutboundReplyParts(reply);
2706
+ if (reply.isReasoning === true || !hasMedia && reply.text && visibleText === void 0) {
2707
+ logVerbose("matrix reply suppressed as reasoning-only");
2708
+ return accepted.result();
2709
+ }
2710
+ if (!hasText && !hasMedia) {
2711
+ if (reply.audioAsVoice) logVerbose("matrix reply has audioAsVoice without media/text; skipping");
2712
+ else runtime.error?.("matrix reply missing text/media");
2713
+ return accepted.result();
2714
+ }
2715
+ const explicitReplyToId = reply.replyToTag || reply.replyToCurrent ? reply.replyToId?.trim() : void 0;
2716
+ const ambientReplyToId = threadTarget ?? replyToEventId;
2717
+ const replyToIdForReply = explicitReplyToId || (!threadTarget && replyToMode !== "off" && (replyToMode === "all" || !hasReplied) ? (reply.replyToId ?? ambientReplyToId)?.trim() : void 0);
2718
+ const fallbackReplyToId = threadTarget ? (reply.replyToId ?? ambientReplyToId)?.trim() : void 0;
2719
+ const onDeliveryResult = (result) => {
2720
+ accepted.add({ receipt: result.receipt }, result.content);
2721
+ if (replyToIdForReply) hasReplied = true;
2722
+ };
2723
+ const extraContent = resolveMatrixExtraContent(reply);
2724
+ const targets = mediaUrls.length > 0 ? mediaUrls : [void 0];
2725
+ try {
2726
+ for (const [index, mediaUrl] of targets.entries()) await sendMessageMatrix(roomId, index === 0 ? visibleText ?? "" : "", {
2727
+ client,
2728
+ cfg,
2975
2729
  ...mediaUrl !== void 0 ? {
2976
2730
  mediaUrl,
2977
- mediaLocalRoots: params.mediaLocalRoots,
2731
+ mediaLocalRoots,
2978
2732
  audioAsVoice: reply.audioAsVoice
2979
2733
  } : {},
2980
2734
  replyToId: replyToIdForReply,
2981
2735
  fallbackReplyToId,
2982
- threadId: params.threadId,
2983
- accountId: params.accountId,
2736
+ threadId: threadTarget,
2737
+ accountId,
2984
2738
  extraContent: index === 0 ? extraContent : void 0,
2985
2739
  onDeliveryResult
2986
2740
  });
2741
+ } catch (error) {
2742
+ throw toMatrixPartialDeliveryError(error, [accepted.result()]);
2987
2743
  }
2988
- } catch (error) {
2989
- throw toMatrixPartialDeliveryError(error, [accepted.result()]);
2990
- }
2991
- return accepted.result();
2992
- }
2993
- //#endregion
2994
- //#region extensions/matrix/src/matrix/monitor/handler-reply-dispatcher.ts
2995
- function createMatrixReplyDispatcher(config) {
2996
- const { cfg, prefixOptions, humanDelay, typingCallbacks, streaming, draftStream, draftController, client, roomId, runtime, replyToMode, threadTarget, replyToEventId, accountId, mediaLocalRoots, logVerboseMessage } = config;
2997
- const quietDraftStreaming = streaming === "quiet" || streaming === "progress";
2998
- const hasRepliedRef = { value: false };
2999
- const deliverPayload = (reply) => deliverMatrixReplies({
3000
- cfg,
3001
- replies: [reply],
3002
- roomId,
3003
- client,
3004
- runtime,
3005
- replyToMode,
3006
- hasRepliedRef,
3007
- threadId: threadTarget,
3008
- replyToId: threadTarget ?? replyToEventId ?? void 0,
3009
- accountId,
3010
- mediaLocalRoots
3011
- });
2744
+ return accepted.result();
2745
+ };
3012
2746
  const { previewLifecycle } = draftController;
3013
2747
  let nonFinalReplyDeliveryFailed = false;
3014
- const beginNextBlockDraft = () => {
2748
+ const beginNextBlockDraft = (boundary) => {
3015
2749
  draftController.beginDraftGeneration();
3016
- draftController.advanceDraftBlockBoundary({ fallbackToLatestEnd: true });
2750
+ draftController.advanceDraftBlockBoundary(boundary);
3017
2751
  draftStream?.reset();
3018
2752
  draftController.resetReplyToIdForNextBlock();
3019
2753
  draftController.updateDraftFromLatestFullText();
@@ -3048,6 +2782,7 @@ function createMatrixReplyDispatcher(config) {
3048
2782
  } : payload;
3049
2783
  const { hasMedia } = resolveSendableOutboundReplyParts(payload);
3050
2784
  const payloadText = payload.text ?? ttsSupplement?.spokenText;
2785
+ const blockBoundary = info.kind === "block" && !payload.isCompactionNotice ? draftController.captureDraftBlockBoundary(payloadText, info) : void 0;
3051
2786
  const payloadReplyMismatch = (!threadTarget && replyToMode !== "off" || payload.replyToTag || payload.replyToCurrent) && normalizeOptionalString(payload.replyToId) !== draftController.currentReplyToId();
3052
2787
  let retainedDraftDelivery;
3053
2788
  let deliveryResult;
@@ -3077,8 +2812,7 @@ function createMatrixReplyDispatcher(config) {
3077
2812
  });
3078
2813
  return createDraftDeliveryResult(draftEventId, prepareMatrixSingleText(edit.text, {
3079
2814
  cfg,
3080
- accountId,
3081
- preserveWhitespace: true
2815
+ accountId
3082
2816
  }).convertedText);
3083
2817
  },
3084
2818
  createPreviewReceipt: createDraftReceipt,
@@ -3102,12 +2836,17 @@ function createMatrixReplyDispatcher(config) {
3102
2836
  })).deliveryResult;
3103
2837
  } catch (error) {
3104
2838
  if (retainedDraftDelivery) previewLifecycle.retainPreview();
2839
+ if (blockBoundary) beginNextBlockDraft(retainedDraftDelivery ? {
2840
+ ...blockBoundary,
2841
+ messageGeneration: blockBoundary.previewMessageGeneration,
2842
+ endOffset: blockBoundary.messageGeneration === blockBoundary.previewMessageGeneration ? Math.max(blockBoundary.endOffset, blockBoundary.previewEndOffset) : blockBoundary.previewEndOffset
2843
+ } : blockBoundary);
3105
2844
  throw toMatrixPartialDeliveryError(error, retainedDraftDelivery ? [retainedDraftDelivery] : []);
3106
2845
  }
3107
2846
  if (retainedDraftDelivery && !deliveryResult?.visibleReplySent) previewLifecycle.retainPreview();
3108
2847
  const mergedDelivery = mergeMatrixReplyDeliveryResults([retainedDraftDelivery?.messageIds?.includes(draftStream?.eventId() ?? "") ? retainedDraftDelivery : void 0, deliveryResult].filter((result) => result !== void 0));
3109
- if (info.kind === "block") {
3110
- beginNextBlockDraft();
2848
+ if (blockBoundary) {
2849
+ beginNextBlockDraft(blockBoundary);
3111
2850
  await typingCallbacks.onReplyStart();
3112
2851
  }
3113
2852
  return mergedDelivery;
@@ -3115,19 +2854,17 @@ function createMatrixReplyDispatcher(config) {
3115
2854
  onReplyError: (err, info) => {
3116
2855
  if (info.kind === "final") previewLifecycle.observeFailure();
3117
2856
  else nonFinalReplyDeliveryFailed = true;
3118
- if (info.kind === "block") beginNextBlockDraft();
3119
2857
  runtime.error?.(`matrix ${info.kind} reply failed: ${String(err)}`);
3120
2858
  },
3121
2859
  nonFinalReplyDeliveryFailed: () => nonFinalReplyDeliveryFailed
3122
2860
  };
3123
2861
  }
3124
- //#endregion
3125
- //#region extensions/matrix/src/matrix/monitor/handler-state.ts
2862
+ // extensions/matrix/src/matrix/monitor/handler-state.ts
3126
2863
  const ALLOW_FROM_STORE_CACHE_TTL_MS = 3e4;
3127
2864
  const PAIRING_REPLY_COOLDOWN_MS = 3e5;
3128
2865
  const MAX_TRACKED_PAIRING_REPLY_SENDERS = 512;
3129
2866
  function createMatrixHandlerState(config) {
3130
- const { core, accountId, runtime, allowFromResolvedEntries, groupAllowFromResolvedEntries, resolveLiveUserAllowlist } = config;
2867
+ const { core, accountId, runtime, allowFromResolvedEntries, groupAllowFromResolvedEntries } = config;
3131
2868
  let cachedStoreAllowFrom = null;
3132
2869
  const liveAllowlistCache = /* @__PURE__ */ new Map();
3133
2870
  const resolveCachedLiveAllowlist = async (paramsValue) => {
@@ -3142,7 +2879,7 @@ function createMatrixHandlerState(config) {
3142
2879
  });
3143
2880
  const cached = liveAllowlistCache.get(paramsValue.scope);
3144
2881
  if (cached?.signature === signature) return cached.entries;
3145
- const entries = await resolveLiveUserAllowlist({
2882
+ const entries = await resolveMatrixMonitorLiveUserAllowlist({
3146
2883
  cfg: paramsValue.cfg,
3147
2884
  accountId,
3148
2885
  entries: paramsValue.entries,
@@ -3182,24 +2919,23 @@ function createMatrixHandlerState(config) {
3182
2919
  };
3183
2920
  const readStoreAllowFrom = async () => {
3184
2921
  const now = Date.now();
3185
- if (cachedStoreAllowFrom && isFutureDateTimestampMs(cachedStoreAllowFrom.expiresAtMs, { nowMs: now })) return cachedStoreAllowFrom.value;
2922
+ if (cachedStoreAllowFrom && cachedStoreAllowFrom.expiresAtMs > now) return cachedStoreAllowFrom.value;
3186
2923
  cachedStoreAllowFrom = null;
3187
2924
  const value = await core.channel.pairing.readAllowFromStore({
3188
2925
  channel: "matrix",
3189
2926
  env: process.env,
3190
2927
  accountId
3191
2928
  }).catch(() => []);
3192
- const expiresAtMs = resolveExpiresAtMsFromDurationMs(ALLOW_FROM_STORE_CACHE_TTL_MS, { nowMs: now });
3193
- cachedStoreAllowFrom = expiresAtMs === void 0 ? null : {
2929
+ cachedStoreAllowFrom = {
3194
2930
  value,
3195
- expiresAtMs
2931
+ expiresAtMs: now + ALLOW_FROM_STORE_CACHE_TTL_MS
3196
2932
  };
3197
2933
  return value;
3198
2934
  };
3199
2935
  const shouldSendPairingReply = (senderId, created) => {
3200
2936
  const now = Date.now();
3201
2937
  const lastSentAtMs = pairingReplySentAtMsBySender.get(senderId);
3202
- if (!created && typeof lastSentAtMs === "number" && now - lastSentAtMs < PAIRING_REPLY_COOLDOWN_MS) return false;
2938
+ if (!created && lastSentAtMs !== void 0 && now - lastSentAtMs < PAIRING_REPLY_COOLDOWN_MS) return false;
3203
2939
  setBoundedMap(pairingReplySentAtMsBySender, senderId, now, MAX_TRACKED_PAIRING_REPLY_SENDERS);
3204
2940
  return true;
3205
2941
  };
@@ -3209,29 +2945,70 @@ function createMatrixHandlerState(config) {
3209
2945
  shouldSendPairingReply
3210
2946
  };
3211
2947
  }
3212
- //#endregion
3213
- //#region extensions/matrix/src/matrix/monitor/handler.ts
2948
+ // extensions/matrix/src/matrix/monitor/location.ts
2949
+ function decodeGeoUriParamValue(value) {
2950
+ try {
2951
+ return decodeURIComponent(value);
2952
+ } catch {
2953
+ return value;
2954
+ }
2955
+ }
2956
+ function resolveMatrixLocation(params) {
2957
+ const { eventType, content } = params;
2958
+ if (!(eventType === EventType.Location || eventType === EventType.RoomMessage && content.msgtype === EventType.Location)) return null;
2959
+ const geoUri = normalizeOptionalString(content.geo_uri) ?? "";
2960
+ if (!geoUri) return null;
2961
+ if (!geoUri.toLowerCase().startsWith("geo:")) return null;
2962
+ const [coordsPart, ...paramParts] = geoUri.slice(4).split(";");
2963
+ if (!coordsPart) return null;
2964
+ const coords = coordsPart.split(",");
2965
+ if (coords.length < 2) return null;
2966
+ const latitude = parseStrictFiniteNumber(coords[0] ?? "");
2967
+ const longitude = parseStrictFiniteNumber(coords[1] ?? "");
2968
+ if (latitude === void 0 || longitude === void 0) return null;
2969
+ const geoParams = /* @__PURE__ */ new Map();
2970
+ for (const part of paramParts) {
2971
+ const segment = part.trim();
2972
+ if (!segment) continue;
2973
+ const eqIndex = segment.indexOf("=");
2974
+ const rawKey = eqIndex === -1 ? segment : segment.slice(0, eqIndex);
2975
+ const rawValue = eqIndex === -1 ? "" : segment.slice(eqIndex + 1);
2976
+ const key = normalizeLowercaseStringOrEmpty(rawKey);
2977
+ if (!key) continue;
2978
+ const valuePart = rawValue.trim();
2979
+ geoParams.set(key, valuePart ? decodeGeoUriParamValue(valuePart) : "");
2980
+ }
2981
+ const accuracyRaw = geoParams.get("u");
2982
+ const location = {
2983
+ latitude,
2984
+ longitude,
2985
+ accuracy: accuracyRaw ? parseStrictFiniteNumber(accuracyRaw) : void 0,
2986
+ caption: (normalizeOptionalString(content.body) ?? "") || void 0,
2987
+ source: "pin",
2988
+ isLive: false
2989
+ };
2990
+ return {
2991
+ text: formatLocationText(location),
2992
+ context: toLocationContext(location)
2993
+ };
2994
+ }
2995
+ // extensions/matrix/src/matrix/monitor/handler.ts
3214
2996
  const SESSION_RESTART_RECOVERY_TOMBSTONE_ERROR_CODE = "SESSION_RESTART_RECOVERY_TOMBSTONE";
3215
2997
  const RESTART_RECOVERY_TOMBSTONE_NOTICE = "This session ended during gateway restart recovery and cannot accept more messages. Send /new or /reset to start a replacement session.";
3216
2998
  function createMatrixRoomMessageHandler(params) {
3217
- const { client, core, cfg: startupConfig, accountId, runtime, logger, logVerboseMessage, allowFromResolvedEntries = [], groupAllowFromResolvedEntries = [], configuredBotUserIds = /* @__PURE__ */ new Set(), replyToMode, streaming, previewToolProgressEnabled, blockStreamingEnabled, historyLimit, startupMs, dropPreStartupMessages, inboundDeduper, directTracker, getMemberDisplayName, resolveLiveUserAllowlist = resolveMatrixMonitorLiveUserAllowlist, resolveStorePath: resolveStorePathImpl = resolveStorePath, createChannelInboundEnvelopeBuilderAsync: createChannelInboundEnvelopeBuilderImpl = createChannelInboundEnvelopeBuilderAsync, resolveHumanDelayConfig: resolveHumanDelayConfigImpl = resolveHumanDelayConfig } = params;
2999
+ const { client, core, cfg: startupConfig, accountId, runtime, logger, logVerboseMessage, allowFromResolvedEntries = [], groupAllowFromResolvedEntries = [], configuredBotUserIds = /* @__PURE__ */ new Set(), replyToMode, streaming, previewToolProgressEnabled, blockStreamingEnabled, historyLimit, directTracker, getMemberDisplayName } = params;
3218
3000
  const handlerConfig = {
3219
3001
  ...params,
3220
3002
  allowFromResolvedEntries,
3221
3003
  groupAllowFromResolvedEntries,
3222
- configuredBotUserIds,
3223
- resolveLiveUserAllowlist,
3224
- resolveStorePath: resolveStorePathImpl,
3225
- createChannelInboundEnvelopeBuilderAsync: createChannelInboundEnvelopeBuilderImpl,
3226
- resolveHumanDelayConfig: resolveHumanDelayConfigImpl
3004
+ configuredBotUserIds
3227
3005
  };
3228
3006
  const handlerState = createMatrixHandlerState({
3229
3007
  core,
3230
3008
  accountId,
3231
3009
  runtime,
3232
3010
  allowFromResolvedEntries,
3233
- groupAllowFromResolvedEntries,
3234
- resolveLiveUserAllowlist
3011
+ groupAllowFromResolvedEntries
3235
3012
  });
3236
3013
  const resolveThreadContext = createMatrixEventContextResolver({
3237
3014
  kind: "thread",
@@ -3248,9 +3025,8 @@ function createMatrixRoomMessageHandler(params) {
3248
3025
  const roomHistoryTracker = createRoomHistoryTracker();
3249
3026
  const roomIngressQueue = new KeyedAsyncQueue();
3250
3027
  const sharedDmContextNoticeRooms = /* @__PURE__ */ new Set();
3251
- return async (roomId, event) => {
3028
+ return async (roomId, event, lifecycle) => {
3252
3029
  const eventId = typeof event.event_id === "string" ? event.event_id.trim() : "";
3253
- let inboundReplayClaim;
3254
3030
  let draftControllerRef;
3255
3031
  try {
3256
3032
  const eventType = event.type;
@@ -3265,39 +3041,42 @@ function createMatrixRoomMessageHandler(params) {
3265
3041
  const senderId = event.sender;
3266
3042
  if (!senderId) return;
3267
3043
  const eventTs = event.origin_server_ts;
3268
- const eventAge = event.unsigned?.age;
3269
- const commitInboundEventIfClaimed = async () => {
3270
- const claim = inboundReplayClaim;
3271
- if (!claim) return;
3272
- await claim.commit();
3273
- if (inboundReplayClaim === claim) inboundReplayClaim = void 0;
3274
- };
3275
- const readIngressPrefix = () => readMatrixIngressPrefix({
3276
- client,
3277
- senderId,
3278
- dropPreStartupMessages,
3279
- eventTs: eventTs ?? void 0,
3280
- eventAge: eventAge ?? void 0,
3281
- startupMs,
3282
- event,
3283
- eventType,
3284
- eventId,
3285
- inboundDeduper,
3286
- roomId,
3287
- logVerboseMessage,
3288
- directTracker,
3289
- claimInboundReplay: (handle) => {
3290
- inboundReplayClaim = handle;
3044
+ const readIngressPrefix = async () => {
3045
+ const selfUserId = await client.getUserId();
3046
+ if (senderId === selfUserId) return;
3047
+ const content = locationContent;
3048
+ if (eventType === EventType.RoomMessage && isMatrixVerificationRoomMessage({
3049
+ msgtype: content.msgtype,
3050
+ body: content.body
3051
+ })) {
3052
+ logVerboseMessage(`matrix: skip verification/system room message room=${roomId}`);
3053
+ return;
3291
3054
  }
3292
- });
3055
+ const locationPayload = resolveMatrixLocation({
3056
+ eventType,
3057
+ content
3058
+ });
3059
+ const relates = content["m.relates_to"];
3060
+ if (relates && "rel_type" in relates && relates.rel_type === RelationType.Replace) return;
3061
+ if (hasBundledMatrixReplacementRelation(event)) return;
3062
+ return {
3063
+ content,
3064
+ isDirectMessage: await directTracker.isDirectMessage({
3065
+ roomId,
3066
+ senderId,
3067
+ selfUserId
3068
+ }),
3069
+ locationPayload,
3070
+ selfUserId
3071
+ };
3072
+ };
3293
3073
  const ingressContext = {
3294
3074
  handler: handlerConfig,
3295
3075
  roomId,
3296
3076
  event,
3297
3077
  eventTs: eventTs ?? void 0,
3298
3078
  senderId,
3299
- roomHistoryTracker,
3300
- commitInboundEventIfClaimed
3079
+ roomHistoryTracker
3301
3080
  };
3302
3081
  const continueIngress = async (paramsLocal) => {
3303
3082
  const access = await resolveMatrixIngressAccess({
@@ -3394,7 +3173,7 @@ function createMatrixRoomMessageHandler(params) {
3394
3173
  const replyDispatcher = createMatrixReplyDispatcher({
3395
3174
  cfg,
3396
3175
  prefixOptions,
3397
- humanDelay: resolveHumanDelayConfigImpl(cfg, _route.agentId),
3176
+ humanDelay: resolveHumanDelayConfig(cfg, _route.agentId),
3398
3177
  typingCallbacks,
3399
3178
  streaming,
3400
3179
  draftStream,
@@ -3419,27 +3198,11 @@ function createMatrixRoomMessageHandler(params) {
3419
3198
  route: _route,
3420
3199
  sessionKey: _route.sessionKey
3421
3200
  });
3422
- const replayClaimAtDispatch = inboundReplayClaim;
3423
- const turnAdoptionLifecycle = replayClaimAtDispatch ? {
3424
- admission: "exclusive",
3425
- onDeferred: () => {
3426
- if (inboundReplayClaim !== replayClaimAtDispatch) return false;
3427
- inboundReplayClaim = void 0;
3428
- },
3429
- onAdopted: async () => {
3430
- if (inboundReplayClaim === replayClaimAtDispatch) inboundReplayClaim = void 0;
3431
- await replayClaimAtDispatch.commit();
3432
- },
3433
- onAbandoned: () => {
3434
- if (inboundReplayClaim === replayClaimAtDispatch) inboundReplayClaim = void 0;
3435
- replayClaimAtDispatch.release();
3436
- }
3437
- } : void 0;
3438
3201
  const turnResultPromise = core.channel.inbound.run({
3439
3202
  channel: "matrix",
3440
3203
  accountId: _route.accountId,
3441
3204
  raw: event,
3442
- ...turnAdoptionLifecycle ? { turnAdoptionLifecycle } : {},
3205
+ turnAdoptionLifecycle: lifecycle,
3443
3206
  adapter: {
3444
3207
  ingest: () => ({
3445
3208
  id: messageId,
@@ -3504,11 +3267,6 @@ function createMatrixRoomMessageHandler(params) {
3504
3267
  skillFilter: roomConfig?.skills,
3505
3268
  disableBlockStreaming: !blockStreamingEnabled,
3506
3269
  onPartialReply: draftStream ? (payload) => draftController.onPartialReply(payload.text ?? "") : void 0,
3507
- onBlockReplyQueued: draftStream ? (payload, context) => {
3508
- if (payload.isCompactionNotice === true) return false;
3509
- draftController.queueDraftBlockBoundary(payload, context);
3510
- return false;
3511
- } : void 0,
3512
3270
  onAssistantMessageStart: draftStream ? () => {
3513
3271
  draftController.resetDraftBlockOffsets();
3514
3272
  draftController.beginAssistantMessage();
@@ -3541,36 +3299,29 @@ function createMatrixRoomMessageHandler(params) {
3541
3299
  deliveryPartCount: 1,
3542
3300
  extraContent: { msgtype: "m.notice" }
3543
3301
  });
3544
- await commitInboundEventIfClaimed();
3545
3302
  } catch (noticeError) {
3546
3303
  runtime.error?.(`matrix: failed completing restart-recovery tombstone notice room=${roomId} id=${eventId || "unknown"}: ${String(noticeError)}`);
3304
+ throw noticeError;
3547
3305
  }
3548
3306
  return;
3549
3307
  }
3550
- if (!turnResult.dispatched) {
3551
- if (turnResult.admission.kind === "drop" && turnResult.admission.reason === "bot-loop-protection") await commitInboundEventIfClaimed();
3552
- return;
3553
- }
3308
+ if (!turnResult.dispatched) return;
3554
3309
  const { dispatchResult } = turnResult;
3555
3310
  const { queuedFinal } = dispatchResult;
3556
3311
  const failedDeliveryKind = draftController.previewLifecycle.finalFailed ? "final" : !queuedFinal && replyDispatcher.nonFinalReplyDeliveryFailed() ? "non-final" : void 0;
3557
3312
  if (failedDeliveryKind) {
3558
- logVerboseMessage(`matrix: ${failedDeliveryKind} reply delivery failed room=${roomId} id=${messageId}; keeping replay committed`);
3559
- await commitInboundEventIfClaimed();
3313
+ logVerboseMessage(`matrix: ${failedDeliveryKind} reply delivery failed room=${roomId} id=${messageId}; turn already adopted`);
3560
3314
  return;
3561
3315
  }
3562
3316
  if (isRoom && triggerSnapshot) roomHistoryTracker.consumeHistory(_route.agentId, roomId, triggerSnapshot, messageId, threadRootId ? thread.threadId : void 0);
3563
- if (!hasFinalInboundReplyDispatch(dispatchResult)) {
3564
- await commitInboundEventIfClaimed();
3565
- return;
3566
- }
3317
+ if (!hasFinalInboundReplyDispatch(dispatchResult)) return;
3567
3318
  const finalCount = resolveInboundReplyDispatchCounts(dispatchResult).final;
3568
3319
  logVerboseMessage(`matrix: delivered ${finalCount} reply${finalCount === 1 ? "" : "ies"} to ${replyTarget}`);
3569
- await commitInboundEventIfClaimed();
3570
3320
  } catch (err) {
3571
3321
  const draftController = draftControllerRef;
3572
3322
  if (draftController?.draftStream?.eventId()) draftController.previewLifecycle.retainPreview();
3573
3323
  runtime.error?.(`matrix handler failed: ${String(err)}`);
3324
+ throw err;
3574
3325
  } finally {
3575
3326
  const draftStream = draftControllerRef?.draftStream;
3576
3327
  if (draftStream) {
@@ -3578,12 +3329,103 @@ function createMatrixRoomMessageHandler(params) {
3578
3329
  await draftControllerRef?.previewLifecycle.cleanup();
3579
3330
  await draftStream.cleanupPending();
3580
3331
  }
3581
- inboundReplayClaim?.release();
3582
3332
  }
3583
3333
  };
3584
3334
  }
3585
- //#endregion
3586
- //#region extensions/matrix/src/matrix/monitor/recent-invite.ts
3335
+ // extensions/matrix/src/matrix/monitor/ingress.ts
3336
+ const MatrixIngressPayloadError = createChannelIngressError("MatrixIngressPayloadError");
3337
+ function inspectMatrixIngressEvent(raw) {
3338
+ if (!raw || typeof raw.roomId !== "string" || !raw.roomId.trim() || !raw.event || typeof raw.event.event_id !== "string" || !raw.event.event_id.trim()) throw new MatrixIngressPayloadError("Matrix ingress event is missing its room or event ID");
3339
+ return {
3340
+ eventId: raw.event.event_id,
3341
+ laneKey: `room:${raw.roomId}`
3342
+ };
3343
+ }
3344
+ function createMatrixIngressMonitor(params) {
3345
+ let queue = params.queue;
3346
+ const getQueue = () => queue ??= getMatrixRuntime().state.openChannelIngressQueue({ accountId: params.accountId });
3347
+ let lastReceivedAt = 0;
3348
+ let initializeOrder;
3349
+ const monitor = createChannelIngressMonitor({
3350
+ queue: getQueue,
3351
+ inspect: inspectMatrixIngressEvent,
3352
+ payload: {
3353
+ version: 1,
3354
+ serialize: (raw) => raw,
3355
+ deserialize: (body) => body,
3356
+ encode: ({ body }) => ({
3357
+ version: 1,
3358
+ ...body
3359
+ }),
3360
+ decode: (payload) => {
3361
+ inspectMatrixIngressEvent(payload);
3362
+ return {
3363
+ version: payload.version,
3364
+ body: payload
3365
+ };
3366
+ },
3367
+ createClaimError: (kind) => new MatrixIngressPayloadError(kind === "invalid-version" ? "Matrix ingress payload version is unsupported" : "Matrix event identity changed after durable admission")
3368
+ },
3369
+ deliver: async ({ roomId, event, historical }, lifecycle) => {
3370
+ if (historical) return;
3371
+ if (event.type === EventType.RoomMessageEncrypted && !params.client.crypto) return;
3372
+ const [hydrated] = await params.client.hydrateEvents(roomId, [event]);
3373
+ if (!hydrated || hydrated.type === EventType.RoomMessageEncrypted || getMatrixEventProjection(hydrated)?.decryptionFailure) throw new Error("Matrix ingress event is waiting for decryption");
3374
+ return await params.dispatch(roomId, hydrated, lifecycle);
3375
+ },
3376
+ pollIntervalMs: 1e3,
3377
+ retention: "standard",
3378
+ waitForDeliveryIdleOnStop: false,
3379
+ drain: {
3380
+ deferredLaneOccupancy: "release",
3381
+ onLog: params.onError,
3382
+ resolveNonRetryableFailure: (error) => error instanceof MatrixIngressPayloadError ? {
3383
+ reason: "invalid-event",
3384
+ message: error.message
3385
+ } : null
3386
+ },
3387
+ onError: params.onError
3388
+ });
3389
+ const admitSync = async (sync, { hasSavedSync }) => {
3390
+ const events = [];
3391
+ const rooms = [...Object.entries(sync.rooms?.join ?? {}), ...Object.entries(sync.rooms?.leave ?? {})];
3392
+ for (const [roomId, room] of rooms) for (const event of room.timeline?.events ?? []) {
3393
+ if (!(event.type === EventType.RoomMessage || event.type === EventType.RoomMessageEncrypted || event.type === EventType.Location || event.type === EventType.Reaction || isPollEventType(event.type))) continue;
3394
+ const historical = !hasSavedSync && (typeof event.origin_server_ts === "number" && event.origin_server_ts < params.startupMs || typeof event.origin_server_ts !== "number" && typeof event.unsigned?.age === "number" && event.unsigned.age > 0);
3395
+ events.push({
3396
+ roomId,
3397
+ event: {
3398
+ ...event,
3399
+ room_id: roomId
3400
+ },
3401
+ ...historical ? { historical: true } : {}
3402
+ });
3403
+ }
3404
+ if (events.length === 0) return;
3405
+ await (initializeOrder ??= (async () => {
3406
+ const ingressQueue = getQueue();
3407
+ const { pending, claims } = ingressQueue.listUnsettled ? await ingressQueue.listUnsettled() : {
3408
+ pending: await ingressQueue.listPending({ limit: "all" }),
3409
+ claims: await ingressQueue.listClaims()
3410
+ };
3411
+ for (const row of [...pending, ...claims]) lastReceivedAt = Math.max(lastReceivedAt, row.receivedAt);
3412
+ })());
3413
+ for (const event of events) {
3414
+ const result = await monitor.admit(event, { receivedAt: Math.max(Date.now(), lastReceivedAt + 1) });
3415
+ if (result.kind === "durable") {
3416
+ const admitted = result.queueResult;
3417
+ if (admitted.kind === "accepted" || admitted.kind === "pending" || admitted.kind === "claimed") lastReceivedAt = Math.max(lastReceivedAt, admitted.record.receivedAt);
3418
+ }
3419
+ }
3420
+ };
3421
+ return {
3422
+ admitSync,
3423
+ start: monitor.start,
3424
+ stop: monitor.stop,
3425
+ waitForIdle: monitor.waitForIdle
3426
+ };
3427
+ }
3428
+ // extensions/matrix/src/matrix/monitor/recent-invite.ts
3587
3429
  function shouldPromoteRecentInviteRoom(params) {
3588
3430
  if (!params.roomInfo.nameResolved || !params.roomInfo.aliasesResolved) return false;
3589
3431
  const roomAliases = [params.roomInfo.canonicalAlias ?? "", ...params.roomInfo.altAliases].filter(Boolean);
@@ -3594,21 +3436,20 @@ function shouldPromoteRecentInviteRoom(params) {
3594
3436
  aliases: roomAliases
3595
3437
  }).matchSource === void 0;
3596
3438
  }
3597
- //#endregion
3598
- //#region extensions/matrix/src/matrix/monitor/startup.ts
3439
+ // extensions/matrix/src/matrix/monitor/startup.ts
3599
3440
  const loadMatrixStartupMaintenanceDeps = createLazyRuntimeModule(() => Promise.all([
3600
- import("./setup-core-EQceJMZZ.mjs").then((n) => n.f),
3601
- import("./device-health-Be60VF1w.mjs").then((n) => n.t),
3602
- import("./setup-core-EQceJMZZ.mjs").then((n) => n.u),
3603
- import("./startup-verification-UU8DUvi4.mjs")
3441
+ import("./setup-core-BaKffgBi.mjs").then((n) => n.f),
3442
+ import("./device-health-D7n-lPeb.mjs").then((n) => n.t),
3443
+ import("./setup-core-BaKffgBi.mjs").then((n) => n.u),
3444
+ import("./startup-verification-C-lhD0gk.mjs")
3604
3445
  ]).then(([configUpdateModule, deviceHealthModule, profileModule, startupVerificationModule]) => ({
3605
3446
  updateMatrixAccountConfig: configUpdateModule.updateMatrixAccountConfig,
3606
- summarizeMatrixDeviceHealth: deviceHealthModule.summarizeMatrixDeviceHealth,
3447
+ listStaleOpenClawMatrixDevices: deviceHealthModule.listStaleOpenClawMatrixDevices,
3607
3448
  syncMatrixOwnProfile: profileModule.syncMatrixOwnProfile,
3608
3449
  ensureMatrixStartupVerification: startupVerificationModule.ensureMatrixStartupVerification
3609
3450
  })));
3610
- async function runMatrixStartupMaintenance(params, deps) {
3611
- const runtimeDeps = deps ?? await loadMatrixStartupMaintenanceDeps();
3451
+ async function runMatrixStartupMaintenance(params) {
3452
+ const runtimeDeps = await loadMatrixStartupMaintenanceDeps();
3612
3453
  throwIfMatrixStartupAborted(params.abortSignal);
3613
3454
  try {
3614
3455
  const profileSync = await runtimeDeps.syncMatrixOwnProfile({
@@ -3635,8 +3476,8 @@ async function runMatrixStartupMaintenance(params, deps) {
3635
3476
  if (!(params.auth.encryption && params.client.crypto)) return;
3636
3477
  try {
3637
3478
  throwIfMatrixStartupAborted(params.abortSignal);
3638
- const deviceHealth = runtimeDeps.summarizeMatrixDeviceHealth(await params.client.listOwnDevices());
3639
- if (deviceHealth.staleOpenClawDevices.length > 0) params.logger.warn(`matrix: stale OpenClaw devices detected for ${params.auth.userId}: ${deviceHealth.staleOpenClawDevices.map((device) => device.deviceId).join(", ")}. Run 'openclaw matrix devices prune-stale --account ${params.effectiveAccountId}' to keep encrypted-room trust healthy.`);
3479
+ const staleOpenClawDevices = runtimeDeps.listStaleOpenClawMatrixDevices(await params.client.listOwnDevices());
3480
+ if (staleOpenClawDevices.length > 0) params.logger.warn(`matrix: stale OpenClaw devices detected for ${params.auth.userId}: ${staleOpenClawDevices.map((device) => device.deviceId).join(", ")}. Run 'openclaw matrix devices prune-stale --account ${params.effectiveAccountId}' to keep encrypted-room trust healthy.`);
3640
3481
  } catch (err) {
3641
3482
  if (isMatrixStartupAbortError(err)) throw err;
3642
3483
  params.logger.debug?.("Failed to inspect matrix device hygiene (non-fatal)", { error: String(err) });
@@ -3662,12 +3503,7 @@ async function runMatrixStartupMaintenance(params, deps) {
3662
3503
  params.logger.debug?.("Failed to resolve matrix verification status (non-fatal)", { error: String(err) });
3663
3504
  }
3664
3505
  }
3665
- //#endregion
3666
- //#region extensions/matrix/src/matrix/monitor/status.ts
3667
- function cloneLastDisconnect(value) {
3668
- if (!value || typeof value === "string") return value ?? null;
3669
- return { ...value };
3670
- }
3506
+ // extensions/matrix/src/matrix/monitor/status.ts
3671
3507
  function formatSyncError(error) {
3672
3508
  if (!error) return null;
3673
3509
  if (error instanceof Error) return error.message || error.name || "unknown";
@@ -3685,10 +3521,7 @@ function createMatrixMonitorStatusController(params) {
3685
3521
  lifecycle: "starting"
3686
3522
  };
3687
3523
  const emit = () => {
3688
- params.statusSink?.({
3689
- ...status,
3690
- lastDisconnect: cloneLastDisconnect(status.lastDisconnect)
3691
- });
3524
+ params.statusSink?.({ ...status });
3692
3525
  };
3693
3526
  const noteConnected = (at = Date.now(), options) => {
3694
3527
  const lastConnectedAt = status.connected === true ? status.lastConnectedAt ?? at : at;
@@ -3765,62 +3598,7 @@ function createMatrixMonitorStatusController(params) {
3765
3598
  }
3766
3599
  };
3767
3600
  }
3768
- //#endregion
3769
- //#region extensions/matrix/src/matrix/monitor/sync-lifecycle.ts
3770
- function formatSyncLifecycleError(state, error) {
3771
- if (error instanceof Error) return error;
3772
- const message = typeof error === "string" && error.trim() ? error.trim() : void 0;
3773
- if (state === "STOPPED") return new Error(message ?? "Matrix sync stopped unexpectedly");
3774
- return new Error(message ?? `Matrix sync entered ${state} unexpectedly`);
3775
- }
3776
- function createMatrixMonitorSyncLifecycle(params) {
3777
- let fatalError = null;
3778
- let resolveFatalWait = null;
3779
- let rejectFatalWait = null;
3780
- const settleFatal = (error) => {
3781
- if (fatalError) return;
3782
- fatalError = error;
3783
- rejectFatalWait?.(error);
3784
- resolveFatalWait = null;
3785
- rejectFatalWait = null;
3786
- };
3787
- const onSyncState = (state, _prevState, error) => {
3788
- if (isMatrixTerminalSyncState(state) && !params.isStopping?.()) {
3789
- const fatalErrorLocal = formatSyncLifecycleError(state, error);
3790
- params.statusController.noteUnexpectedError(fatalErrorLocal);
3791
- settleFatal(fatalErrorLocal);
3792
- return;
3793
- }
3794
- if (fatalError) return;
3795
- if (params.isStopping?.() && !isMatrixTerminalSyncState(state)) return;
3796
- params.statusController.noteSyncState(state, error);
3797
- };
3798
- const onUnexpectedError = (error) => {
3799
- if (params.isStopping?.()) return;
3800
- params.statusController.noteUnexpectedError(error);
3801
- settleFatal(error);
3802
- };
3803
- params.client.on("sync.state", onSyncState);
3804
- params.client.on("sync.unexpected_error", onUnexpectedError);
3805
- return {
3806
- async waitForFatalStop() {
3807
- if (fatalError) throw fatalError;
3808
- await new Promise((resolve, reject) => {
3809
- resolveFatalWait = resolve;
3810
- rejectFatalWait = (error) => reject(error);
3811
- });
3812
- },
3813
- dispose() {
3814
- resolveFatalWait?.();
3815
- resolveFatalWait = null;
3816
- rejectFatalWait = null;
3817
- params.client.off("sync.state", onSyncState);
3818
- params.client.off("sync.unexpected_error", onUnexpectedError);
3819
- }
3820
- };
3821
- }
3822
- //#endregion
3823
- //#region extensions/matrix/src/matrix/monitor/index.ts
3601
+ // extensions/matrix/src/matrix/monitor/index.ts
3824
3602
  function resolveMatrixStreamingMode(streaming) {
3825
3603
  const mode = streaming?.mode;
3826
3604
  if (mode === "partial" || mode === "quiet" || mode === "progress") return mode;
@@ -3832,6 +3610,12 @@ function resolveMatrixPreviewToolProgressEnabled(streaming) {
3832
3610
  if (mode === "progress") return streaming?.progress?.toolProgress ?? streaming?.preview?.toolProgress ?? false;
3833
3611
  return streaming?.preview?.toolProgress ?? true;
3834
3612
  }
3613
+ function formatSyncLifecycleError(state, error) {
3614
+ if (error instanceof Error) return error;
3615
+ const message = typeof error === "string" && error.trim() ? error.trim() : void 0;
3616
+ if (state === "STOPPED") return new Error(message ?? "Matrix sync stopped unexpectedly");
3617
+ return new Error(message ?? `Matrix sync entered ${state} unexpectedly`);
3618
+ }
3835
3619
  const DEFAULT_MEDIA_MAX_MB = 20;
3836
3620
  async function monitorMatrixProvider(opts = {}) {
3837
3621
  if (opts.abortSignal?.aborted) return;
@@ -3926,7 +3710,12 @@ async function monitorMatrixProvider(opts = {}) {
3926
3710
  });
3927
3711
  let disposeAutoJoin = () => {};
3928
3712
  let disposeMonitorEvents = () => {};
3929
- let syncLifecycle = null;
3713
+ let disposeSyncIngress = () => {};
3714
+ let ingress;
3715
+ let fatalError = null;
3716
+ let resolveFatalWait = null;
3717
+ let rejectFatalWait = null;
3718
+ const isStopping = () => cleanedUp || monitorLifecycleSignal?.aborted === true;
3930
3719
  let monitorSetupClosed = false;
3931
3720
  const cleanup = (mode = "persist") => {
3932
3721
  if (cleanupPromise) return cleanupPromise;
@@ -3990,6 +3779,29 @@ async function monitorMatrixProvider(opts = {}) {
3990
3779
  }
3991
3780
  if (isMatrixDisconnectedSyncState(state)) healthySyncSinceMs = void 0;
3992
3781
  };
3782
+ const settleFatal = (error) => {
3783
+ if (fatalError) return;
3784
+ fatalError = error;
3785
+ rejectFatalWait?.(error);
3786
+ resolveFatalWait = null;
3787
+ rejectFatalWait = null;
3788
+ };
3789
+ const onSyncLifecycleState = (state, _prevState, error) => {
3790
+ if (isMatrixTerminalSyncState(state) && !isStopping()) {
3791
+ const fatalErrorLocal = formatSyncLifecycleError(state, error);
3792
+ statusController.noteUnexpectedError(fatalErrorLocal);
3793
+ settleFatal(fatalErrorLocal);
3794
+ return;
3795
+ }
3796
+ if (fatalError) return;
3797
+ if (isStopping() && !isMatrixTerminalSyncState(state)) return;
3798
+ statusController.noteSyncState(state, error);
3799
+ };
3800
+ const onUnexpectedSyncError = (error) => {
3801
+ if (isStopping()) return;
3802
+ statusController.noteUnexpectedError(error);
3803
+ settleFatal(error);
3804
+ };
3993
3805
  const monitorRetirement = {
3994
3806
  closeTaskAdmission: () => {
3995
3807
  monitorSetupClosed = true;
@@ -3998,17 +3810,24 @@ async function monitorMatrixProvider(opts = {}) {
3998
3810
  detachListeners: () => {
3999
3811
  disposeAutoJoin();
4000
3812
  disposeMonitorEvents();
3813
+ disposeSyncIngress();
4001
3814
  client?.off("sync.state", onSyncState);
4002
- syncLifecycle?.dispose();
3815
+ resolveFatalWait?.();
3816
+ resolveFatalWait = null;
3817
+ rejectFatalWait = null;
3818
+ client?.off("sync.state", onSyncLifecycleState);
3819
+ client?.off("sync.unexpected_error", onUnexpectedSyncError);
3820
+ },
3821
+ waitForTasks: async () => {
3822
+ await ingress?.stop();
3823
+ await monitorTaskRunner.waitForIdle();
4003
3824
  },
4004
- waitForTasks: monitorTaskRunner.waitForIdle,
4005
3825
  cleanup: () => threadBindingManager?.stop()
4006
3826
  };
4007
3827
  try {
4008
3828
  clientLease = await acquireSharedMatrixClient({
4009
3829
  cfg,
4010
3830
  auth: authWithLimit,
4011
- startClient: false,
4012
3831
  accountId: auth.accountId,
4013
3832
  abortSignal: opts.abortSignal,
4014
3833
  role: "monitor"
@@ -4016,18 +3835,10 @@ async function monitorMatrixProvider(opts = {}) {
4016
3835
  client = clientLease.client;
4017
3836
  monitorLifecycleSignal = opts.abortSignal ? AbortSignal.any([opts.abortSignal, clientLease.abortSignal]) : clientLease.abortSignal;
4018
3837
  clientLease.registerMonitorRetirement(monitorRetirement);
4019
- const inboundDeduper = createMatrixInboundEventDeduper({
4020
- auth,
4021
- env: process.env
4022
- });
4023
- syncLifecycle = createMatrixMonitorSyncLifecycle({
4024
- client,
4025
- statusController,
4026
- isStopping: () => cleanedUp || monitorLifecycleSignal?.aborted === true
4027
- });
3838
+ client.on("sync.state", onSyncLifecycleState);
3839
+ client.on("sync.unexpected_error", onUnexpectedSyncError);
4028
3840
  client.on("sync.state", onSyncState);
4029
- const dropPreStartupMessages = !client.hasPersistedSyncState();
4030
- const { getRoomInfo, getMemberDisplayName, invalidateMemberDisplayName } = createMatrixRoomInfoResolver(client);
3841
+ const { getRoomInfo, getMemberDisplayName, invalidateMemberDisplayName, invalidateRoomName } = createMatrixRoomInfoResolver(client);
4031
3842
  const isExplicitlyConfiguredRoom = async (roomId) => {
4032
3843
  const roomInfoForConfig = needsRoomAliasesForConfig ? await getRoomInfo(roomId, { includeAliases: true }) : void 0;
4033
3844
  const aliases = roomInfoForConfig ? [roomInfoForConfig.canonicalAlias ?? "", ...roomInfoForConfig.altAliases].filter(Boolean) : [];
@@ -4096,9 +3907,6 @@ async function monitorMatrixProvider(opts = {}) {
4096
3907
  dmPolicy,
4097
3908
  mediaMaxBytes,
4098
3909
  historyLimit,
4099
- startupMs,
4100
- dropPreStartupMessages,
4101
- inboundDeduper,
4102
3910
  directTracker,
4103
3911
  getRoomInfo,
4104
3912
  getMemberDisplayName,
@@ -4139,21 +3947,30 @@ async function monitorMatrixProvider(opts = {}) {
4139
3947
  needsRoomAliasesForConfig,
4140
3948
  getRoomInfo,
4141
3949
  invalidateMemberDisplayName,
3950
+ invalidateRoomName,
4142
3951
  logVerboseMessage,
4143
3952
  warnedEncryptedRooms,
4144
3953
  warnedCryptoMissingRooms,
4145
3954
  logger,
4146
3955
  getHealthySyncSinceMs: () => healthySyncSinceMs,
4147
3956
  formatNativeDependencyHint: core.system.formatNativeDependencyHint,
4148
- onRoomMessage: handleRoomMessage,
4149
3957
  runDetachedTask: monitorTaskRunner.runDetachedTask
4150
3958
  });
3959
+ ingress = createMatrixIngressMonitor({
3960
+ accountId: effectiveAccountId,
3961
+ client,
3962
+ startupMs,
3963
+ dispatch: (roomId, event, lifecycle) => monitorTaskRunner.runTask(() => handleRoomMessage(roomId, event, lifecycle)),
3964
+ onError: (error) => logger.warn("matrix ingress failed", { error: String(error) })
3965
+ });
3966
+ disposeSyncIngress = await client.bindSyncIngress(ingress.admitSync);
4151
3967
  logVerboseMessage("matrix: starting client");
4152
3968
  await clientLease.start(monitorLifecycleSignal);
4153
3969
  if (monitorSetupClosed) {
4154
3970
  await cleanup("stop");
4155
3971
  return;
4156
3972
  }
3973
+ ingress.start();
4157
3974
  logVerboseMessage("matrix: client started");
4158
3975
  logger.info(`matrix: logged in as ${auth.userId}`);
4159
3976
  monitorTaskRunner.runDetachedTask("deviceId backfill", async () => {
@@ -4202,7 +4019,13 @@ async function monitorMatrixProvider(opts = {}) {
4202
4019
  } catch (err) {
4203
4020
  logger.warn("matrix: failed during monitor shutdown cleanup", { error: String(err) });
4204
4021
  }
4205
- }), syncLifecycle.waitForFatalStop()]);
4022
+ }), new Promise((resolve, reject) => {
4023
+ if (fatalError) reject(fatalError);
4024
+ else {
4025
+ resolveFatalWait = resolve;
4026
+ rejectFatalWait = reject;
4027
+ }
4028
+ })]);
4206
4029
  await cleanup();
4207
4030
  } catch (err) {
4208
4031
  if (monitorSetupClosed || monitorLifecycleSignal?.aborted && isMatrixStartupAbortError(err)) {
@@ -4214,5 +4037,4 @@ async function monitorMatrixProvider(opts = {}) {
4214
4037
  throw err;
4215
4038
  }
4216
4039
  }
4217
- //#endregion
4218
4040
  export { monitorMatrixProvider };