@openclaw/matrix 2026.11.3 → 2026.11.5-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.setup/{account-selection-CWsL5zIU.mjs → account-selection-UUPhMBmu.mjs} +10 -10
- package/dist/.setup/{approval-handler.runtime-Co2elSYS.mjs → approval-handler.runtime-Ca12_7Qa.mjs} +16 -51
- package/dist/.setup/{approval-reactions-D2pEUrFS.mjs → approval-reactions-BazmsDbe.mjs} +2 -2
- package/dist/.setup/{channel-BBvOdxTc.mjs → channel-CX7k81dL.mjs} +291 -360
- package/dist/.setup/channel.runtime-K_hHX-9W.mjs +73 -0
- package/dist/.setup/{channel.setup-p6oll48W.mjs → channel.setup-B00zzOOL.mjs} +28 -45
- package/dist/.setup/{cli-C2XKMk1U.mjs → cli-dz9hd2dR.mjs} +248 -308
- package/dist/.setup/{cli-metadata-C60BW1oa.mjs → cli-metadata-CwUhA9CY.mjs} +1 -1
- package/dist/.setup/{client-Cxv-iMwp.mjs → client-CFPYqaYK.mjs} +5 -5
- package/dist/.setup/{client-BEl7PU1_.mjs → client-D1bsidwU.mjs} +87 -174
- package/dist/.setup/{client-bootstrap-D1vLveT2.mjs → client-bootstrap-CTT0VF6v.mjs} +5 -10
- package/dist/.setup/{client-support-D-xHScuo.mjs → client-support-B_Mp4Qk9.mjs} +1 -15
- package/dist/.setup/{create-client-CrY1E3hg.mjs → create-client-Ccf5wyS3.mjs} +5 -5
- package/dist/.setup/{credentials-udso1z0C.mjs → credentials-kT20jk_u.mjs} +6 -20
- package/dist/.setup/{credentials-read-Dj7Hj87M.mjs → credentials-read-CM6wXUjL.mjs} +2 -2
- package/dist/.setup/{crypto-runtime-DqX7VD1W.mjs → crypto-runtime-DZNytKX5.mjs} +73 -159
- package/dist/.setup/{crypto-state-store-DclM-fO5.mjs → crypto-state-store-BZLlwkv_.mjs} +14 -10
- package/dist/.setup/{crypto-store-ownership-Dr-T40Rp.mjs → crypto-store-ownership-CiQ1l_O7.mjs} +1 -1
- package/dist/.setup/{crypto-unsafe-state-doctor-BG9qMu0B.mjs → crypto-unsafe-state-doctor-Dh1dtuSz.mjs} +6 -5
- package/dist/.setup/{deps-L_1bUAGL.mjs → deps-D-W_QQjz.mjs} +4 -3
- package/dist/.setup/device-health-Ck2YpEVN.mjs +8 -0
- package/dist/.setup/{direct-management-ZcjZgYEl.mjs → direct-management-Dp1giZ34.mjs} +21 -27
- package/dist/.setup/{directory-live-_yaRaktv.mjs → directory-live-ufzRheWx.mjs} +4 -4
- package/dist/.setup/{draft-stream-vO_qjwJb.mjs → draft-stream-BPjjKSoI.mjs} +10 -16
- package/dist/.setup/{encryption-guidance-BLUoN4aV.mjs → encryption-guidance-Br3Lv9Hm.mjs} +1 -1
- package/dist/.setup/{exec-approvals-BFT-ee9F.mjs → exec-approvals-BwEOyI1-.mjs} +31 -41
- package/dist/.setup/{file-sync-store-BxUPmUoJ.mjs → file-sync-store-BpS12yaK.mjs} +81 -8
- package/dist/.setup/{http-client-ByR4STVQ.mjs → http-client-B_ohXrBm.mjs} +19 -31
- package/dist/.setup/{idb-persistence-C2TsCHY2.mjs → idb-persistence-BTOsltD9.mjs} +21 -14
- package/dist/.setup/{joined-room-encryption-DBbLkdvv.mjs → joined-room-encryption-C0gHa2DG.mjs} +3 -2
- package/dist/.setup/{messages-TuEa_BPZ.mjs → messages-DpJ9naJa.mjs} +39 -22
- package/dist/.setup/{monitor-B86Ll4B8.mjs → monitor-Rzl3naSn.mjs} +693 -857
- package/dist/.setup/{onboarding-DOLEjkg2.mjs → onboarding-BK-V2ZLT.mjs} +115 -127
- package/dist/.setup/{outbound-BWsyqwt1.mjs → outbound-DMMVmZjV.mjs} +2 -2
- package/dist/.setup/{profile-update-DiXSVBki.mjs → profile-update-RLsY-gu6.mjs} +14 -14
- package/dist/.setup/{reaction-events-CuUeYcBC.mjs → reaction-events-UA_g6jEX.mjs} +74 -99
- package/dist/.setup/{resolve-targets-Dd70hGcM.mjs → resolve-targets-DYW8ULZS.mjs} +1 -1
- package/dist/.setup/{retired-state-C4UnLIg4.mjs → retired-state-JGUEBE72.mjs} +41 -2
- package/dist/.setup/{room-info-C13IUffQ.mjs → room-info-Dhc4efkA.mjs} +21 -8
- package/dist/.setup/runtime-setter-api-i2MOXoT3.mjs +2 -0
- package/dist/.setup/{sdk-DNW03GqJ.mjs → sdk-DPXiQ3jr.mjs} +92 -105
- package/dist/.setup/secret-contract-api-Dukgvike.mjs +2 -0
- package/dist/.setup/{send-BGgwE5pV.mjs → send-HHAbKARg.mjs} +168 -250
- package/dist/.setup/{send-currentness-C2rMVVIQ.mjs → send-currentness-DGxiiBn9.mjs} +9 -15
- package/dist/.setup/{setup-bootstrap-BCbltIf_.mjs → setup-bootstrap-DaT2j28V.mjs} +2 -2
- package/dist/.setup/{setup-core-Di6NtQ_J.mjs → setup-core-DcqQbLZv.mjs} +18 -41
- package/dist/.setup/setup-plugin-api-Cg4TelGZ.mjs +2 -0
- package/dist/.setup/{startup-verification-8xvGpdtK.mjs → startup-verification-UkaoSldm.mjs} +9 -23
- package/dist/.setup/{storage-CN4dxdtV.mjs → storage-C3N6YZIn.mjs} +8 -20
- package/dist/.setup/{subagent-hooks-CSY4iwa_.mjs → subagent-hooks-CfGAysJi.mjs} +1 -1
- package/dist/.setup/{sync-cache-state-L1kwjhjj.mjs → sync-cache-state-BKVaKRzQ.mjs} +5 -8
- package/dist/.setup/sync-state-CWbp0QSY.mjs +12 -0
- package/dist/.setup/task-runner-DY3aKiQa.mjs +52 -0
- package/dist/.setup/{thread-bindings-pNgPVdof.mjs → thread-bindings-891JsKXF.mjs} +34 -50
- package/dist/.setup/{thread-bindings-shared-CPjUA0Ib.mjs → thread-bindings-shared-QmZOfX9Q.mjs} +2 -2
- package/dist/.setup/{tool-actions-CFC7ZpIt.mjs → tool-actions-yFZH_7mC.mjs} +59 -67
- package/dist/.setup/{url-validation-CF6pG6eE.mjs → url-validation-By_2hsXr.mjs} +1 -2
- package/dist/.setup/{verification-CuT5ZBDO.mjs → verification-CcZIVL8P.mjs} +6 -6
- package/dist/.source-module-urls/1cd4d4ff8d44e1c8b830932b44d7cf8a7f3350e09e169910e1d7a85e131b7bea.json +1 -0
- package/dist/api.js +6 -6
- package/dist/auth-presence.js +1 -1
- package/dist/channel-plugin-api.js +1 -2
- package/dist/cli-metadata.js +1 -2
- package/dist/contract-api.js +2 -2
- package/dist/doctor-contract-api.js +110 -120
- package/dist/helper-api.js +1 -1
- package/dist/index.js +1 -1
- package/dist/plugin-entry.handlers.runtime.js +2 -2
- package/dist/runtime-api.js +3 -3
- package/dist/runtime-setter-api.js +1 -2
- package/dist/secret-contract-api.js +1 -2
- package/dist/session-binding-contract-api.js +1 -1
- package/dist/setup-entry.js +3 -3
- package/dist/setup-plugin-api.js +1 -2
- package/dist/subagent-hooks-api.js +1 -1
- package/dist/thread-binding-api.js +1 -2
- package/dist/thread-bindings-runtime.js +1 -2
- package/node_modules/@babel/runtime/helpers/asyncIterator.js +1 -1
- package/node_modules/@babel/runtime/helpers/createForOfIteratorHelper.js +12 -6
- package/node_modules/@babel/runtime/helpers/esm/asyncIterator.js +1 -1
- package/node_modules/@babel/runtime/helpers/esm/createForOfIteratorHelper.js +12 -6
- package/node_modules/@babel/runtime/helpers/esm/interopRequireWildcard.js +16 -19
- package/node_modules/@babel/runtime/helpers/esm/toPrimitive.js +5 -5
- package/node_modules/@babel/runtime/helpers/interopRequireWildcard.js +16 -19
- package/node_modules/@babel/runtime/helpers/toPrimitive.js +5 -5
- package/node_modules/@babel/runtime/package.json +1 -1
- package/node_modules/@openclaw/fs-safe/CHANGELOG.md +94 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-parser.wasm +0 -0
- package/node_modules/@openclaw/fs-safe/dist/copy-file-input.d.ts +1 -1
- package/node_modules/@openclaw/fs-safe/dist/copy-file-input.js +3 -1
- package/node_modules/@openclaw/fs-safe/dist/copy-path-admission.js +2 -2
- package/node_modules/@openclaw/fs-safe/dist/copy-root-file-sync.js +8 -1
- package/node_modules/@openclaw/fs-safe/dist/file-open-error.d.ts +2 -0
- package/node_modules/@openclaw/fs-safe/dist/file-open-error.js +14 -0
- package/node_modules/@openclaw/fs-safe/dist/file-sync.d.ts +2 -1
- package/node_modules/@openclaw/fs-safe/dist/file-sync.js +6 -1
- package/node_modules/@openclaw/fs-safe/dist/guest-native-python.js +3 -0
- package/node_modules/@openclaw/fs-safe/dist/native-binding.d.ts +1 -0
- package/node_modules/@openclaw/fs-safe/dist/native-config.js +14 -3
- package/node_modules/@openclaw/fs-safe/dist/native-operations.js +2 -0
- package/node_modules/@openclaw/fs-safe/dist/native-pinned-write-windows.js +9 -2
- package/node_modules/@openclaw/fs-safe/dist/native-staged-file.js +40 -32
- package/node_modules/@openclaw/fs-safe/dist/output.js +6 -0
- package/node_modules/@openclaw/fs-safe/dist/owner-dacl.d.ts +2 -0
- package/node_modules/@openclaw/fs-safe/dist/owner-dacl.js +1 -0
- package/node_modules/@openclaw/fs-safe/dist/path.js +5 -1
- package/node_modules/@openclaw/fs-safe/dist/pinned-write-staged.js +25 -2
- package/node_modules/@openclaw/fs-safe/dist/publication-handle.d.ts +4 -0
- package/node_modules/@openclaw/fs-safe/dist/publication-handle.js +32 -0
- package/node_modules/@openclaw/fs-safe/dist/publish-copy-stage.d.ts +2 -1
- package/node_modules/@openclaw/fs-safe/dist/publish-copy-stage.js +19 -9
- package/node_modules/@openclaw/fs-safe/dist/publish-file.js +23 -24
- package/node_modules/@openclaw/fs-safe/dist/publish-rename-fallback.d.ts +21 -0
- package/node_modules/@openclaw/fs-safe/dist/publish-rename-fallback.js +102 -0
- package/node_modules/@openclaw/fs-safe/dist/root-create-native.js +2 -0
- package/node_modules/@openclaw/fs-safe/dist/root-directory-entry.d.ts +3 -1
- package/node_modules/@openclaw/fs-safe/dist/root-directory-entry.js +8 -5
- package/node_modules/@openclaw/fs-safe/dist/root-directory-list-types.d.ts +3 -0
- package/node_modules/@openclaw/fs-safe/dist/root-directory-list.d.ts +2 -1
- package/node_modules/@openclaw/fs-safe/dist/root-directory-list.js +19 -9
- package/node_modules/@openclaw/fs-safe/dist/root-file-final-admission.js +3 -3
- package/node_modules/@openclaw/fs-safe/dist/root-path-existing.d.ts +2 -2
- package/node_modules/@openclaw/fs-safe/dist/root-path-existing.js +27 -13
- package/node_modules/@openclaw/fs-safe/dist/root-path.js +2 -2
- package/node_modules/@openclaw/fs-safe/dist/sibling-staged-file.d.ts +3 -0
- package/node_modules/@openclaw/fs-safe/dist/sibling-staged-file.js +18 -3
- package/node_modules/@openclaw/fs-safe/dist/watch-hints.d.ts +1 -1
- package/node_modules/@openclaw/fs-safe/dist/watch-hints.js +68 -21
- package/node_modules/@openclaw/fs-safe/dist/watch-io-error.d.ts +2 -0
- package/node_modules/@openclaw/fs-safe/dist/watch-io-error.js +27 -0
- package/node_modules/@openclaw/fs-safe/dist/watch-io-worker.d.ts +1 -0
- package/node_modules/@openclaw/fs-safe/dist/watch-io-worker.js +93 -0
- package/node_modules/@openclaw/fs-safe/dist/watch-io.d.ts +47 -0
- package/node_modules/@openclaw/fs-safe/dist/watch-io.js +236 -0
- package/node_modules/@openclaw/fs-safe/dist/watch-native.d.ts +1 -1
- package/node_modules/@openclaw/fs-safe/dist/watch-native.js +3 -3
- package/node_modules/@openclaw/fs-safe/dist/watch-probe.d.ts +16 -0
- package/node_modules/@openclaw/fs-safe/dist/watch-probe.js +135 -0
- package/node_modules/@openclaw/fs-safe/dist/watch-rescan.d.ts +1 -1
- package/node_modules/@openclaw/fs-safe/dist/watch-rescan.js +86 -24
- package/node_modules/@openclaw/fs-safe/dist/watch-scan.d.ts +4 -0
- package/node_modules/@openclaw/fs-safe/dist/watch-scan.js +78 -16
- package/node_modules/@openclaw/fs-safe/dist/watch-stream.d.ts +2 -0
- package/node_modules/@openclaw/fs-safe/dist/watch-stream.js +23 -0
- package/node_modules/@openclaw/fs-safe/dist/watch-types.d.ts +3 -1
- package/node_modules/@openclaw/fs-safe/dist/watch.js +60 -13
- package/node_modules/@openclaw/fs-safe/dist/windows-security-facts.d.ts +1 -1
- package/node_modules/@openclaw/fs-safe/dist/windows-security-facts.js +1 -0
- package/node_modules/@openclaw/fs-safe/dist/windows-security-helper.exe +0 -0
- package/node_modules/@openclaw/fs-safe/docs/advanced.md +5 -2
- package/node_modules/@openclaw/fs-safe/docs/compiler-qualification.md +392 -0
- package/node_modules/@openclaw/fs-safe/docs/config.md +7 -1
- package/node_modules/@openclaw/fs-safe/docs/contributing.md +25 -5
- package/node_modules/@openclaw/fs-safe/docs/copy.md +10 -0
- package/node_modules/@openclaw/fs-safe/docs/durability.md +9 -3
- package/node_modules/@openclaw/fs-safe/docs/errors.md +13 -0
- package/node_modules/@openclaw/fs-safe/docs/migrating-to-0.5.md +6 -4
- package/node_modules/@openclaw/fs-safe/docs/native-helper.md +6 -4
- package/node_modules/@openclaw/fs-safe/docs/output.md +4 -2
- package/node_modules/@openclaw/fs-safe/docs/path.md +5 -2
- package/node_modules/@openclaw/fs-safe/docs/permissions.md +15 -0
- package/node_modules/@openclaw/fs-safe/docs/security-model.md +9 -0
- package/node_modules/@openclaw/fs-safe/docs/staged-file.md +2 -0
- package/node_modules/@openclaw/fs-safe/docs/testing.md +1 -1
- package/node_modules/@openclaw/fs-safe/docs/watch.md +62 -5
- package/node_modules/@openclaw/fs-safe/docs/writing.md +6 -1
- package/node_modules/@openclaw/fs-safe/package.json +18 -16
- package/node_modules/@openclaw/fs-safe-darwin-arm64/fs-safe-native.node +0 -0
- package/node_modules/@openclaw/fs-safe-darwin-arm64/package.json +1 -1
- package/node_modules/@openclaw/fs-safe-darwin-x64/fs-safe-native.node +0 -0
- package/node_modules/@openclaw/fs-safe-darwin-x64/package.json +1 -1
- package/node_modules/@openclaw/fs-safe-freebsd-arm64/fs-safe-native.node +0 -0
- package/node_modules/@openclaw/fs-safe-freebsd-arm64/package.json +1 -1
- package/node_modules/@openclaw/fs-safe-freebsd-x64/fs-safe-native.node +0 -0
- package/node_modules/@openclaw/fs-safe-freebsd-x64/package.json +1 -1
- package/node_modules/@openclaw/fs-safe-linux-arm64-gnu/fs-safe-native.node +0 -0
- package/node_modules/@openclaw/fs-safe-linux-arm64-gnu/package.json +1 -1
- package/node_modules/@openclaw/fs-safe-linux-arm64-musl/fs-safe-native.node +0 -0
- package/node_modules/@openclaw/fs-safe-linux-arm64-musl/package.json +1 -1
- package/node_modules/@openclaw/fs-safe-linux-x64-gnu/fs-safe-native.node +0 -0
- package/node_modules/@openclaw/fs-safe-linux-x64-gnu/package.json +1 -1
- package/node_modules/@openclaw/fs-safe-linux-x64-musl/fs-safe-native.node +0 -0
- package/node_modules/@openclaw/fs-safe-linux-x64-musl/package.json +1 -1
- package/node_modules/@openclaw/fs-safe-win32-arm64-msvc/fs-safe-native.node +0 -0
- package/node_modules/@openclaw/fs-safe-win32-arm64-msvc/package.json +1 -1
- package/node_modules/@openclaw/fs-safe-win32-x64-msvc/fs-safe-native.node +0 -0
- package/node_modules/@openclaw/fs-safe-win32-x64-msvc/package.json +1 -1
- package/node_modules/@tokenizer/inflate/README.md +30 -1
- package/node_modules/@tokenizer/inflate/lib/GzipHandler.js +1 -1
- package/node_modules/@tokenizer/inflate/lib/ZipHandler.d.ts +8 -3
- package/node_modules/@tokenizer/inflate/lib/ZipHandler.js +101 -26
- package/node_modules/@tokenizer/inflate/lib/ZipLimitError.d.ts +16 -0
- package/node_modules/@tokenizer/inflate/lib/ZipLimitError.js +10 -0
- package/node_modules/@tokenizer/inflate/lib/ZipToken.d.ts +1 -1
- package/node_modules/@tokenizer/inflate/lib/ZipToken.js +11 -7
- package/node_modules/@tokenizer/inflate/lib/index.d.ts +2 -1
- package/node_modules/@tokenizer/inflate/lib/index.js +2 -1
- package/node_modules/@tokenizer/inflate/package.json +16 -15
- package/node_modules/argparse/lib/argparse.js +1 -1
- package/node_modules/argparse/package.json +1 -1
- package/node_modules/fake-indexeddb/build/cjs/FDBCursor.js +20 -18
- package/node_modules/fake-indexeddb/build/cjs/FDBKeyRange.js +6 -6
- package/node_modules/fake-indexeddb/build/cjs/FDBTransaction.js +20 -2
- package/node_modules/fake-indexeddb/build/cjs/lib/RecordStore.js +3 -3
- package/node_modules/fake-indexeddb/build/cjs/lib/binarySearchTree.js +11 -13
- package/node_modules/fake-indexeddb/build/cjs/lib/cmp.js +44 -14
- package/node_modules/fake-indexeddb/build/cjs/test/fakeIndexedDB/auto.js +54 -0
- package/node_modules/fake-indexeddb/build/cjs/test/fakeIndexedDB/binarySearchTree.js +413 -0
- package/node_modules/fake-indexeddb/build/cjs/test/fakeIndexedDB/fakeIndexedDB.js +1018 -0
- package/node_modules/fake-indexeddb/build/cjs/test/fakeIndexedDB/forceCloseDatabase.js +99 -0
- package/node_modules/fake-indexeddb/build/cjs/test/fakeIndexedDB/getAll.js +707 -0
- package/node_modules/fake-indexeddb/build/cjs/test/fakeIndexedDB/memoryLeaks.js +42 -0
- package/node_modules/fake-indexeddb/build/esm/FDBCursor.js +19 -18
- package/node_modules/fake-indexeddb/build/esm/FDBKeyRange.js +6 -6
- package/node_modules/fake-indexeddb/build/esm/FDBTransaction.js +20 -2
- package/node_modules/fake-indexeddb/build/esm/lib/RecordStore.js +3 -3
- package/node_modules/fake-indexeddb/build/esm/lib/binarySearchTree.js +11 -13
- package/node_modules/fake-indexeddb/build/esm/lib/cmp.js +41 -11
- package/node_modules/fake-indexeddb/build/esm/test/fakeIndexedDB/auto.js +52 -0
- package/node_modules/fake-indexeddb/build/esm/test/fakeIndexedDB/binarySearchTree.js +409 -0
- package/node_modules/fake-indexeddb/build/esm/test/fakeIndexedDB/fakeIndexedDB.js +1014 -0
- package/node_modules/fake-indexeddb/build/esm/test/fakeIndexedDB/forceCloseDatabase.js +95 -0
- package/node_modules/fake-indexeddb/build/esm/test/fakeIndexedDB/getAll.js +703 -0
- package/node_modules/fake-indexeddb/build/esm/test/fakeIndexedDB/memoryLeaks.js +38 -0
- package/node_modules/fake-indexeddb/package.json +1 -1
- package/node_modules/file-type/node_modules/strtok3/LICENSE.txt +21 -0
- package/node_modules/file-type/node_modules/strtok3/README.md +591 -0
- package/node_modules/file-type/node_modules/strtok3/lib/AbortSignal.d.ts +2 -0
- package/node_modules/file-type/node_modules/strtok3/lib/AbortSignal.js +7 -0
- package/node_modules/file-type/node_modules/strtok3/lib/AbstractTokenizer.d.ts +114 -0
- package/node_modules/file-type/node_modules/strtok3/lib/AbstractTokenizer.js +196 -0
- package/node_modules/file-type/node_modules/strtok3/lib/BlobTokenizer.d.ts +29 -0
- package/node_modules/file-type/node_modules/strtok3/lib/BlobTokenizer.js +56 -0
- package/node_modules/file-type/node_modules/strtok3/lib/BufferSizeError.d.ts +19 -0
- package/node_modules/file-type/node_modules/strtok3/lib/BufferSizeError.js +27 -0
- package/node_modules/file-type/node_modules/strtok3/lib/BufferTokenizer.d.ts +29 -0
- package/node_modules/file-type/node_modules/strtok3/lib/BufferTokenizer.js +50 -0
- package/node_modules/file-type/node_modules/strtok3/lib/FileTokenizer.d.ts +47 -0
- package/node_modules/file-type/node_modules/strtok3/lib/FileTokenizer.js +83 -0
- package/node_modules/file-type/node_modules/strtok3/lib/NotRegularFileError.d.ts +5 -0
- package/node_modules/file-type/node_modules/strtok3/lib/NotRegularFileError.js +8 -0
- package/node_modules/file-type/node_modules/strtok3/lib/ReadStreamTokenizer.d.ts +34 -0
- package/node_modules/file-type/node_modules/strtok3/lib/ReadStreamTokenizer.js +125 -0
- package/node_modules/file-type/node_modules/strtok3/lib/core.d.ts +41 -0
- package/node_modules/file-type/node_modules/strtok3/lib/core.js +69 -0
- package/node_modules/file-type/node_modules/strtok3/lib/index.d.ts +17 -0
- package/node_modules/file-type/node_modules/strtok3/lib/index.js +23 -0
- package/node_modules/file-type/node_modules/strtok3/lib/stream/AbstractStreamReader.d.ts +54 -0
- package/node_modules/file-type/node_modules/strtok3/lib/stream/AbstractStreamReader.js +73 -0
- package/node_modules/file-type/node_modules/strtok3/lib/stream/Deferred.d.ts +6 -0
- package/node_modules/file-type/node_modules/strtok3/lib/stream/Deferred.js +10 -0
- package/node_modules/file-type/node_modules/strtok3/lib/stream/Errors.d.ts +10 -0
- package/node_modules/file-type/node_modules/strtok3/lib/stream/Errors.js +16 -0
- package/node_modules/file-type/node_modules/strtok3/lib/stream/StreamReader.d.ts +30 -0
- package/node_modules/file-type/node_modules/strtok3/lib/stream/StreamReader.js +104 -0
- package/node_modules/file-type/node_modules/strtok3/lib/stream/WebStreamByobReader.d.ts +14 -0
- package/node_modules/file-type/node_modules/strtok3/lib/stream/WebStreamByobReader.js +29 -0
- package/node_modules/file-type/node_modules/strtok3/lib/stream/WebStreamDefaultReader.d.ts +19 -0
- package/node_modules/file-type/node_modules/strtok3/lib/stream/WebStreamDefaultReader.js +67 -0
- package/node_modules/file-type/node_modules/strtok3/lib/stream/WebStreamReader.d.ts +14 -0
- package/node_modules/file-type/node_modules/strtok3/lib/stream/WebStreamReader.js +13 -0
- package/node_modules/file-type/node_modules/strtok3/lib/stream/WebStreamReaderFactory.d.ts +5 -0
- package/node_modules/file-type/node_modules/strtok3/lib/stream/WebStreamReaderFactory.js +19 -0
- package/node_modules/file-type/node_modules/strtok3/lib/stream/index.d.ts +6 -0
- package/node_modules/file-type/node_modules/strtok3/lib/stream/index.js +5 -0
- package/node_modules/file-type/node_modules/strtok3/lib/types.d.ts +146 -0
- package/node_modules/file-type/node_modules/strtok3/lib/types.js +1 -0
- package/node_modules/file-type/node_modules/strtok3/package.json +95 -0
- package/node_modules/file-type/package.json +28 -27
- package/node_modules/file-type/readme.md +32 -3
- package/node_modules/file-type/source/detectors/ebml.js +2 -2
- package/node_modules/file-type/source/detectors/png.js +1 -0
- package/node_modules/file-type/source/detectors/zip.js +71 -112
- package/node_modules/file-type/source/index.d.ts +18 -8
- package/node_modules/file-type/source/index.js +75 -49
- package/node_modules/file-type/source/index.test-d.ts +29 -21
- package/node_modules/file-type/source/supported.js +4 -0
- package/node_modules/file-type/source/tokens.js +2 -2
- package/node_modules/markdown-it/dist/browser/markdown-it.esm.min.mjs +737 -686
- package/node_modules/markdown-it/dist/browser/markdown-it.esm.min.mjs.map +1 -1
- package/node_modules/markdown-it/dist/browser/markdown-it.umd.min.js +8 -8
- package/node_modules/markdown-it/dist/browser/markdown-it.umd.min.js.map +1 -1
- package/node_modules/markdown-it/dist/markdown-it.cjs.js +660 -518
- package/node_modules/markdown-it/dist/markdown-it.cjs.js.map +1 -1
- package/node_modules/markdown-it/dist/markdown-it.d.mts +1 -0
- package/node_modules/markdown-it/dist/markdown-it.mjs +179 -124
- package/node_modules/markdown-it/dist/markdown-it.mjs.map +1 -1
- package/node_modules/markdown-it/package.json +11 -11
- package/node_modules/matrix-js-sdk/CHANGELOG.md +23 -0
- package/node_modules/matrix-js-sdk/lib/@types/PushRules.d.ts +3 -1
- package/node_modules/matrix-js-sdk/lib/@types/PushRules.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/@types/PushRules.js +2 -0
- package/node_modules/matrix-js-sdk/lib/@types/PushRules.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/@types/event.d.ts +1 -0
- package/node_modules/matrix-js-sdk/lib/@types/event.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/@types/event.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/@types/matrix-sdk-crypto-wasm.d.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/client.d.ts +88 -37
- package/node_modules/matrix-js-sdk/lib/client.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/client.js +72 -47
- package/node_modules/matrix-js-sdk/lib/client.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/crypto-api/index.d.ts +3 -3
- package/node_modules/matrix-js-sdk/lib/crypto-api/index.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/crypto-api/index.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/embedded.d.ts +17 -1
- package/node_modules/matrix-js-sdk/lib/embedded.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/embedded.js +46 -1
- package/node_modules/matrix-js-sdk/lib/embedded.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/errors.d.ts +1 -1
- package/node_modules/matrix-js-sdk/lib/errors.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/errors.js +2 -2
- package/node_modules/matrix-js-sdk/lib/errors.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/http-api/fetch.d.ts +7 -1
- package/node_modules/matrix-js-sdk/lib/http-api/fetch.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/http-api/fetch.js +14 -5
- package/node_modules/matrix-js-sdk/lib/http-api/fetch.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/http-api/interface.d.ts +34 -8
- package/node_modules/matrix-js-sdk/lib/http-api/interface.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/http-api/interface.js +10 -3
- package/node_modules/matrix-js-sdk/lib/http-api/interface.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/http-api/refresh.d.ts +30 -11
- package/node_modules/matrix-js-sdk/lib/http-api/refresh.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/http-api/refresh.js +72 -5
- package/node_modules/matrix-js-sdk/lib/http-api/refresh.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/matrix.d.ts +1 -1
- package/node_modules/matrix-js-sdk/lib/matrix.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/matrix.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/matrixrtc/CallMembership.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/matrixrtc/CallMembership.js +20 -6
- package/node_modules/matrix-js-sdk/lib/matrixrtc/CallMembership.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/matrixrtc/IMembershipManager.d.ts +5 -0
- package/node_modules/matrix-js-sdk/lib/matrixrtc/IMembershipManager.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/matrixrtc/IMembershipManager.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/matrixrtc/MatrixRTCSession.d.ts +27 -1
- package/node_modules/matrix-js-sdk/lib/matrixrtc/MatrixRTCSession.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/matrixrtc/MatrixRTCSession.js +58 -36
- package/node_modules/matrix-js-sdk/lib/matrixrtc/MatrixRTCSession.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/matrixrtc/MatrixRTCSessionManager.js +1 -1
- package/node_modules/matrix-js-sdk/lib/matrixrtc/MatrixRTCSessionManager.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/matrixrtc/MembershipManager.d.ts +76 -0
- package/node_modules/matrix-js-sdk/lib/matrixrtc/MembershipManager.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/matrixrtc/MembershipManager.js +264 -47
- package/node_modules/matrix-js-sdk/lib/matrixrtc/MembershipManager.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/matrixrtc/index.d.ts +1 -1
- package/node_modules/matrix-js-sdk/lib/matrixrtc/index.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/matrixrtc/index.js +1 -1
- package/node_modules/matrix-js-sdk/lib/matrixrtc/index.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/matrixrtc/membershipData/common.d.ts +8 -0
- package/node_modules/matrix-js-sdk/lib/matrixrtc/membershipData/common.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/matrixrtc/membershipData/common.js +10 -0
- package/node_modules/matrix-js-sdk/lib/matrixrtc/membershipData/common.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/matrixrtc/membershipData/index.d.ts +1 -1
- package/node_modules/matrix-js-sdk/lib/matrixrtc/membershipData/index.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/matrixrtc/membershipData/index.js +1 -1
- package/node_modules/matrix-js-sdk/lib/matrixrtc/membershipData/index.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/matrixrtc/types.d.ts +104 -11
- package/node_modules/matrix-js-sdk/lib/matrixrtc/types.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/matrixrtc/types.js +263 -19
- package/node_modules/matrix-js-sdk/lib/matrixrtc/types.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/matrixrtc/utils.d.ts +22 -1
- package/node_modules/matrix-js-sdk/lib/matrixrtc/utils.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/matrixrtc/utils.js +38 -0
- package/node_modules/matrix-js-sdk/lib/matrixrtc/utils.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/models/room-sticky-events.d.ts +7 -0
- package/node_modules/matrix-js-sdk/lib/models/room-sticky-events.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/models/room-sticky-events.js +27 -0
- package/node_modules/matrix-js-sdk/lib/models/room-sticky-events.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/models/thread.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/models/thread.js +8 -0
- package/node_modules/matrix-js-sdk/lib/models/thread.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/oauth/authorize.js +1 -1
- package/node_modules/matrix-js-sdk/lib/oauth/authorize.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/oauth/index.d.ts +3 -5
- package/node_modules/matrix-js-sdk/lib/oauth/index.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/oauth/index.js +7 -7
- package/node_modules/matrix-js-sdk/lib/oauth/index.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/oauth/tokenRefresher.d.ts +10 -4
- package/node_modules/matrix-js-sdk/lib/oauth/tokenRefresher.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/oauth/tokenRefresher.js +34 -24
- package/node_modules/matrix-js-sdk/lib/oauth/tokenRefresher.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/receipt-accumulator.d.ts +10 -11
- package/node_modules/matrix-js-sdk/lib/receipt-accumulator.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/receipt-accumulator.js +26 -25
- package/node_modules/matrix-js-sdk/lib/receipt-accumulator.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/room-summary-api.d.ts +71 -0
- package/node_modules/matrix-js-sdk/lib/room-summary-api.d.ts.map +1 -0
- package/node_modules/matrix-js-sdk/lib/room-summary-api.js +82 -0
- package/node_modules/matrix-js-sdk/lib/room-summary-api.js.map +1 -0
- package/node_modules/matrix-js-sdk/lib/rust-crypto/backup.d.ts +7 -0
- package/node_modules/matrix-js-sdk/lib/rust-crypto/backup.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/rust-crypto/backup.js +41 -25
- package/node_modules/matrix-js-sdk/lib/rust-crypto/backup.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/sync.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/sync.js +6 -1
- package/node_modules/matrix-js-sdk/lib/sync.js.map +1 -1
- package/node_modules/matrix-js-sdk/package.json +6 -6
- package/node_modules/matrix-js-sdk/src/@types/PushRules.ts +2 -0
- package/node_modules/matrix-js-sdk/src/@types/event.ts +1 -1
- package/node_modules/matrix-js-sdk/src/@types/matrix-sdk-crypto-wasm.d.ts +15 -12
- package/node_modules/matrix-js-sdk/src/client.ts +105 -62
- package/node_modules/matrix-js-sdk/src/crypto-api/index.ts +3 -3
- package/node_modules/matrix-js-sdk/src/embedded.ts +61 -2
- package/node_modules/matrix-js-sdk/src/errors.ts +2 -1
- package/node_modules/matrix-js-sdk/src/http-api/fetch.ts +14 -5
- package/node_modules/matrix-js-sdk/src/http-api/interface.ts +36 -8
- package/node_modules/matrix-js-sdk/src/http-api/refresh.ts +101 -17
- package/node_modules/matrix-js-sdk/src/matrix.ts +1 -1
- package/node_modules/matrix-js-sdk/src/matrixrtc/CallMembership.ts +22 -4
- package/node_modules/matrix-js-sdk/src/matrixrtc/IMembershipManager.ts +6 -0
- package/node_modules/matrix-js-sdk/src/matrixrtc/MatrixRTCSession.ts +72 -49
- package/node_modules/matrix-js-sdk/src/matrixrtc/MatrixRTCSessionManager.ts +1 -1
- package/node_modules/matrix-js-sdk/src/matrixrtc/MembershipManager.ts +284 -61
- package/node_modules/matrix-js-sdk/src/matrixrtc/index.ts +7 -1
- package/node_modules/matrix-js-sdk/src/matrixrtc/membershipData/common.ts +12 -0
- package/node_modules/matrix-js-sdk/src/matrixrtc/membershipData/index.ts +1 -1
- package/node_modules/matrix-js-sdk/src/matrixrtc/types.ts +351 -23
- package/node_modules/matrix-js-sdk/src/matrixrtc/utils.ts +54 -1
- package/node_modules/matrix-js-sdk/src/models/room-sticky-events.ts +26 -1
- package/node_modules/matrix-js-sdk/src/models/thread.ts +9 -0
- package/node_modules/matrix-js-sdk/src/oauth/authorize.ts +1 -1
- package/node_modules/matrix-js-sdk/src/oauth/index.ts +7 -8
- package/node_modules/matrix-js-sdk/src/oauth/tokenRefresher.ts +15 -5
- package/node_modules/matrix-js-sdk/src/receipt-accumulator.ts +30 -26
- package/node_modules/matrix-js-sdk/src/room-summary-api.ts +114 -0
- package/node_modules/matrix-js-sdk/src/rust-crypto/backup.ts +46 -33
- package/node_modules/matrix-js-sdk/src/sync.ts +9 -1
- package/node_modules/music-metadata/README.md +125 -37
- package/node_modules/music-metadata/lib/ParseError.d.ts +10 -3
- package/node_modules/music-metadata/lib/ParseError.js +2 -0
- package/node_modules/music-metadata/lib/ParserFactory.d.ts +1 -1
- package/node_modules/music-metadata/lib/ParserFactory.js +20 -8
- package/node_modules/music-metadata/lib/aiff/AiffParser.d.ts +1 -0
- package/node_modules/music-metadata/lib/aiff/AiffParser.js +25 -17
- package/node_modules/music-metadata/lib/aiff/AiffToken.d.ts +9 -3
- package/node_modules/music-metadata/lib/aiff/AiffToken.js +10 -0
- package/node_modules/music-metadata/lib/apev2/APEv2Parser.d.ts +4 -3
- package/node_modules/music-metadata/lib/apev2/APEv2Parser.js +6 -30
- package/node_modules/music-metadata/lib/asf/AsfGuid.js +49 -49
- package/node_modules/music-metadata/lib/asf/AsfObject.d.ts +12 -6
- package/node_modules/music-metadata/lib/asf/AsfObject.js +201 -58
- package/node_modules/music-metadata/lib/asf/AsfParser.d.ts +4 -0
- package/node_modules/music-metadata/lib/asf/AsfParser.js +119 -27
- package/node_modules/music-metadata/lib/caf/CafLoader.d.ts +2 -0
- package/node_modules/music-metadata/lib/caf/CafLoader.js +8 -0
- package/node_modules/music-metadata/lib/caf/CafParser.d.ts +37 -0
- package/node_modules/music-metadata/lib/caf/CafParser.js +253 -0
- package/node_modules/music-metadata/lib/caf/CafTagMap.d.ts +8 -0
- package/node_modules/music-metadata/lib/caf/CafTagMap.js +38 -0
- package/node_modules/music-metadata/lib/caf/CafToken.d.ts +75 -0
- package/node_modules/music-metadata/lib/caf/CafToken.js +135 -0
- package/node_modules/music-metadata/lib/common/Allocation.d.ts +14 -0
- package/node_modules/music-metadata/lib/common/Allocation.js +70 -0
- package/node_modules/music-metadata/lib/common/BasicParser.d.ts +2 -0
- package/node_modules/music-metadata/lib/common/BasicParser.js +8 -0
- package/node_modules/music-metadata/lib/common/CaseInsensitiveTagMap.d.ts +1 -1
- package/node_modules/music-metadata/lib/common/CaseInsensitiveTagMap.js +3 -3
- package/node_modules/music-metadata/lib/common/CombinedTagMapper.js +4 -3
- package/node_modules/music-metadata/lib/common/GenericTagMapper.d.ts +1 -1
- package/node_modules/music-metadata/lib/common/GenericTagMapper.js +4 -2
- package/node_modules/music-metadata/lib/common/GenericTagTypes.d.ts +2 -2
- package/node_modules/music-metadata/lib/common/MetadataCollector.d.ts +6 -5
- package/node_modules/music-metadata/lib/common/MetadataCollector.js +57 -30
- package/node_modules/music-metadata/lib/common/TrackInfo.d.ts +8 -0
- package/node_modules/music-metadata/lib/common/TrackInfo.js +68 -0
- package/node_modules/music-metadata/lib/common/Util.d.ts +1 -1
- package/node_modules/music-metadata/lib/common/Util.js +6 -12
- package/node_modules/music-metadata/lib/core.d.ts +1 -1
- package/node_modules/music-metadata/lib/core.js +10 -18
- package/node_modules/music-metadata/lib/dsdiff/DsdiffLoader.js +1 -1
- package/node_modules/music-metadata/lib/dsdiff/DsdiffParser.d.ts +7 -3
- package/node_modules/music-metadata/lib/dsdiff/DsdiffParser.js +69 -33
- package/node_modules/music-metadata/lib/dsf/DsfParser.d.ts +4 -3
- package/node_modules/music-metadata/lib/dsf/DsfParser.js +1 -1
- package/node_modules/music-metadata/lib/ebml/EbmlIterator.d.ts +28 -19
- package/node_modules/music-metadata/lib/ebml/EbmlIterator.js +97 -67
- package/node_modules/music-metadata/lib/ebml/types.d.ts +36 -8
- package/node_modules/music-metadata/lib/ebml/types.js +2 -1
- package/node_modules/music-metadata/lib/flac/FlacParser.js +10 -18
- package/node_modules/music-metadata/lib/id3v1/ID3v1Parser.d.ts +1 -1
- package/node_modules/music-metadata/lib/id3v1/ID3v1Parser.js +5 -1
- package/node_modules/music-metadata/lib/id3v2/AbstractID3Parser.js +1 -4
- package/node_modules/music-metadata/lib/id3v2/EmbeddedID3v2.d.ts +5 -0
- package/node_modules/music-metadata/lib/id3v2/EmbeddedID3v2.js +29 -0
- package/node_modules/music-metadata/lib/id3v2/FrameParser.d.ts +5 -3
- package/node_modules/music-metadata/lib/id3v2/FrameParser.js +59 -33
- package/node_modules/music-metadata/lib/id3v2/ID3v2Parser.js +15 -8
- package/node_modules/music-metadata/lib/index.d.ts +2 -0
- package/node_modules/music-metadata/lib/index.js +8 -4
- package/node_modules/music-metadata/lib/matroska/MatroskaDtd.d.ts +630 -2
- package/node_modules/music-metadata/lib/matroska/MatroskaDtd.js +58 -40
- package/node_modules/music-metadata/lib/matroska/MatroskaParser.d.ts +4 -0
- package/node_modules/music-metadata/lib/matroska/MatroskaParser.js +211 -68
- package/node_modules/music-metadata/lib/matroska/types.d.ts +33 -131
- package/node_modules/music-metadata/lib/matroska/types.js +1 -18
- package/node_modules/music-metadata/lib/mp4/Atom.js +7 -0
- package/node_modules/music-metadata/lib/mp4/AtomToken.d.ts +17 -4
- package/node_modules/music-metadata/lib/mp4/AtomToken.js +124 -21
- package/node_modules/music-metadata/lib/mp4/MP4Parser.d.ts +12 -3
- package/node_modules/music-metadata/lib/mp4/MP4Parser.js +559 -242
- package/node_modules/music-metadata/lib/mpeg/AdtsFrameHeader.d.ts +17 -0
- package/node_modules/music-metadata/lib/mpeg/AdtsFrameHeader.js +44 -0
- package/node_modules/music-metadata/lib/mpeg/MpegFrameHeader.d.ts +41 -0
- package/node_modules/music-metadata/lib/mpeg/MpegFrameHeader.js +84 -0
- package/node_modules/music-metadata/lib/mpeg/MpegParser.d.ts +11 -24
- package/node_modules/music-metadata/lib/mpeg/MpegParser.js +77 -337
- package/node_modules/music-metadata/lib/musepack/MusepackConentError.d.ts +4 -3
- package/node_modules/music-metadata/lib/musepack/sv7/BitReader.js +3 -2
- package/node_modules/music-metadata/lib/musepack/sv7/MpcSv7Parser.js +3 -6
- package/node_modules/music-metadata/lib/musepack/sv8/MpcSv8Parser.js +1 -4
- package/node_modules/music-metadata/lib/musepack/sv8/StreamVersion8.js +1 -0
- package/node_modules/music-metadata/lib/ogg/OggLoader.js +1 -1
- package/node_modules/music-metadata/lib/ogg/OggParser.d.ts +4 -3
- package/node_modules/music-metadata/lib/ogg/OggParser.js +54 -9
- package/node_modules/music-metadata/lib/ogg/OggStreamMetadata.d.ts +14 -0
- package/node_modules/music-metadata/lib/ogg/OggStreamMetadata.js +27 -0
- package/node_modules/music-metadata/lib/ogg/OggToken.d.ts +1 -0
- package/node_modules/music-metadata/lib/ogg/OggToken.js +3 -1
- package/node_modules/music-metadata/lib/ogg/flac/FlacStream.d.ts +3 -1
- package/node_modules/music-metadata/lib/ogg/flac/FlacStream.js +21 -3
- package/node_modules/music-metadata/lib/ogg/opus/Opus.d.ts +4 -3
- package/node_modules/music-metadata/lib/ogg/opus/Opus.js +1 -0
- package/node_modules/music-metadata/lib/ogg/opus/OpusStream.js +4 -2
- package/node_modules/music-metadata/lib/ogg/speex/SpeexStream.js +2 -1
- package/node_modules/music-metadata/lib/ogg/theora/Theora.d.ts +5 -0
- package/node_modules/music-metadata/lib/ogg/theora/Theora.js +7 -2
- package/node_modules/music-metadata/lib/ogg/theora/TheoraStream.d.ts +5 -2
- package/node_modules/music-metadata/lib/ogg/theora/TheoraStream.js +43 -3
- package/node_modules/music-metadata/lib/ogg/vorbis/Vorbis.js +4 -3
- package/node_modules/music-metadata/lib/ogg/vorbis/VorbisDecoder.d.ts +11 -0
- package/node_modules/music-metadata/lib/ogg/vorbis/VorbisDecoder.js +29 -0
- package/node_modules/music-metadata/lib/ogg/vorbis/VorbisStream.d.ts +6 -4
- package/node_modules/music-metadata/lib/ogg/vorbis/VorbisStream.js +24 -18
- package/node_modules/music-metadata/lib/riff/RiffChunk.js +3 -0
- package/node_modules/music-metadata/lib/type.d.ts +49 -6
- package/node_modules/music-metadata/lib/type.js +22 -1
- package/node_modules/music-metadata/lib/wav/WaveChunk.d.ts +4 -3
- package/node_modules/music-metadata/lib/wav/WaveChunk.js +2 -0
- package/node_modules/music-metadata/lib/wav/WaveParser.d.ts +0 -1
- package/node_modules/music-metadata/lib/wav/WaveParser.js +21 -23
- package/node_modules/music-metadata/lib/wavpack/WavPackParser.d.ts +4 -3
- package/node_modules/music-metadata/lib/wavpack/WavPackParser.js +6 -6
- package/node_modules/music-metadata/package.json +26 -22
- package/node_modules/strtok3/LICENSE.txt +21 -21
- package/node_modules/strtok3/README.md +712 -399
- package/node_modules/strtok3/lib/AbortSignal.d.ts +2 -0
- package/node_modules/strtok3/lib/AbortSignal.js +7 -0
- package/node_modules/strtok3/lib/AbstractTokenizer.d.ts +40 -2
- package/node_modules/strtok3/lib/AbstractTokenizer.js +101 -16
- package/node_modules/strtok3/lib/BlobTokenizer.d.ts +1 -1
- package/node_modules/strtok3/lib/BlobTokenizer.js +14 -11
- package/node_modules/strtok3/lib/BufferSizeError.d.ts +19 -0
- package/node_modules/strtok3/lib/BufferSizeError.js +27 -0
- package/node_modules/strtok3/lib/BufferTokenizer.d.ts +1 -1
- package/node_modules/strtok3/lib/BufferTokenizer.js +7 -9
- package/node_modules/strtok3/lib/FileTokenizer.d.ts +13 -3
- package/node_modules/strtok3/lib/FileTokenizer.js +29 -7
- package/node_modules/strtok3/lib/NotRegularFileError.d.ts +5 -0
- package/node_modules/strtok3/lib/NotRegularFileError.js +8 -0
- package/node_modules/strtok3/lib/ReadStreamTokenizer.js +32 -9
- package/node_modules/strtok3/lib/TokenizerBoundaryError.d.ts +7 -0
- package/node_modules/strtok3/lib/TokenizerBoundaryError.js +10 -0
- package/node_modules/strtok3/lib/TokenizerView.d.ts +9 -0
- package/node_modules/strtok3/lib/TokenizerView.js +184 -0
- package/node_modules/strtok3/lib/core.d.ts +10 -6
- package/node_modules/strtok3/lib/core.js +16 -22
- package/node_modules/strtok3/lib/index.d.ts +5 -4
- package/node_modules/strtok3/lib/index.js +3 -2
- package/node_modules/strtok3/lib/isRandomAccessTokenizer.d.ts +6 -0
- package/node_modules/strtok3/lib/isRandomAccessTokenizer.js +10 -0
- package/node_modules/strtok3/lib/stream/AbstractStreamReader.js +5 -3
- package/node_modules/strtok3/lib/stream/Errors.js +3 -3
- package/node_modules/strtok3/lib/stream/StreamReader.d.ts +4 -3
- package/node_modules/strtok3/lib/stream/StreamReader.js +46 -25
- package/node_modules/strtok3/lib/stream/WebStreamByobReader.js +5 -3
- package/node_modules/strtok3/lib/stream/WebStreamDefaultReader.d.ts +1 -1
- package/node_modules/strtok3/lib/stream/WebStreamDefaultReader.js +9 -4
- package/node_modules/strtok3/lib/stream/WebStreamReader.d.ts +13 -3
- package/node_modules/strtok3/lib/stream/WebStreamReader.js +1 -1
- package/node_modules/strtok3/lib/stream/WebStreamReaderFactory.js +1 -1
- package/node_modules/strtok3/lib/stream/index.d.ts +1 -1
- package/node_modules/strtok3/lib/types.d.ts +25 -1
- package/node_modules/strtok3/package.json +97 -94
- package/node_modules/typebox/build/format/duration.d.mts +2 -2
- package/node_modules/typebox/build/format/duration.mjs +2 -2
- package/node_modules/typebox/build/format/idn_email.d.mts +1 -0
- package/node_modules/typebox/build/format/idn_email.mjs +1 -0
- package/node_modules/typebox/build/format/idn_hostname.d.mts +1 -1
- package/node_modules/typebox/build/format/idn_hostname.mjs +1 -1
- package/node_modules/typebox/build/format/ipv4.d.mts +2 -2
- package/node_modules/typebox/build/format/ipv4.mjs +2 -2
- package/node_modules/typebox/build/format/ipv6.d.mts +1 -1
- package/node_modules/typebox/build/format/ipv6.mjs +1 -1
- package/node_modules/typebox/build/format/relative_json_pointer.d.mts +2 -2
- package/node_modules/typebox/build/format/relative_json_pointer.mjs +2 -2
- package/node_modules/typebox/build/schema/build.mjs +1 -0
- package/node_modules/typebox/build/schema/engine/_unique.d.mts +4 -2
- package/node_modules/typebox/build/schema/engine/_unique.mjs +7 -3
- package/node_modules/typebox/build/schema/engine/additionalItems.mjs +3 -3
- package/node_modules/typebox/build/schema/engine/additionalProperties.d.mts +0 -3
- package/node_modules/typebox/build/schema/engine/additionalProperties.mjs +15 -17
- package/node_modules/typebox/build/schema/engine/contains.mjs +3 -3
- package/node_modules/typebox/build/schema/engine/index.d.mts +1 -0
- package/node_modules/typebox/build/schema/engine/index.mjs +1 -0
- package/node_modules/typebox/build/schema/engine/items.mjs +7 -4
- package/node_modules/typebox/build/schema/engine/maxContains.mjs +2 -2
- package/node_modules/typebox/build/schema/engine/minContains.mjs +3 -3
- package/node_modules/typebox/build/schema/engine/oneOf.mjs +2 -2
- package/node_modules/typebox/build/schema/engine/patternProperties.mjs +2 -2
- package/node_modules/typebox/build/schema/engine/propertyNames.mjs +2 -2
- package/node_modules/typebox/build/schema/engine/unevaluatedItems.mjs +2 -2
- package/node_modules/typebox/build/schema/engine/unevaluatedProperties.mjs +2 -2
- package/node_modules/typebox/build/system/hashing/hash.mjs +63 -34
- package/node_modules/typebox/build/system/locale/en_US.mjs +2 -1
- package/node_modules/typebox/build/system/memory/assign.d.mts +2 -8
- package/node_modules/typebox/build/system/memory/assign.mjs +13 -6
- package/node_modules/typebox/build/system/memory/clone.d.mts +4 -5
- package/node_modules/typebox/build/system/memory/clone.mjs +8 -96
- package/node_modules/typebox/build/system/memory/create.d.mts +1 -5
- package/node_modules/typebox/build/system/memory/create.mjs +18 -13
- package/node_modules/typebox/build/system/memory/deep.d.mts +2 -0
- package/node_modules/typebox/build/system/memory/deep.mjs +108 -0
- package/node_modules/typebox/build/system/memory/discard.d.mts +1 -1
- package/node_modules/typebox/build/system/memory/discard.mjs +9 -8
- package/node_modules/typebox/build/system/memory/finalize.d.mts +4 -0
- package/node_modules/typebox/build/system/memory/finalize.mjs +30 -0
- package/node_modules/typebox/build/system/memory/keys.d.mts +2 -0
- package/node_modules/typebox/build/system/memory/keys.mjs +8 -0
- package/node_modules/typebox/build/system/memory/update.d.mts +1 -4
- package/node_modules/typebox/build/system/memory/update.mjs +43 -16
- package/node_modules/typebox/build/type/engine/call/index.d.mts +1 -0
- package/node_modules/typebox/build/type/engine/call/index.mjs +1 -0
- package/node_modules/typebox/build/type/engine/evaluate/composite.d.mts +2 -24
- package/node_modules/typebox/build/type/engine/evaluate/composite.mjs +2 -29
- package/node_modules/typebox/build/type/engine/evaluate/index.d.mts +1 -0
- package/node_modules/typebox/build/type/engine/evaluate/index.mjs +1 -0
- package/node_modules/typebox/build/type/engine/evaluate/narrow.d.mts +5 -1
- package/node_modules/typebox/build/type/engine/evaluate/narrow.mjs +6 -1
- package/node_modules/typebox/build/type/engine/evaluate/property.d.mts +30 -0
- package/node_modules/typebox/build/type/engine/evaluate/property.mjs +29 -0
- package/node_modules/typebox/build/type/engine/immutable/instantiate_add.d.mts +1 -3
- package/node_modules/typebox/build/type/engine/immutable/instantiate_add.mjs +1 -4
- package/node_modules/typebox/build/type/engine/object/from_intersect.d.mts +2 -2
- package/node_modules/typebox/build/type/engine/object/from_intersect.mjs +2 -2
- package/node_modules/typebox/build/type/engine/object/from_union.d.mts +2 -2
- package/node_modules/typebox/build/type/engine/object/from_union.mjs +2 -2
- package/node_modules/typebox/build/type/engine/optional/instantiate_add.d.mts +1 -3
- package/node_modules/typebox/build/type/engine/optional/instantiate_add.mjs +1 -4
- package/node_modules/typebox/build/type/engine/readonly/instantiate_add.d.mts +1 -3
- package/node_modules/typebox/build/type/engine/readonly/instantiate_add.mjs +1 -4
- package/node_modules/typebox/build/type/engine/this/index.d.mts +1 -0
- package/node_modules/typebox/build/type/engine/this/index.mjs +1 -0
- package/node_modules/typebox/build/value/clone/clone.d.mts +4 -3
- package/node_modules/typebox/build/value/clone/clone.mjs +5 -7
- package/node_modules/typebox/build/value/repair/from_cyclic.d.mts +2 -0
- package/node_modules/typebox/build/value/repair/from_cyclic.mjs +6 -0
- package/node_modules/typebox/build/value/shared/union_priority_sort.mjs +25 -14
- package/node_modules/typebox/package.json +1 -1
- package/node_modules/typebox/readme.md +1 -1
- package/node_modules/zod/package.json +1 -1
- package/node_modules/zod/src/v4/classic/tests/array.test.ts +27 -0
- package/node_modules/zod/src/v4/classic/tests/map.test.ts +7 -0
- package/node_modules/zod/src/v4/classic/tests/set.test.ts +6 -0
- package/node_modules/zod/src/v4/core/compile.ts +9 -0
- package/node_modules/zod/src/v4/core/schemas.ts +35 -1
- package/node_modules/zod/src/v4/core/util.ts +13 -0
- package/node_modules/zod/src/v4/core/versions.ts +1 -1
- package/node_modules/zod/v4/core/compile.cjs +8 -0
- package/node_modules/zod/v4/core/compile.js +8 -0
- package/node_modules/zod/v4/core/schemas.cjs +30 -0
- package/node_modules/zod/v4/core/schemas.d.cts +3 -1
- package/node_modules/zod/v4/core/schemas.d.ts +3 -1
- package/node_modules/zod/v4/core/schemas.js +30 -0
- package/node_modules/zod/v4/core/util.cjs +15 -0
- package/node_modules/zod/v4/core/util.d.cts +2 -0
- package/node_modules/zod/v4/core/util.d.ts +2 -0
- package/node_modules/zod/v4/core/util.js +14 -0
- package/node_modules/zod/v4/core/versions.cjs +1 -1
- package/node_modules/zod/v4/core/versions.js +1 -1
- package/openclaw.plugin.json +11 -0
- package/package.json +11 -11
- package/dist/.setup/channel.runtime-DyX4mM8d.mjs +0 -76
- package/dist/.setup/device-health-D6_ECUVe.mjs +0 -21
- package/dist/.setup/inbound-dedupe-sW_gaR44.mjs +0 -48
- package/dist/.setup/runtime-setter-api-DtxDAM-x.mjs +0 -3
- package/dist/.setup/secret-contract-api-CiuSYjUy.mjs +0 -3
- package/dist/.setup/setup-plugin-api-ORC_4yEA.mjs +0 -3
- package/dist/.setup/sqlite-state-LByPx4Yp.mjs +0 -37
- package/node_modules/music-metadata/node_modules/content-type/LICENSE +0 -22
- package/node_modules/music-metadata/node_modules/content-type/README.md +0 -71
- package/node_modules/music-metadata/node_modules/content-type/dist/index.d.ts +0 -46
- package/node_modules/music-metadata/node_modules/content-type/dist/index.js +0 -176
- package/node_modules/music-metadata/node_modules/content-type/dist/index.js.map +0 -1
- package/node_modules/music-metadata/node_modules/content-type/package.json +0 -52
- package/node_modules/typebox/build/system/memory/freeze.d.mts +0 -4
- package/node_modules/typebox/build/system/memory/freeze.mjs +0 -6
|
@@ -1,36 +1,40 @@
|
|
|
1
1
|
import { t as getMatrixRuntime } from "./runtime-1kn1P6io.mjs";
|
|
2
2
|
import { a as resolveMatrixAccountConfig, i as resolveMatrixAccountAllowlistConfig } from "./account-config-CRsKoMqJ.mjs";
|
|
3
|
-
import { h as resolveConfiguredMatrixBotUserIds } from "./setup-core-
|
|
4
|
-
import { a as
|
|
5
|
-
import { a as resolveMatrixAllowListMatch, i as normalizeMatrixUserId, r as normalizeMatrixAllowList } from "./channel.setup-
|
|
3
|
+
import { h as resolveConfiguredMatrixBotUserIds } from "./setup-core-DcqQbLZv.mjs";
|
|
4
|
+
import { a as resolveMatrixInboundRouteAsync, i as resolveMatrixRoomConfig, n as resolveMatrixStoredSessionMeta, o as resolveMatrixThreadRouting } from "./channel-CX7k81dL.mjs";
|
|
5
|
+
import { a as resolveMatrixAllowListMatch, i as normalizeMatrixUserId, r as normalizeMatrixAllowList } from "./channel.setup-B00zzOOL.mjs";
|
|
6
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-
|
|
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-
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import { n as
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
7
|
+
import { a as MATRIX_REACTION_EVENT_TYPE, n as withMatrixSendCurrentness } from "./send-currentness-DGxiiBn9.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-Dp1giZ34.mjs";
|
|
9
|
+
import { n as getMatrixMonitorTaskSignal, t as createMatrixMonitorTaskRunner } from "./task-runner-DY3aKiQa.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-HHAbKARg.mjs";
|
|
11
|
+
import { n as getMatrixEventProjection } from "./event-helpers-CxNgMQqH.mjs";
|
|
12
|
+
import { t as createMatrixThreadBindingManager } from "./thread-bindings-891JsKXF.mjs";
|
|
13
|
+
import { a as isMatrixAccessTokenInvalidatedError } from "./client-support-B_Mp4Qk9.mjs";
|
|
14
|
+
import { a as isMatrixStartupAbortError, c as resolveMatrixAuth, l as resolveMatrixAuthContext, n as acquireSharedMatrixClient, o as throwIfMatrixStartupAborted, s as backfillMatrixAuthDeviceIdAfterStartup } from "./client-D1bsidwU.mjs";
|
|
15
|
+
import { i as readMatrixMessages, l as fetchMatrixPollSnapshot } from "./messages-DpJ9naJa.mjs";
|
|
16
|
+
import { a as isMatrixMediaSizeLimitError, i as MatrixMediaSizeLimitError } from "./http-client-B_ohXrBm.mjs";
|
|
17
|
+
import { n as prepareMatrixReplyPayload, r as resolveMatrixExtraContent } from "./outbound-DMMVmZjV.mjs";
|
|
18
|
+
import { t as resolveMatrixTargets } from "./resolve-targets-DYW8ULZS.mjs";
|
|
19
|
+
import { n as emitMatrixLog } from "./logger-CuAzdD8Q.mjs";
|
|
20
|
+
import { t as formatMatrixEncryptedEventDisabledWarning } from "./encryption-guidance-Br3Lv9Hm.mjs";
|
|
21
|
+
import { n as isMatrixReadySyncState, r as isMatrixTerminalSyncState, t as isMatrixDisconnectedSyncState } from "./sync-state-CWbp0QSY.mjs";
|
|
22
|
+
import { r as getMatrixRoomInfo, t as createMatrixRoomInfoResolver } from "./room-info-Dhc4efkA.mjs";
|
|
20
23
|
import { channelBlockedPatch, channelReadyPatch, channelStoppedPatch, createTransportActivityStatusPatch } from "openclaw/plugin-sdk/gateway-runtime";
|
|
21
24
|
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";
|
|
25
|
+
import { createChannelDeliveryAccumulator, createChannelIngressError, createChannelIngressMonitor, createChannelProgressDraftCompositor, createLivePreviewLifecycle, createPreviewMessageReceipt, createReplyPrefixOptions, createTypingCallbacks, logTypingFailure, resolveChannelStreamingBlockEnabled, waitUntilAbort } from "openclaw/plugin-sdk/channel-outbound";
|
|
23
26
|
import { extractErrorCode, formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
|
|
24
27
|
import { normalizeLowercaseStringOrEmpty, normalizeNullableString, normalizeOptionalString, normalizeStringifiedEntries, normalizeUniqueTrimmedStringList, readStringValue, uniqueStrings } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
25
28
|
import { stripReasoningTagsFromText } from "openclaw/plugin-sdk/text-chunking";
|
|
29
|
+
import { randomUUID } from "node:crypto";
|
|
26
30
|
import { CHANNEL_APPROVAL_NATIVE_RUNTIME_CONTEXT_CAPABILITY } from "openclaw/plugin-sdk/approval-handler-adapter-runtime";
|
|
27
31
|
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 {
|
|
32
|
+
import { normalizeStringEntries as normalizeStringEntries$1, truncateWithMarker } from "openclaw/plugin-sdk/string-normalization-runtime";
|
|
33
|
+
import { parseStrictFiniteNumber, resolveOptionalIntegerOption, resolvePromptHistoryLimit } from "openclaw/plugin-sdk/number-runtime";
|
|
30
34
|
import { resolveAgentRoute, resolveInboundLastRouteSessionKey } from "openclaw/plugin-sdk/routing";
|
|
31
35
|
import { getSessionEntryAsync, resolveStorePath } from "openclaw/plugin-sdk/session-store-runtime";
|
|
32
36
|
import { KeyedAsyncQueue } from "openclaw/plugin-sdk/keyed-async-queue";
|
|
33
|
-
import { escapeRegExp,
|
|
37
|
+
import { escapeRegExp, truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
|
|
34
38
|
import { buildTtsSupplementMediaPayload, getReplyPayloadTtsSupplement, resolveSendableOutboundReplyParts } from "openclaw/plugin-sdk/reply-payload";
|
|
35
39
|
import { format } from "node:util";
|
|
36
40
|
import { resolvePinnedMainDmOwnerFromAllowlist } from "openclaw/plugin-sdk/security-runtime";
|
|
@@ -65,14 +69,13 @@ function registerMatrixAutoJoin(params) {
|
|
|
65
69
|
const allowedAliases = rawAllowlist.filter((entry) => entry.startsWith("#"));
|
|
66
70
|
const resolvedAliasRoomIds = /* @__PURE__ */ new Map();
|
|
67
71
|
if (autoJoin === "off") return () => {};
|
|
68
|
-
if (autoJoin === "
|
|
69
|
-
else {
|
|
70
|
-
logVerbose("matrix: auto-join enabled for allowlist invites");
|
|
72
|
+
if (autoJoin === "allowlist") {
|
|
71
73
|
const inertEntries = rawAllowlist.filter((entry) => !isMatrixInviteAutoJoinTarget(entry));
|
|
72
74
|
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
75
|
}
|
|
74
76
|
const resolveAllowedAliasRoomId = async (alias) => {
|
|
75
|
-
|
|
77
|
+
const cached = resolvedAliasRoomIds.get(alias);
|
|
78
|
+
if (cached !== void 0) return cached;
|
|
76
79
|
const resolved = await params.client.resolveRoom(alias);
|
|
77
80
|
if (resolved) resolvedAliasRoomIds.set(alias, resolved);
|
|
78
81
|
return resolved;
|
|
@@ -89,17 +92,23 @@ function registerMatrixAutoJoin(params) {
|
|
|
89
92
|
};
|
|
90
93
|
const onInvite = (roomId, _inviteEvent) => {
|
|
91
94
|
params.runDetachedTask(`auto-join invite handler room=${roomId}`, async () => {
|
|
95
|
+
const monitorSignal = getMatrixMonitorTaskSignal();
|
|
92
96
|
if (autoJoin === "allowlist") {
|
|
93
97
|
const allowedAliasRoomIds = await resolveAllowedAliasRoomIds();
|
|
98
|
+
if (monitorSignal?.aborted) return;
|
|
94
99
|
if (!(autoJoinAllowlist.has("*") || allowedRoomIds.has(roomId) || allowedAliasRoomIds.some((resolvedRoomId) => resolvedRoomId === roomId))) {
|
|
95
100
|
logVerbose(`matrix: invite ignored (not in allowlist) room=${roomId}`);
|
|
96
101
|
return;
|
|
97
102
|
}
|
|
98
103
|
}
|
|
104
|
+
if (monitorSignal?.aborted) return;
|
|
99
105
|
try {
|
|
100
|
-
await client
|
|
106
|
+
await withMatrixSendCurrentness(client, () => {
|
|
107
|
+
monitorSignal?.throwIfAborted();
|
|
108
|
+
}, () => client.joinRoom(roomId));
|
|
101
109
|
logVerbose(`matrix: joined room ${roomId}`);
|
|
102
110
|
} catch (err) {
|
|
111
|
+
if (monitorSignal?.aborted) return;
|
|
103
112
|
runtime.error?.(`matrix: failed to join room ${roomId}: ${String(err)}`);
|
|
104
113
|
}
|
|
105
114
|
});
|
|
@@ -179,7 +188,7 @@ async function resolveMatrixMonitorUserEntries(params) {
|
|
|
179
188
|
resolved: false
|
|
180
189
|
});
|
|
181
190
|
}
|
|
182
|
-
(pending.length === 0 ? [] : await
|
|
191
|
+
(pending.length === 0 ? [] : await resolveMatrixTargets({
|
|
183
192
|
cfg: params.cfg,
|
|
184
193
|
accountId: params.accountId,
|
|
185
194
|
inputs: pending.map((entry) => entry.query),
|
|
@@ -208,7 +217,6 @@ async function resolveMatrixMonitorUserAllowlist(params) {
|
|
|
208
217
|
accountId: params.accountId,
|
|
209
218
|
entries: allowList,
|
|
210
219
|
runtime: params.runtime,
|
|
211
|
-
resolveTargets: params.resolveTargets,
|
|
212
220
|
allowNameMatching
|
|
213
221
|
});
|
|
214
222
|
const canonicalized = canonicalizeAllowlistWithResolvedIds({
|
|
@@ -276,7 +284,6 @@ async function resolveMatrixMonitorLiveUserAllowlist(params) {
|
|
|
276
284
|
accountId: params.accountId,
|
|
277
285
|
entries: pending,
|
|
278
286
|
runtime: params.runtime,
|
|
279
|
-
resolveTargets: params.resolveTargets ?? resolveMatrixTargets,
|
|
280
287
|
allowNameMatching
|
|
281
288
|
});
|
|
282
289
|
const resolvedEntries = filterMatrixAllowlistEntries(canonicalizeAllowlistWithResolvedIds({
|
|
@@ -287,93 +294,90 @@ async function resolveMatrixMonitorLiveUserAllowlist(params) {
|
|
|
287
294
|
for (const entry of resolvedEntries) addEntry(entry);
|
|
288
295
|
return effective;
|
|
289
296
|
}
|
|
290
|
-
async function
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
if (
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
297
|
+
async function resolveMatrixMonitorConfig(params) {
|
|
298
|
+
async function resolveMatrixMonitorRoomsConfig() {
|
|
299
|
+
const sourceRooms = params.roomsConfig;
|
|
300
|
+
if (!sourceRooms || Object.keys(sourceRooms).length === 0) return sourceRooms;
|
|
301
|
+
const mapping = [];
|
|
302
|
+
const unresolved = [];
|
|
303
|
+
const nextRooms = {};
|
|
304
|
+
const allowNameMatching = isMatrixDangerousNameMatchingEnabled({
|
|
305
|
+
cfg: params.cfg,
|
|
306
|
+
accountId: params.accountId
|
|
307
|
+
});
|
|
308
|
+
if (sourceRooms["*"]) nextRooms["*"] = sourceRooms["*"];
|
|
309
|
+
const pending = [];
|
|
310
|
+
for (const [entry, roomConfig] of Object.entries(sourceRooms)) {
|
|
311
|
+
if (entry === "*") continue;
|
|
312
|
+
const input = entry.trim();
|
|
313
|
+
if (!input) continue;
|
|
314
|
+
const cleaned = normalizeMatrixRoomLookupEntry(input);
|
|
315
|
+
if (!cleaned) {
|
|
316
|
+
unresolved.push(entry);
|
|
317
|
+
continue;
|
|
318
|
+
}
|
|
319
|
+
if (isMatrixRoomId(cleaned)) {
|
|
320
|
+
if (!nextRooms[cleaned]) nextRooms[cleaned] = roomConfig;
|
|
321
|
+
if (cleaned !== input) mapping.push(`${input}→${cleaned}`);
|
|
322
|
+
continue;
|
|
323
|
+
}
|
|
324
|
+
if (!cleaned.startsWith("#") && !allowNameMatching) {
|
|
325
|
+
unresolved.push(input);
|
|
326
|
+
continue;
|
|
327
|
+
}
|
|
328
|
+
pending.push({
|
|
329
|
+
input,
|
|
330
|
+
query: cleaned,
|
|
331
|
+
config: roomConfig
|
|
332
|
+
});
|
|
319
333
|
}
|
|
320
|
-
pending.
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
334
|
+
if (pending.length > 0) (await resolveMatrixTargets({
|
|
335
|
+
cfg: params.cfg,
|
|
336
|
+
accountId: params.accountId,
|
|
337
|
+
inputs: pending.map((entry) => entry.query),
|
|
338
|
+
kind: "group",
|
|
339
|
+
runtime: params.runtime
|
|
340
|
+
})).forEach((entry, index) => {
|
|
341
|
+
const source = pending[index];
|
|
342
|
+
if (!source) return;
|
|
343
|
+
if (entry.resolved && entry.id) {
|
|
344
|
+
const roomKey = normalizeMatrixRoomLookupEntry(entry.id);
|
|
345
|
+
if (!nextRooms[roomKey]) nextRooms[roomKey] = source.config;
|
|
346
|
+
mapping.push(`${source.input}→${roomKey}`);
|
|
347
|
+
} else unresolved.push(source.input);
|
|
348
|
+
});
|
|
349
|
+
summarizeMapping("matrix rooms", mapping, unresolved, params.runtime);
|
|
350
|
+
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.");
|
|
351
|
+
const roomUsers = /* @__PURE__ */ new Set();
|
|
352
|
+
for (const roomConfig of Object.values(nextRooms)) addAllowlistUserEntriesFromConfigEntry(roomUsers, roomConfig);
|
|
353
|
+
if (roomUsers.size === 0) return nextRooms;
|
|
354
|
+
const resolution = await resolveMatrixMonitorUserEntries({
|
|
355
|
+
cfg: params.cfg,
|
|
356
|
+
accountId: params.accountId,
|
|
357
|
+
entries: Array.from(roomUsers),
|
|
358
|
+
runtime: params.runtime,
|
|
359
|
+
allowNameMatching
|
|
360
|
+
});
|
|
361
|
+
logMatrixAllowlistResolution({
|
|
362
|
+
label: "matrix room users",
|
|
363
|
+
resolution,
|
|
364
|
+
allowNameMatching,
|
|
365
|
+
runtime: params.runtime
|
|
366
|
+
});
|
|
367
|
+
return patchAllowlistUsersInConfigEntries({
|
|
368
|
+
entries: nextRooms,
|
|
369
|
+
resolvedMap: resolution.resolvedMap,
|
|
370
|
+
strategy: "canonicalize",
|
|
371
|
+
entryKey: normalizeMatrixUserId
|
|
324
372
|
});
|
|
325
373
|
}
|
|
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
374
|
const [allowFrom, groupAllowFrom, roomsConfig] = await Promise.all([
|
|
370
375
|
resolveMatrixMonitorUserAllowlist({
|
|
371
376
|
cfg: params.cfg,
|
|
372
377
|
accountId: params.accountId,
|
|
373
378
|
label: "matrix dm allowlist",
|
|
374
379
|
list: params.allowFrom,
|
|
375
|
-
runtime: params.runtime
|
|
376
|
-
resolveTargets
|
|
380
|
+
runtime: params.runtime
|
|
377
381
|
}),
|
|
378
382
|
resolveMatrixMonitorUserAllowlist({
|
|
379
383
|
cfg: params.cfg,
|
|
@@ -381,16 +385,9 @@ async function resolveMatrixMonitorConfig(params) {
|
|
|
381
385
|
label: "matrix group allowlist",
|
|
382
386
|
list: params.groupAllowFrom,
|
|
383
387
|
failClosedOnUnresolved: true,
|
|
384
|
-
runtime: params.runtime
|
|
385
|
-
resolveTargets
|
|
388
|
+
runtime: params.runtime
|
|
386
389
|
}),
|
|
387
|
-
resolveMatrixMonitorRoomsConfig(
|
|
388
|
-
cfg: params.cfg,
|
|
389
|
-
accountId: params.accountId,
|
|
390
|
-
roomsConfig: params.roomsConfig,
|
|
391
|
-
runtime: params.runtime,
|
|
392
|
-
resolveTargets
|
|
393
|
-
})
|
|
390
|
+
resolveMatrixMonitorRoomsConfig()
|
|
394
391
|
]);
|
|
395
392
|
return {
|
|
396
393
|
allowFrom: allowFrom.entries,
|
|
@@ -410,20 +407,10 @@ function createDirectRoomTracker(client, opts = {}) {
|
|
|
410
407
|
const log = opts.log ?? (() => {});
|
|
411
408
|
let lastDmUpdateMs = 0;
|
|
412
409
|
let hasSeededDmCache = false;
|
|
413
|
-
let cachedSelfUserId = null;
|
|
414
410
|
const joinedMembersCache = /* @__PURE__ */ new Map();
|
|
415
411
|
const directMemberFlagCache = /* @__PURE__ */ new Map();
|
|
416
412
|
const recentInviteCandidates = /* @__PURE__ */ new Map();
|
|
417
413
|
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
414
|
const refreshDmCache = async () => {
|
|
428
415
|
const now = Date.now();
|
|
429
416
|
if (now - lastDmUpdateMs < DM_CACHE_TTL_MS) return;
|
|
@@ -530,12 +517,11 @@ function createDirectRoomTracker(client, opts = {}) {
|
|
|
530
517
|
log(`matrix: remembered invite candidate room=${roomId} sender=${normalizedRemoteUserId}`);
|
|
531
518
|
},
|
|
532
519
|
isDirectMessage: async (params) => {
|
|
533
|
-
const { roomId, senderId } = params;
|
|
520
|
+
const { roomId, senderId, selfUserId } = params;
|
|
534
521
|
if (await checkRoomPolicy("isExplicitlyConfiguredRoom", roomId)) {
|
|
535
522
|
log(`matrix: dm rejected via explicit room config room=${roomId}`);
|
|
536
523
|
return false;
|
|
537
524
|
}
|
|
538
|
-
const selfUserId = params.selfUserId ?? await ensureSelfUserId();
|
|
539
525
|
const joinedMembers = params.joinedMembers ?? await resolveJoinedMembers(roomId);
|
|
540
526
|
const strictDirectMembership = isStrictDirectMembership({
|
|
541
527
|
selfUserId,
|
|
@@ -579,12 +565,12 @@ function createDirectRoomTracker(client, opts = {}) {
|
|
|
579
565
|
const promoteDirectRoom = async (source) => {
|
|
580
566
|
const promotion = await promoteMatrixDirectRoomCandidate({
|
|
581
567
|
client,
|
|
582
|
-
remoteUserId: senderId
|
|
568
|
+
remoteUserId: senderId,
|
|
583
569
|
roomId,
|
|
584
570
|
selfUserId
|
|
585
571
|
});
|
|
586
572
|
if (promotion.classifyAsDirect) {
|
|
587
|
-
rememberLocallyPromotedDirectRoom(roomId, senderId
|
|
573
|
+
rememberLocallyPromotedDirectRoom(roomId, senderId);
|
|
588
574
|
log(`matrix: dm detected via ${source} room=${roomId} reason=${promotion.reason} repaired=${String(promotion.repaired)}`);
|
|
589
575
|
}
|
|
590
576
|
return promotion.classifyAsDirect;
|
|
@@ -603,6 +589,7 @@ const EventType = {
|
|
|
603
589
|
RoomMessage: "m.room.message",
|
|
604
590
|
RoomMessageEncrypted: "m.room.encrypted",
|
|
605
591
|
RoomMember: "m.room.member",
|
|
592
|
+
RoomName: "m.room.name",
|
|
606
593
|
Location: "m.location",
|
|
607
594
|
Reaction: MATRIX_REACTION_EVENT_TYPE
|
|
608
595
|
};
|
|
@@ -616,7 +603,7 @@ const matrixIngressIdentity = defineStableChannelIngressIdentity({
|
|
|
616
603
|
normalize: normalizeMatrixEntry,
|
|
617
604
|
matchEntry({ subject, entry }) {
|
|
618
605
|
const senderId = subject.identifiers[0]?.value;
|
|
619
|
-
return
|
|
606
|
+
return resolveMatrixAllowListMatch({
|
|
620
607
|
allowList: [entry.value],
|
|
621
608
|
userId: senderId ?? ""
|
|
622
609
|
}).allowed;
|
|
@@ -705,7 +692,7 @@ async function resolveMatrixMonitorCommandAccess(state, params) {
|
|
|
705
692
|
allowFrom: commandAllowFrom,
|
|
706
693
|
groupAllowFrom: commandGroupAllowFrom,
|
|
707
694
|
command: {
|
|
708
|
-
useAccessGroups:
|
|
695
|
+
useAccessGroups: true,
|
|
709
696
|
allowTextCommands: params.allowTextCommands,
|
|
710
697
|
hasControlCommand: params.hasControlCommand,
|
|
711
698
|
groupOwnerAllowFrom: "none",
|
|
@@ -747,7 +734,7 @@ const matrixVerificationConstants = {
|
|
|
747
734
|
const MAX_TRACKED_VERIFICATION_EVENTS = 1024;
|
|
748
735
|
const SAS_NOTICE_RETRY_DELAY_MS = 750;
|
|
749
736
|
const VERIFICATION_EVENT_STARTUP_GRACE_MS = 3e4;
|
|
750
|
-
const loadMatrixDirectRoomDeps = createLazyRuntimeModule(() => Promise.all([import("./direct-management-
|
|
737
|
+
const loadMatrixDirectRoomDeps = createLazyRuntimeModule(() => Promise.all([import("./direct-management-Dp1giZ34.mjs").then((n) => n.t), import("./direct-management-Dp1giZ34.mjs").then((n) => n.o)]).then(([directManagementModule, directRoomModule]) => ({
|
|
751
738
|
inspectMatrixDirectRooms: directManagementModule.inspectMatrixDirectRooms,
|
|
752
739
|
isStrictDirectRoom: directRoomModule.isStrictDirectRoom
|
|
753
740
|
})));
|
|
@@ -809,8 +796,8 @@ function formatVerificationStageNotice(params) {
|
|
|
809
796
|
function formatVerificationSasNotice(summary) {
|
|
810
797
|
const sas = summary.sas;
|
|
811
798
|
if (!sas) return null;
|
|
812
|
-
const emojiLine =
|
|
813
|
-
const decimalLine =
|
|
799
|
+
const emojiLine = sas.emoji?.length ? `SAS emoji: ${sas.emoji.map(([emoji, name]) => `${normalizeNullableString(emoji) ?? "?"} ${normalizeNullableString(name) ?? "?"}`).join(" | ")}` : null;
|
|
800
|
+
const decimalLine = sas.decimal ? `SAS decimal: ${sas.decimal.join(" ")}` : null;
|
|
814
801
|
if (!emojiLine && !decimalLine) return null;
|
|
815
802
|
const lines = [`Matrix verification SAS with ${summary.otherUserId}:`];
|
|
816
803
|
if (emojiLine) lines.push(emojiLine);
|
|
@@ -828,65 +815,18 @@ function resolveVerificationFlowCandidates(params) {
|
|
|
828
815
|
content["m.relates_to"]?.event_id
|
|
829
816
|
]);
|
|
830
817
|
}
|
|
831
|
-
function resolveSummaryRecency(summary) {
|
|
832
|
-
const ts = Date.parse(summary.updatedAt ?? "");
|
|
833
|
-
return Number.isFinite(ts) ? ts : 0;
|
|
834
|
-
}
|
|
835
818
|
function isActiveVerificationSummary(summary) {
|
|
836
819
|
if (summary.completed) return false;
|
|
837
820
|
if (summary.phaseName === "cancelled" || summary.phaseName === "done") return false;
|
|
838
|
-
if (
|
|
821
|
+
if (summary.phase >= 4) return false;
|
|
839
822
|
return true;
|
|
840
823
|
}
|
|
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
824
|
function trackBounded(set, value) {
|
|
885
825
|
if (!value || set.has(value)) return false;
|
|
886
826
|
set.add(value);
|
|
887
827
|
if (set.size > MAX_TRACKED_VERIFICATION_EVENTS) {
|
|
888
828
|
const oldest = set.values().next().value;
|
|
889
|
-
if (
|
|
829
|
+
if (oldest !== void 0) set.delete(oldest);
|
|
890
830
|
}
|
|
891
831
|
return true;
|
|
892
832
|
}
|
|
@@ -1012,14 +952,51 @@ function createMatrixVerificationEventRouter(params) {
|
|
|
1012
952
|
senderId,
|
|
1013
953
|
event
|
|
1014
954
|
});
|
|
1015
|
-
const {
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
955
|
+
const { client, sasNoticeRetryDelayMs } = params;
|
|
956
|
+
const resolveSummary = async () => {
|
|
957
|
+
if (!client.crypto) return null;
|
|
958
|
+
await client.crypto.ensureVerificationDmTracked({
|
|
959
|
+
roomId,
|
|
960
|
+
userId: senderId
|
|
961
|
+
}).catch(() => null);
|
|
962
|
+
const list = await client.crypto.listVerifications();
|
|
963
|
+
if (list.length === 0) return null;
|
|
964
|
+
const candidates = resolveVerificationFlowCandidates({
|
|
965
|
+
event,
|
|
966
|
+
flowId
|
|
967
|
+
});
|
|
968
|
+
const byTransactionId = list.find((entry) => candidates.some((candidate) => entry.transactionId === candidate));
|
|
969
|
+
if (byTransactionId) return byTransactionId;
|
|
970
|
+
const { inspectMatrixDirectRooms, isStrictDirectRoom } = await loadMatrixDirectRoomDeps();
|
|
971
|
+
const inspection = await inspectMatrixDirectRooms({
|
|
972
|
+
client,
|
|
973
|
+
remoteUserId: senderId
|
|
974
|
+
}).catch(() => null);
|
|
975
|
+
const activeRoomId = normalizeNullableString(inspection?.activeRoomId);
|
|
976
|
+
if (activeRoomId) {
|
|
977
|
+
if (activeRoomId !== roomId) return null;
|
|
978
|
+
} else if (!await isStrictDirectRoom({
|
|
979
|
+
client,
|
|
980
|
+
roomId,
|
|
981
|
+
remoteUserId: senderId
|
|
982
|
+
})) return null;
|
|
983
|
+
const activeByUser = list.filter((entry) => entry.otherUserId === senderId && isActiveVerificationSummary(entry));
|
|
984
|
+
return activeByUser.find((entry) => normalizeNullableString(entry.roomId) === roomId) ?? activeByUser[0] ?? null;
|
|
985
|
+
};
|
|
986
|
+
const resolveSasNotice = async () => {
|
|
987
|
+
for (let attempt = 0;; attempt += 1) {
|
|
988
|
+
const summary = await resolveSummary();
|
|
989
|
+
const sasNotice = summary && isActiveVerificationSummary(summary) ? formatVerificationSasNotice(summary) : null;
|
|
990
|
+
if (sasNotice || attempt > 0 || signal.stage !== "ready" && signal.stage !== "start") return {
|
|
991
|
+
summary,
|
|
992
|
+
sasNotice
|
|
993
|
+
};
|
|
994
|
+
await new Promise((resolve) => {
|
|
995
|
+
setTimeout(resolve, sasNoticeRetryDelayMs ?? SAS_NOTICE_RETRY_DELAY_MS);
|
|
996
|
+
});
|
|
997
|
+
}
|
|
998
|
+
};
|
|
999
|
+
const { summary, sasNotice } = await resolveSasNotice().catch(() => ({
|
|
1023
1000
|
summary: null,
|
|
1024
1001
|
sasNotice: null
|
|
1025
1002
|
}));
|
|
@@ -1034,10 +1011,7 @@ function createMatrixVerificationEventRouter(params) {
|
|
|
1034
1011
|
}
|
|
1035
1012
|
for (const body of notices) await sendVerificationNotice(roomId, body);
|
|
1036
1013
|
};
|
|
1037
|
-
|
|
1038
|
-
else routeTask().catch((err) => {
|
|
1039
|
-
params.logVerboseMessage(`matrix: failed routing verification event: ${String(err)}`);
|
|
1040
|
-
});
|
|
1014
|
+
params.runDetachedTask(`verification event handler room=${roomId} id=${event.event_id ?? "unknown"}`, routeTask);
|
|
1041
1015
|
return true;
|
|
1042
1016
|
}
|
|
1043
1017
|
return {
|
|
@@ -1053,15 +1027,6 @@ const MATRIX_POST_HEALTHY_SYNC_DECRYPT_FAILURE_SAMPLE_LIMIT = 3;
|
|
|
1053
1027
|
function formatMatrixPostHealthySyncDecryptionHint(accountId) {
|
|
1054
1028
|
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
1029
|
}
|
|
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
1030
|
function createMatrixPostHealthySyncDecryptFailureTracker(params) {
|
|
1066
1031
|
let observations = [];
|
|
1067
1032
|
let warningEmitted = false;
|
|
@@ -1081,11 +1046,12 @@ function createMatrixPostHealthySyncDecryptFailureTracker(params) {
|
|
|
1081
1046
|
trackedHealthySyncSinceMs = healthySyncSinceMs;
|
|
1082
1047
|
resetObservations();
|
|
1083
1048
|
}
|
|
1084
|
-
if (!
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1049
|
+
if (typeof healthySyncSinceMs !== "number" || !Number.isFinite(healthySyncSinceMs)) return {
|
|
1050
|
+
freshAfterHealthySync: false,
|
|
1051
|
+
failureCount: 0
|
|
1052
|
+
};
|
|
1053
|
+
const eventTs = event.origin_server_ts;
|
|
1054
|
+
if (!Number.isFinite(eventTs) || eventTs <= 0 || eventTs < healthySyncSinceMs || eventTs > nowMs + 6e4) return {
|
|
1089
1055
|
freshAfterHealthySync: false,
|
|
1090
1056
|
failureCount: 0
|
|
1091
1057
|
};
|
|
@@ -1128,7 +1094,6 @@ function formatMatrixSelfDecryptionHint(accountId) {
|
|
|
1128
1094
|
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
1095
|
}
|
|
1130
1096
|
async function resolveMatrixSelfUserId(client, logVerboseMessage) {
|
|
1131
|
-
if (typeof client.getUserId !== "function") return null;
|
|
1132
1097
|
try {
|
|
1133
1098
|
return await client.getUserId() ?? null;
|
|
1134
1099
|
} catch (err) {
|
|
@@ -1137,7 +1102,7 @@ async function resolveMatrixSelfUserId(client, logVerboseMessage) {
|
|
|
1137
1102
|
}
|
|
1138
1103
|
}
|
|
1139
1104
|
function registerMatrixMonitorEvents(params) {
|
|
1140
|
-
const { cfg, client, auth, allowFrom, dmEnabled, dmPolicy, readStoreAllowFrom, directTracker, invalidateMemberDisplayName, logVerboseMessage, warnedEncryptedRooms, warnedCryptoMissingRooms, logger, getHealthySyncSinceMs, formatNativeDependencyHint,
|
|
1105
|
+
const { cfg, client, auth, allowFrom, dmEnabled, dmPolicy, readStoreAllowFrom, directTracker, invalidateMemberDisplayName, invalidateRoomName, logVerboseMessage, warnedEncryptedRooms, warnedCryptoMissingRooms, logger, getHealthySyncSinceMs, formatNativeDependencyHint, runDetachedTask, sasNoticeRetryDelayMs } = params;
|
|
1141
1106
|
const postHealthySyncDecryptFailureTracker = createMatrixPostHealthySyncDecryptFailureTracker({ getHealthySyncSinceMs });
|
|
1142
1107
|
const { routeVerificationEvent, routeVerificationSummary } = createMatrixVerificationEventRouter({
|
|
1143
1108
|
client,
|
|
@@ -1149,20 +1114,8 @@ function registerMatrixMonitorEvents(params) {
|
|
|
1149
1114
|
runDetachedTask,
|
|
1150
1115
|
sasNoticeRetryDelayMs
|
|
1151
1116
|
});
|
|
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
1117
|
const onRoomMessageEvent = (roomId, event) => {
|
|
1164
|
-
|
|
1165
|
-
dispatchRoomMessage("room message handler", roomId, event);
|
|
1118
|
+
routeVerificationEvent(roomId, event);
|
|
1166
1119
|
};
|
|
1167
1120
|
const onEncryptedEvent = (roomId, event) => {
|
|
1168
1121
|
const eventId = event?.event_id ?? "unknown";
|
|
@@ -1173,12 +1126,10 @@ function registerMatrixMonitorEvents(params) {
|
|
|
1173
1126
|
const eventId = event?.event_id ?? "unknown";
|
|
1174
1127
|
const eventType = event?.type ?? "unknown";
|
|
1175
1128
|
logVerboseMessage(`matrix: decrypted event room=${roomId} type=${eventType} id=${eventId}`);
|
|
1176
|
-
|
|
1177
|
-
if (eventType !== EventType.RoomMessage) return;
|
|
1178
|
-
dispatchRoomMessage("decrypted room message handler", roomId, event);
|
|
1129
|
+
routeVerificationEvent(roomId, event);
|
|
1179
1130
|
};
|
|
1180
1131
|
const onFailedDecryption = (roomId, event, error) => {
|
|
1181
|
-
|
|
1132
|
+
runDetachedTask(`failed decryption handler room=${roomId} id=${event.event_id ?? "unknown"}`, async () => {
|
|
1182
1133
|
const failureState = postHealthySyncDecryptFailureTracker.recordFailure(roomId, event, error);
|
|
1183
1134
|
const selfUserId = await resolveMatrixSelfUserId(client, logVerboseMessage);
|
|
1184
1135
|
const sender = typeof event.sender === "string" ? event.sender : null;
|
|
@@ -1213,7 +1164,7 @@ function registerMatrixMonitorEvents(params) {
|
|
|
1213
1164
|
});
|
|
1214
1165
|
};
|
|
1215
1166
|
const onVerificationSummary = (summary) => {
|
|
1216
|
-
|
|
1167
|
+
runDetachedTask("verification summary handler", async () => {
|
|
1217
1168
|
await routeVerificationSummary(summary);
|
|
1218
1169
|
});
|
|
1219
1170
|
};
|
|
@@ -1222,9 +1173,9 @@ function registerMatrixMonitorEvents(params) {
|
|
|
1222
1173
|
const eventId = event?.event_id ?? "unknown";
|
|
1223
1174
|
const sender = event?.sender ?? "unknown";
|
|
1224
1175
|
const invitee = normalizeOptionalString(event?.state_key) ?? "";
|
|
1225
|
-
const senderIsInvitee = Boolean(invitee) && (normalizeOptionalString(event?.sender) ?? "") === invitee;
|
|
1226
|
-
const isDirect = (event?.content)?.is_direct === true;
|
|
1227
1176
|
const rememberedSender = normalizeOptionalString(event?.sender);
|
|
1177
|
+
const senderIsInvitee = Boolean(invitee) && rememberedSender === invitee;
|
|
1178
|
+
const isDirect = (event?.content)?.is_direct === true;
|
|
1228
1179
|
if (rememberedSender && !senderIsInvitee) directTracker?.rememberInvite?.(roomId, rememberedSender);
|
|
1229
1180
|
logVerboseMessage(`matrix: invite room=${roomId} sender=${sender} direct=${String(isDirect)} id=${eventId}`);
|
|
1230
1181
|
};
|
|
@@ -1233,7 +1184,7 @@ function registerMatrixMonitorEvents(params) {
|
|
|
1233
1184
|
const eventId = event?.event_id ?? "unknown";
|
|
1234
1185
|
logVerboseMessage(`matrix: join room=${roomId} id=${eventId}`);
|
|
1235
1186
|
if (event.membershipProvenance !== "transition" || event.state_key !== auth.userId) return;
|
|
1236
|
-
|
|
1187
|
+
runDetachedTask(`join introduction room=${roomId}`, async () => {
|
|
1237
1188
|
const members = await readJoinedMatrixMembers(client, roomId);
|
|
1238
1189
|
const remoteUserId = members?.find((member) => member !== auth.userId);
|
|
1239
1190
|
if (!members?.includes(auth.userId) || !remoteUserId || await directTracker.isDirectMessage({
|
|
@@ -1321,10 +1272,7 @@ function registerMatrixMonitorEvents(params) {
|
|
|
1321
1272
|
if (stateKey) invalidateMemberDisplayName?.(roomId, stateKey);
|
|
1322
1273
|
logVerboseMessage(`matrix: member event room=${roomId} stateKey=${stateKey} membership=${membership ?? "unknown"}`);
|
|
1323
1274
|
}
|
|
1324
|
-
if (eventType === EventType.
|
|
1325
|
-
dispatchRoomMessage("reaction handler", roomId, event);
|
|
1326
|
-
return;
|
|
1327
|
-
}
|
|
1275
|
+
if (eventType === EventType.RoomName) invalidateRoomName?.(roomId);
|
|
1328
1276
|
routeVerificationEvent(roomId, event);
|
|
1329
1277
|
};
|
|
1330
1278
|
client.on("room.message", onRoomMessageEvent);
|
|
@@ -1347,12 +1295,7 @@ function registerMatrixMonitorEvents(params) {
|
|
|
1347
1295
|
};
|
|
1348
1296
|
}
|
|
1349
1297
|
//#endregion
|
|
1350
|
-
//#region extensions/matrix/src/matrix/monitor/context
|
|
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
|
-
}
|
|
1298
|
+
//#region extensions/matrix/src/matrix/monitor/event-context.ts
|
|
1356
1299
|
function summarizeMatrixMessageContextEvent(event) {
|
|
1357
1300
|
if (isPollStartType(event.type)) {
|
|
1358
1301
|
const pollSummary = parsePollStart(event.content);
|
|
@@ -1365,8 +1308,7 @@ function summarizeMatrixMessageContextEvent(event) {
|
|
|
1365
1308
|
msgtype: normalizeOptionalString(content.msgtype)
|
|
1366
1309
|
});
|
|
1367
1310
|
}
|
|
1368
|
-
|
|
1369
|
-
//#region extensions/matrix/src/matrix/monitor/event-context.ts
|
|
1311
|
+
const MAX_CONTEXT_BODY_LENGTH = 500;
|
|
1370
1312
|
function createMatrixEventContextResolver(params) {
|
|
1371
1313
|
const cache = /* @__PURE__ */ new Map();
|
|
1372
1314
|
const isThread = params.kind === "thread";
|
|
@@ -1388,7 +1330,11 @@ function createMatrixEventContextResolver(params) {
|
|
|
1388
1330
|
const context = {};
|
|
1389
1331
|
if (isThread || !event.unsigned?.redacted_because) {
|
|
1390
1332
|
const body = summarizeMatrixMessageContextEvent(event);
|
|
1391
|
-
let summary = body ?
|
|
1333
|
+
let summary = body ? truncateWithMarker(body, MAX_CONTEXT_BODY_LENGTH, {
|
|
1334
|
+
marker: "...",
|
|
1335
|
+
reserve: 3,
|
|
1336
|
+
trimEnd: false
|
|
1337
|
+
}) : void 0;
|
|
1392
1338
|
if (isThread && !summary) {
|
|
1393
1339
|
const msgtype = normalizeOptionalString(event.content.msgtype);
|
|
1394
1340
|
const eventType = normalizeOptionalString(event.type);
|
|
@@ -1440,28 +1386,6 @@ const matrixPreflightAudio = createChannelPreflightAudio({
|
|
|
1440
1386
|
channel: "matrix",
|
|
1441
1387
|
isAudio: isMatrixAudioContent
|
|
1442
1388
|
});
|
|
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
1389
|
//#endregion
|
|
1466
1390
|
//#region extensions/matrix/src/matrix/monitor/handler-helpers.ts
|
|
1467
1391
|
const MATRIX_TOOL_PROGRESS_MAX_CHARS = 300;
|
|
@@ -1480,27 +1404,6 @@ function hasBundledMatrixReplacementRelation(event) {
|
|
|
1480
1404
|
if (!relations || typeof relations !== "object") return false;
|
|
1481
1405
|
return relations[RelationType.Replace] !== void 0;
|
|
1482
1406
|
}
|
|
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
1407
|
function markTrackedRoomIfFirst(set, roomId) {
|
|
1505
1408
|
if (set.has(roomId)) return false;
|
|
1506
1409
|
set.add(roomId);
|
|
@@ -1574,11 +1477,11 @@ function formatMatrixToolProgressMarkdownCode(text) {
|
|
|
1574
1477
|
}
|
|
1575
1478
|
//#endregion
|
|
1576
1479
|
//#region extensions/matrix/src/matrix/monitor/handler-runtime.ts
|
|
1577
|
-
const loadMatrixSendModule = createLazyRuntimeModule(() => import("./send-
|
|
1480
|
+
const loadMatrixSendModule = createLazyRuntimeModule(() => import("./send-HHAbKARg.mjs").then((n) => n.s));
|
|
1578
1481
|
const loadAcpBindingRuntime = createLazyRuntimeModule(() => import("openclaw/plugin-sdk/acp-binding-runtime"));
|
|
1579
1482
|
const loadSessionBindingRuntime = createLazyRuntimeModule(() => import("openclaw/plugin-sdk/session-binding-runtime"));
|
|
1580
|
-
const loadMatrixReactionEvents = createLazyRuntimeModule(() => import("./reaction-events-
|
|
1581
|
-
const loadMatrixDraftStream = createLazyRuntimeModule(() => import("./draft-stream-
|
|
1483
|
+
const loadMatrixReactionEvents = createLazyRuntimeModule(() => import("./reaction-events-UA_g6jEX.mjs"));
|
|
1484
|
+
const loadMatrixDraftStream = createLazyRuntimeModule(() => import("./draft-stream-BPjjKSoI.mjs"));
|
|
1582
1485
|
async function matrixTextWouldActivateMentions(client, text) {
|
|
1583
1486
|
const { resolveMatrixMentionsForBody } = await loadMatrixSendModule();
|
|
1584
1487
|
const mentions = await resolveMatrixMentionsForBody({
|
|
@@ -1591,7 +1494,7 @@ async function matrixTextWouldActivateMentions(client, text) {
|
|
|
1591
1494
|
//#region extensions/matrix/src/matrix/monitor/handler-context.ts
|
|
1592
1495
|
async function resolveMatrixInboundContext(config) {
|
|
1593
1496
|
const { handler, ingress, roomId, event, eventTs, resolveThreadContext, resolveReplyContext, senderId, sharedDmContextNoticeRooms } = config;
|
|
1594
|
-
const { client, core, accountId, runtime, logVerboseMessage, groupPolicy, getRoomInfo, historyLimit, dmSessionScope
|
|
1497
|
+
const { client, core, accountId, runtime, logVerboseMessage, groupPolicy, getRoomInfo, historyLimit, dmSessionScope } = handler;
|
|
1595
1498
|
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
1499
|
const contextVisibilityMode = resolveChannelContextVisibilityMode({
|
|
1597
1500
|
cfg,
|
|
@@ -1612,16 +1515,16 @@ async function resolveMatrixInboundContext(config) {
|
|
|
1612
1515
|
}).allowed;
|
|
1613
1516
|
return true;
|
|
1614
1517
|
};
|
|
1615
|
-
const shouldIncludeRoomContextSender = (
|
|
1518
|
+
const shouldIncludeRoomContextSender = (contextSenderId) => evaluateSupplementalContextVisibility({
|
|
1616
1519
|
mode: contextVisibilityMode,
|
|
1617
|
-
kind,
|
|
1520
|
+
kind: "thread",
|
|
1618
1521
|
senderAllowed: isRoomContextSenderAllowed(contextSenderId)
|
|
1619
1522
|
}).include;
|
|
1620
1523
|
let threadContext = ingress.threadContext ?? (threadRootId ? await resolveThreadContext({
|
|
1621
1524
|
roomId,
|
|
1622
1525
|
eventId: threadRootId
|
|
1623
1526
|
}) : void 0);
|
|
1624
|
-
if (threadContext?.senderId && !shouldIncludeRoomContextSender(
|
|
1527
|
+
if (threadContext?.senderId && !shouldIncludeRoomContextSender(threadContext.senderId)) {
|
|
1625
1528
|
logVerboseMessage(`matrix: drop thread root context (mode=${contextVisibilityMode})`);
|
|
1626
1529
|
threadContext = void 0;
|
|
1627
1530
|
}
|
|
@@ -1636,11 +1539,11 @@ async function resolveMatrixInboundContext(config) {
|
|
|
1636
1539
|
eventId: replyToEventId
|
|
1637
1540
|
}) : void 0;
|
|
1638
1541
|
const replySenderAllowed = !replyContext?.senderId || isRoomContextSenderAllowed(replyContext.senderId);
|
|
1639
|
-
const roomName = (isRoom ? await getRoomInfo(roomId) : void 0)?.name;
|
|
1542
|
+
const roomName = (isRoom ? await getRoomInfo(roomId, { currentName: true }) : void 0)?.name;
|
|
1640
1543
|
const envelopeFrom = isDirectMessage ? senderName : roomName ?? roomId;
|
|
1641
1544
|
const textWithId = `${bodyText}\n[matrix event id: ${messageId} room: ${roomId}]`;
|
|
1642
|
-
const storePath =
|
|
1643
|
-
const buildEnvelope = await
|
|
1545
|
+
const storePath = resolveStorePath(cfg.session?.store, { agentId: _route.agentId });
|
|
1546
|
+
const buildEnvelope = await createChannelInboundEnvelopeBuilderAsync({
|
|
1644
1547
|
cfg,
|
|
1645
1548
|
route: _route
|
|
1646
1549
|
});
|
|
@@ -1681,7 +1584,6 @@ async function resolveMatrixInboundContext(config) {
|
|
|
1681
1584
|
channelIngress,
|
|
1682
1585
|
channel: "matrix",
|
|
1683
1586
|
contextVisibility: contextVisibilityMode,
|
|
1684
|
-
finalize: finalizeInboundContext,
|
|
1685
1587
|
supplemental: {
|
|
1686
1588
|
quote: replyContext ? {
|
|
1687
1589
|
id: threadTarget ? void 0 : replyToEventId ?? void 0,
|
|
@@ -1719,7 +1621,8 @@ async function resolveMatrixInboundContext(config) {
|
|
|
1719
1621
|
route: {
|
|
1720
1622
|
..._route,
|
|
1721
1623
|
routeSessionKey: _route.sessionKey,
|
|
1722
|
-
parentSessionKey:
|
|
1624
|
+
parentSessionKey: void 0,
|
|
1625
|
+
modelParentSessionKey: threadTarget && _route.matchedBy !== "binding.channel" ? _route.mainSessionKey : void 0
|
|
1723
1626
|
},
|
|
1724
1627
|
reply: {
|
|
1725
1628
|
to: `room:${roomId}`,
|
|
@@ -1754,7 +1657,7 @@ async function resolveMatrixInboundContext(config) {
|
|
|
1754
1657
|
}
|
|
1755
1658
|
});
|
|
1756
1659
|
if (quoteHidden) logVerboseMessage(`matrix: drop reply context (mode=${contextVisibilityMode})`);
|
|
1757
|
-
logVerboseMessage(`matrix inbound: room=${roomId} from=${senderId}
|
|
1660
|
+
logVerboseMessage(`matrix inbound: room=${roomId} from=${senderId} chars=${bodyText.length}`);
|
|
1758
1661
|
const replyTarget = ctxPayload.To;
|
|
1759
1662
|
if (!replyTarget) {
|
|
1760
1663
|
runtime.error?.("matrix: missing reply target");
|
|
@@ -1811,7 +1714,6 @@ async function createMatrixDraftController(params) {
|
|
|
1811
1714
|
let currentDraftMessageGeneration = 0;
|
|
1812
1715
|
let currentDraftBlockOffset = 0;
|
|
1813
1716
|
let latestDraftFullText = "";
|
|
1814
|
-
const pendingDraftBoundaries = [];
|
|
1815
1717
|
let currentDraftReplyToId = draftReplyToId;
|
|
1816
1718
|
const progressConfigEntry = accountConfig ?? cfg.channels?.matrix;
|
|
1817
1719
|
const progressSeed = `${accountId}:${roomId}`;
|
|
@@ -1863,26 +1765,17 @@ async function createMatrixDraftController(params) {
|
|
|
1863
1765
|
};
|
|
1864
1766
|
};
|
|
1865
1767
|
const updateDraftFromLatestFullText = () => {
|
|
1866
|
-
const
|
|
1867
|
-
const blockText = latestDraftFullText.slice(currentDraftBlockOffset, nextDraftBoundaryOffset);
|
|
1768
|
+
const blockText = latestDraftFullText.slice(currentDraftBlockOffset);
|
|
1868
1769
|
if (blockText) draftStream?.update(blockText);
|
|
1869
1770
|
};
|
|
1870
|
-
const
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
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;
|
|
1771
|
+
const captureDraftBlockBoundary = (text, info) => ({
|
|
1772
|
+
messageGeneration: info.assistantMessageIndex ?? currentDraftMessageGeneration,
|
|
1773
|
+
previewMessageGeneration: currentDraftMessageGeneration,
|
|
1774
|
+
previewEndOffset: latestDraftFullText.length,
|
|
1775
|
+
endOffset: info.blockSourceRange?.[1] ?? currentDraftBlockOffset + (text?.length ?? 0)
|
|
1776
|
+
});
|
|
1777
|
+
const advanceDraftBlockBoundary = (boundary) => {
|
|
1778
|
+
if (boundary.messageGeneration === currentDraftMessageGeneration) currentDraftBlockOffset = Math.max(currentDraftBlockOffset, boundary.endOffset);
|
|
1886
1779
|
};
|
|
1887
1780
|
const resetDraftBlockOffsets = () => {
|
|
1888
1781
|
currentDraftMessageGeneration += 1;
|
|
@@ -1896,7 +1789,6 @@ async function createMatrixDraftController(params) {
|
|
|
1896
1789
|
currentDraftMessageGeneration = 0;
|
|
1897
1790
|
currentDraftBlockOffset = 0;
|
|
1898
1791
|
latestDraftFullText = "";
|
|
1899
|
-
pendingDraftBoundaries.length = 0;
|
|
1900
1792
|
currentDraftReplyToId = draftReplyToId;
|
|
1901
1793
|
progressDraft.beginNewTurn({ force: true });
|
|
1902
1794
|
};
|
|
@@ -1905,7 +1797,7 @@ async function createMatrixDraftController(params) {
|
|
|
1905
1797
|
previewLifecycle,
|
|
1906
1798
|
cancelProgressDraft: () => progressDraft.cancel(),
|
|
1907
1799
|
buildPreviewToolProgressReplyOptions,
|
|
1908
|
-
|
|
1800
|
+
captureDraftBlockBoundary,
|
|
1909
1801
|
advanceDraftBlockBoundary,
|
|
1910
1802
|
resetDraftBlockOffsets,
|
|
1911
1803
|
beginAssistantMessage: () => progressDraft.beginAssistantMessage(),
|
|
@@ -2021,7 +1913,7 @@ function createRoomHistoryTracker(maxQueueSize = DEFAULT_MAX_QUEUE_SIZE, maxRoom
|
|
|
2021
1913
|
}
|
|
2022
1914
|
function rememberWatermark(key, snapshotIdx) {
|
|
2023
1915
|
const nextSnapshotIdx = Math.max(agentWatermarks.get(key) ?? 0, snapshotIdx);
|
|
2024
|
-
|
|
1916
|
+
agentWatermarks.delete(key);
|
|
2025
1917
|
setBoundedMap(agentWatermarks, key, nextSnapshotIdx, maxWatermarkEntries);
|
|
2026
1918
|
}
|
|
2027
1919
|
function markConsumedAfterReservedGap(queue, key, firstReservedRel, snapshotIdx) {
|
|
@@ -2034,19 +1926,10 @@ function createRoomHistoryTracker(maxQueueSize = DEFAULT_MAX_QUEUE_SIZE, maxRoom
|
|
|
2034
1926
|
}
|
|
2035
1927
|
}
|
|
2036
1928
|
function rememberPreparedTrigger(queue, retryKey, prepared) {
|
|
2037
|
-
|
|
1929
|
+
queue.preparedTriggers.delete(retryKey);
|
|
2038
1930
|
setBoundedMap(queue.preparedTriggers, retryKey, prepared, maxPreparedTriggerEntries);
|
|
2039
1931
|
return prepared;
|
|
2040
1932
|
}
|
|
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
1933
|
function prepareTrigger(agentId, roomId, limit, entry, threadRootId, reservedSlot) {
|
|
2051
1934
|
let slot = reservedSlot;
|
|
2052
1935
|
const queue = getScopedQueue(roomId, threadRootId);
|
|
@@ -2063,8 +1946,20 @@ function createRoomHistoryTracker(maxQueueSize = DEFAULT_MAX_QUEUE_SIZE, maxRoom
|
|
|
2063
1946
|
}
|
|
2064
1947
|
}
|
|
2065
1948
|
if (slot) queue.entries[slot.slotIdx - queue.baseIndex] = entry;
|
|
1949
|
+
const requestedEndAbsExclusive = slot?.slotIdx;
|
|
1950
|
+
const startAbsOverride = slot?.watermarkIdx;
|
|
1951
|
+
const endAbsExclusive = requestedEndAbsExclusive ?? queue.baseIndex + queue.entries.length;
|
|
1952
|
+
let history = [];
|
|
1953
|
+
if (!(limit <= 0 || queue.entries.length === 0)) {
|
|
1954
|
+
const key = wmKey(agentId, roomId, threadRootId);
|
|
1955
|
+
const wm = startAbsOverride ?? agentWatermarks.get(key) ?? 0;
|
|
1956
|
+
const startRel = Math.max(wm, queue.baseIndex) - queue.baseIndex;
|
|
1957
|
+
const endRel = Math.max(startRel, Math.min(endAbsExclusive - queue.baseIndex, queue.entries.length));
|
|
1958
|
+
const available = queue.entries.slice(startRel, endRel).filter((queued) => !queued.discarded && !queued.reserved && !queued.consumedBy?.has(key));
|
|
1959
|
+
history = available.length > limit ? available.slice(-limit) : available;
|
|
1960
|
+
}
|
|
2066
1961
|
const prepared = {
|
|
2067
|
-
history
|
|
1962
|
+
history,
|
|
2068
1963
|
...slot ? { snapshotIdx: slot.slotIdx + 1 } : appendToQueue(queue, entry)
|
|
2069
1964
|
};
|
|
2070
1965
|
if (retryKey) return rememberPreparedTrigger(queue, retryKey, prepared);
|
|
@@ -2121,7 +2016,7 @@ function createRoomHistoryTracker(maxQueueSize = DEFAULT_MAX_QUEUE_SIZE, maxRoom
|
|
|
2121
2016
|
//#endregion
|
|
2122
2017
|
//#region extensions/matrix/src/matrix/monitor/handler-ingress-access.ts
|
|
2123
2018
|
async function resolveMatrixIngressAccess(config) {
|
|
2124
|
-
const { handler, params: paramsLocal, roomId, event, eventTs, senderId, isReactionEvent, readStoreAllowFrom, shouldSendPairingReply, resolveLiveAccountAllowlists, roomHistoryTracker
|
|
2019
|
+
const { handler, params: paramsLocal, roomId, event, eventTs, senderId, isReactionEvent, readStoreAllowFrom, shouldSendPairingReply, resolveLiveAccountAllowlists, roomHistoryTracker } = config;
|
|
2125
2020
|
const { core, cfg, accountId, accountConfig, client, logVerboseMessage, groupPolicy, dmEnabled, dmPolicy, dmThreadReplies, threadReplies, roomsConfig, accountAllowBots, configuredBotUserIds, needsRoomAliasesForConfig, getRoomInfo, getMemberDisplayName } = handler;
|
|
2126
2021
|
const content = paramsLocal.content;
|
|
2127
2022
|
const isDirectMessage = paramsLocal.isDirectMessage;
|
|
@@ -2147,12 +2042,8 @@ async function resolveMatrixIngressAccess(config) {
|
|
|
2147
2042
|
const markReservedHistorySlotConsumed = () => {
|
|
2148
2043
|
reservedHistorySlotConsumed = true;
|
|
2149
2044
|
};
|
|
2150
|
-
const commitInboundEventIfClaimedAndDiscardReserved = async () => {
|
|
2151
|
-
discardReservedHistorySlot();
|
|
2152
|
-
await commitInboundEventIfClaimed();
|
|
2153
|
-
};
|
|
2154
2045
|
if (isRoom && groupPolicy === "disabled") {
|
|
2155
|
-
|
|
2046
|
+
discardReservedHistorySlot();
|
|
2156
2047
|
return;
|
|
2157
2048
|
}
|
|
2158
2049
|
const roomInfoForConfig = isRoom && needsRoomAliasesForConfig ? await getRoomInfo(roomId, { includeAliases: true }) : void 0;
|
|
@@ -2168,7 +2059,7 @@ async function resolveMatrixIngressAccess(config) {
|
|
|
2168
2059
|
const roomMatchMeta = roomConfigInfo ? `matchKey=${roomConfigInfo.matchKey ?? "none"} matchSource=${roomConfigInfo.matchSource ?? "none"}` : "matchKey=none matchSource=none";
|
|
2169
2060
|
if (isConfiguredBotSender && allowBotsMode === "off") {
|
|
2170
2061
|
logVerboseMessage(`matrix: drop configured bot sender=${senderId} (allowBots=false${isDirectMessage ? "" : `, ${roomMatchMeta}`})`);
|
|
2171
|
-
|
|
2062
|
+
discardReservedHistorySlot();
|
|
2172
2063
|
return;
|
|
2173
2064
|
}
|
|
2174
2065
|
const botLoopProtection = isConfiguredBotSender && senderId !== selfUserId ? {
|
|
@@ -2183,18 +2074,18 @@ async function resolveMatrixIngressAccess(config) {
|
|
|
2183
2074
|
} : void 0;
|
|
2184
2075
|
if (isRoom && roomConfig && !roomConfigInfo?.allowed) {
|
|
2185
2076
|
logVerboseMessage(`matrix: room disabled room=${roomId} (${roomMatchMeta})`);
|
|
2186
|
-
|
|
2077
|
+
discardReservedHistorySlot();
|
|
2187
2078
|
return;
|
|
2188
2079
|
}
|
|
2189
2080
|
if (isRoom && groupPolicy === "allowlist") {
|
|
2190
2081
|
if (!roomConfigInfo?.allowlistConfigured) {
|
|
2191
2082
|
logVerboseMessage(`matrix: drop room message (no allowlist, ${roomMatchMeta})`);
|
|
2192
|
-
|
|
2083
|
+
discardReservedHistorySlot();
|
|
2193
2084
|
return;
|
|
2194
2085
|
}
|
|
2195
2086
|
if (!roomConfig) {
|
|
2196
2087
|
logVerboseMessage(`matrix: drop room message (not in allowlist, ${roomMatchMeta})`);
|
|
2197
|
-
|
|
2088
|
+
discardReservedHistorySlot();
|
|
2198
2089
|
return;
|
|
2199
2090
|
}
|
|
2200
2091
|
}
|
|
@@ -2223,7 +2114,7 @@ async function resolveMatrixIngressAccess(config) {
|
|
|
2223
2114
|
const ingressDecision = messageIngress.ingress;
|
|
2224
2115
|
if (isDirectMessage) {
|
|
2225
2116
|
if (!dmEnabled || dmPolicy === "disabled") {
|
|
2226
|
-
|
|
2117
|
+
discardReservedHistorySlot();
|
|
2227
2118
|
return;
|
|
2228
2119
|
}
|
|
2229
2120
|
const senderReason = messageIngress.senderAccess.reasonCode;
|
|
@@ -2238,7 +2129,7 @@ async function resolveMatrixIngressAccess(config) {
|
|
|
2238
2129
|
});
|
|
2239
2130
|
if (!code) {
|
|
2240
2131
|
logVerboseMessage(`matrix pairing request ignored sender=${senderId} (pending limit reached)`);
|
|
2241
|
-
|
|
2132
|
+
discardReservedHistorySlot();
|
|
2242
2133
|
return;
|
|
2243
2134
|
}
|
|
2244
2135
|
if (shouldSendPairingReply(senderId, created)) {
|
|
@@ -2255,27 +2146,26 @@ async function resolveMatrixIngressAccess(config) {
|
|
|
2255
2146
|
cfg,
|
|
2256
2147
|
accountId
|
|
2257
2148
|
});
|
|
2258
|
-
await commitInboundEventIfClaimed();
|
|
2259
2149
|
} catch (err) {
|
|
2260
2150
|
logVerboseMessage(`matrix pairing reply failed for ${senderId}: ${String(err)}`);
|
|
2261
2151
|
discardReservedHistorySlot();
|
|
2262
|
-
|
|
2152
|
+
throw err;
|
|
2263
2153
|
}
|
|
2264
2154
|
} else {
|
|
2265
2155
|
logVerboseMessage(`matrix pairing reminder suppressed sender=${senderId} (cooldown)`);
|
|
2266
|
-
|
|
2156
|
+
discardReservedHistorySlot();
|
|
2267
2157
|
}
|
|
2268
2158
|
}
|
|
2269
2159
|
if (isReactionEvent || dmPolicy !== "pairing") {
|
|
2270
2160
|
logVerboseMessage(`matrix: blocked ${isReactionEvent ? "reaction" : "dm"} sender ${senderId} (dmPolicy=${dmPolicy}, reason=${senderReason})`);
|
|
2271
|
-
|
|
2161
|
+
discardReservedHistorySlot();
|
|
2272
2162
|
}
|
|
2273
2163
|
return;
|
|
2274
2164
|
}
|
|
2275
2165
|
}
|
|
2276
2166
|
if (isRoom && ingressDecision.decision !== "allow") {
|
|
2277
2167
|
logVerboseMessage(`matrix: blocked sender ${senderId} (ingress=${ingressDecision.reasonCode}, ${roomMatchMeta})`);
|
|
2278
|
-
|
|
2168
|
+
discardReservedHistorySlot();
|
|
2279
2169
|
return;
|
|
2280
2170
|
}
|
|
2281
2171
|
if (isRoom) logVerboseMessage(`matrix: allow room ${roomId} (${roomMatchMeta})`);
|
|
@@ -2295,7 +2185,7 @@ async function resolveMatrixIngressAccess(config) {
|
|
|
2295
2185
|
isDirectMessage,
|
|
2296
2186
|
logVerboseMessage
|
|
2297
2187
|
});
|
|
2298
|
-
|
|
2188
|
+
discardReservedHistorySlot();
|
|
2299
2189
|
return;
|
|
2300
2190
|
}
|
|
2301
2191
|
return {
|
|
@@ -2313,7 +2203,6 @@ async function resolveMatrixIngressAccess(config) {
|
|
|
2313
2203
|
historyThreadId,
|
|
2314
2204
|
discardReservedHistorySlot,
|
|
2315
2205
|
markReservedHistorySlotConsumed,
|
|
2316
|
-
commitInboundEventIfClaimedAndDiscardReserved,
|
|
2317
2206
|
roomConfig,
|
|
2318
2207
|
allowBotsMode,
|
|
2319
2208
|
isConfiguredBotSender,
|
|
@@ -2374,69 +2263,8 @@ function decodeVisibleHtmlEntities(value) {
|
|
|
2374
2263
|
return decoded === "\xA0" ? " " : decoded;
|
|
2375
2264
|
});
|
|
2376
2265
|
}
|
|
2377
|
-
/**
|
|
2378
|
-
* Replaces each `<[^>]+>` with a space. No tag can end after the last `>`, so the
|
|
2379
|
-
* regex only runs on that prefix and an unterminated `<` run stays linear.
|
|
2380
|
-
*/
|
|
2381
|
-
function stripHtmlTags(value) {
|
|
2382
|
-
const end = value.lastIndexOf(">") + 1;
|
|
2383
|
-
return value.slice(0, end).replace(/<[^>]+>/g, " ") + value.slice(end);
|
|
2384
|
-
}
|
|
2385
|
-
/**
|
|
2386
|
-
* `href` and label of each anchor, matching the captures of
|
|
2387
|
-
* `/<a\b[^>]*href=(["'])(https:\/\/matrix\.to\/#[^"']+)\1[^>]*>(.*?)<\/a>/gis`: the last
|
|
2388
|
-
* usable `href=` inside the opening tag wins, the quoted value may contain `>`, and the
|
|
2389
|
-
* label ends at the first `</a>`. Each `<a` start is resolved from precomputed next-`>`,
|
|
2390
|
-
* next-quote and next-`</a>` positions plus a forward-only candidate cursor, so the scan
|
|
2391
|
-
* is linear in the length of sender-controlled HTML.
|
|
2392
|
-
*/
|
|
2393
|
-
function* matrixToAnchors(html) {
|
|
2394
|
-
const length = html.length;
|
|
2395
|
-
const nextGt = new Int32Array(length + 1).fill(length);
|
|
2396
|
-
const nextQuote = new Int32Array(length + 1).fill(length);
|
|
2397
|
-
for (let index = length - 1; index >= 0; index -= 1) {
|
|
2398
|
-
const char = html[index];
|
|
2399
|
-
nextGt[index] = char === ">" ? index : nextGt[index + 1];
|
|
2400
|
-
nextQuote[index] = char === "\"" || char === "'" ? index : nextQuote[index + 1];
|
|
2401
|
-
}
|
|
2402
|
-
const closes = Array.from(html.matchAll(/<\/a>/gi), (match) => match.index);
|
|
2403
|
-
let nextClose = 0;
|
|
2404
|
-
const candidates = [];
|
|
2405
|
-
for (const match of html.matchAll(/href=(["'])https:\/\/matrix\.to\/#/gi)) {
|
|
2406
|
-
const valueStart = match.index + 5 + 1;
|
|
2407
|
-
const restStart = match.index + match[0].length;
|
|
2408
|
-
const valueEnd = nextQuote[restStart];
|
|
2409
|
-
if (valueEnd === restStart || valueEnd === length || html[valueEnd] !== match[1]) continue;
|
|
2410
|
-
const tagEnd = nextGt[valueEnd + 1];
|
|
2411
|
-
if (tagEnd === length) continue;
|
|
2412
|
-
while (nextClose < closes.length && closes[nextClose] <= tagEnd) nextClose += 1;
|
|
2413
|
-
if (nextClose === closes.length) break;
|
|
2414
|
-
candidates.push({
|
|
2415
|
-
start: match.index,
|
|
2416
|
-
href: html.slice(valueStart, valueEnd),
|
|
2417
|
-
labelStart: tagEnd + 1,
|
|
2418
|
-
labelEnd: closes[nextClose]
|
|
2419
|
-
});
|
|
2420
|
-
}
|
|
2421
|
-
let resumeAt = 0;
|
|
2422
|
-
let candidatesBefore = 0;
|
|
2423
|
-
for (const open of html.matchAll(/<a\b/gi)) {
|
|
2424
|
-
if (open.index < resumeAt) continue;
|
|
2425
|
-
const firstStart = open.index + open[0].length;
|
|
2426
|
-
const lastStart = nextGt[firstStart] - 1;
|
|
2427
|
-
while (candidatesBefore < candidates.length && candidates[candidatesBefore].start <= lastStart) candidatesBefore += 1;
|
|
2428
|
-
const candidate = candidates[candidatesBefore - 1];
|
|
2429
|
-
if (candidate && candidate.start >= firstStart) {
|
|
2430
|
-
yield {
|
|
2431
|
-
href: candidate.href,
|
|
2432
|
-
label: html.slice(candidate.labelStart, candidate.labelEnd)
|
|
2433
|
-
};
|
|
2434
|
-
resumeAt = candidate.labelEnd + 4;
|
|
2435
|
-
}
|
|
2436
|
-
}
|
|
2437
|
-
}
|
|
2438
2266
|
function extractVisibleMentionText(value) {
|
|
2439
|
-
return normalizeLowercaseStringOrEmpty(decodeVisibleHtmlEntities(
|
|
2267
|
+
return normalizeLowercaseStringOrEmpty(decodeVisibleHtmlEntities((value ?? "").replace(/<[^>]+>/g, " ").replace(/[\u200b-\u200f\u202a-\u202e\u2060-\u206f]/g, "")).replace(/\s+/g, " "));
|
|
2440
2268
|
}
|
|
2441
2269
|
function resolveMatrixUserLocalpart(userId) {
|
|
2442
2270
|
const trimmed = userId.trim();
|
|
@@ -2450,7 +2278,13 @@ function hasVisibleNativeMatrixUserMention(text, userId) {
|
|
|
2450
2278
|
if (!text || !localpart) return false;
|
|
2451
2279
|
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);
|
|
2452
2280
|
}
|
|
2453
|
-
function
|
|
2281
|
+
function stripMatchedMatrixMentionPrefix(text, source, flags) {
|
|
2282
|
+
const match = text.match(new RegExp(`^\\s*${source}(?:\\s*[:,])?(?:\\s+|$)`, flags));
|
|
2283
|
+
return match ? text.slice(match[0].length).trimStart() : null;
|
|
2284
|
+
}
|
|
2285
|
+
function stripMatrixMentionPrefix(params) {
|
|
2286
|
+
const text = params.text;
|
|
2287
|
+
if (!text) return text;
|
|
2454
2288
|
const candidates = [];
|
|
2455
2289
|
const seen = /* @__PURE__ */ new Set();
|
|
2456
2290
|
const localpart = params.userId ? resolveMatrixUserLocalpart(params.userId) : null;
|
|
@@ -2468,16 +2302,7 @@ function resolveMatrixMentionPrefixCandidates(params) {
|
|
|
2468
2302
|
seen.add(normalized);
|
|
2469
2303
|
candidates.push(trimmed);
|
|
2470
2304
|
}
|
|
2471
|
-
|
|
2472
|
-
}
|
|
2473
|
-
function stripMatchedMatrixMentionPrefix(text, source, flags) {
|
|
2474
|
-
const match = text.match(new RegExp(`^\\s*${source}(?:\\s*[:,])?(?:\\s+|$)`, flags));
|
|
2475
|
-
return match ? text.slice(match[0].length).trimStart() : null;
|
|
2476
|
-
}
|
|
2477
|
-
function stripMatrixMentionPrefix(params) {
|
|
2478
|
-
const text = params.text;
|
|
2479
|
-
if (!text) return text;
|
|
2480
|
-
for (const candidate of resolveMatrixMentionPrefixCandidates(params)) {
|
|
2305
|
+
for (const candidate of candidates) {
|
|
2481
2306
|
const stripped = stripMatchedMatrixMentionPrefix(text, escapeRegExp(candidate), "i");
|
|
2482
2307
|
if (stripped !== null) return stripped;
|
|
2483
2308
|
}
|
|
@@ -2487,58 +2312,52 @@ function stripMatrixMentionPrefix(params) {
|
|
|
2487
2312
|
}
|
|
2488
2313
|
return text;
|
|
2489
2314
|
}
|
|
2490
|
-
function isVisibleMentionLabel(params) {
|
|
2491
|
-
const cleaned = extractVisibleMentionText(params.text);
|
|
2492
|
-
if (!cleaned) return false;
|
|
2493
|
-
if (params.mentionRegexes.some((pattern) => pattern.test(cleaned))) return true;
|
|
2494
|
-
const localpart = resolveMatrixUserLocalpart(params.userId);
|
|
2495
|
-
return [
|
|
2496
|
-
extractVisibleMentionText(params.userId),
|
|
2497
|
-
localpart ? extractVisibleMentionText(localpart) : null,
|
|
2498
|
-
localpart ? extractVisibleMentionText(`@${localpart}`) : null,
|
|
2499
|
-
params.displayName ? extractVisibleMentionText(params.displayName) : null,
|
|
2500
|
-
params.displayName ? extractVisibleMentionText(`@${params.displayName}`) : null,
|
|
2501
|
-
params.displayName ? extractVisibleMentionText(`@[${params.displayName}]`) : null
|
|
2502
|
-
].filter((value) => Boolean(value)).includes(cleaned);
|
|
2503
|
-
}
|
|
2504
2315
|
function hasVisibleRoomMention(value) {
|
|
2505
2316
|
const cleaned = extractVisibleMentionText(value);
|
|
2506
2317
|
return /(^|[^a-z0-9_])@room\b/i.test(cleaned);
|
|
2507
2318
|
}
|
|
2508
|
-
/**
|
|
2509
|
-
* Check if formatted_body contains a matrix.to link whose visible label still
|
|
2510
|
-
* looks like a real mention for the given user. Do not trust href alone, since
|
|
2511
|
-
* senders can hide arbitrary matrix.to links behind unrelated link text.
|
|
2512
|
-
* Many Matrix clients (including Element) use HTML links in formatted_body instead of
|
|
2513
|
-
* or in addition to the m.mentions field.
|
|
2514
|
-
*/
|
|
2515
|
-
function checkFormattedBodyMention(params) {
|
|
2516
|
-
if (!params.formattedBody || !params.userId) return false;
|
|
2517
|
-
for (const { href, label: visibleLabel } of matrixToAnchors(params.formattedBody)) try {
|
|
2518
|
-
const parsed = new URL(href);
|
|
2519
|
-
if (decodeURIComponent(parsed.hash.replace(/^#\/?/, "").trim()) !== params.userId.trim()) continue;
|
|
2520
|
-
if (isVisibleMentionLabel({
|
|
2521
|
-
text: visibleLabel,
|
|
2522
|
-
userId: params.userId,
|
|
2523
|
-
mentionRegexes: params.mentionRegexes,
|
|
2524
|
-
displayName: params.displayName
|
|
2525
|
-
})) return true;
|
|
2526
|
-
} catch {
|
|
2527
|
-
continue;
|
|
2528
|
-
}
|
|
2529
|
-
return false;
|
|
2530
|
-
}
|
|
2531
2319
|
function resolveMentions(params) {
|
|
2532
2320
|
const mentions = params.content["m.mentions"];
|
|
2533
2321
|
const mentionedUsers = Array.isArray(mentions?.user_ids) ? new Set(mentions.user_ids) : /* @__PURE__ */ new Set();
|
|
2534
2322
|
const textMentioned = getMatrixRuntime().channel.mentions.matchesMentionPatterns(params.text ?? "", params.mentionRegexes);
|
|
2535
2323
|
const visibleRoomMention = hasVisibleRoomMention(params.text) || hasVisibleRoomMention(params.content.formatted_body);
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
|
|
2541
|
-
|
|
2324
|
+
/**
|
|
2325
|
+
* Check if formatted_body contains a matrix.to link whose visible label still
|
|
2326
|
+
* looks like a real mention for the given user. Do not trust href alone, since
|
|
2327
|
+
* senders can hide arbitrary matrix.to links behind unrelated link text.
|
|
2328
|
+
* Many Matrix clients (including Element) use HTML links in formatted_body instead of
|
|
2329
|
+
* or in addition to the m.mentions field.
|
|
2330
|
+
*/
|
|
2331
|
+
function checkFormattedBodyMention(userId) {
|
|
2332
|
+
const formattedBody = params.content.formatted_body;
|
|
2333
|
+
const { displayName, mentionRegexes } = params;
|
|
2334
|
+
if (!formattedBody || !userId) return false;
|
|
2335
|
+
for (const match of formattedBody.matchAll(/<a\b[^>]*href=(["'])(https:\/\/matrix\.to\/#[^"']+)\1[^>]*>(.*?)<\/a>/gis)) {
|
|
2336
|
+
const href = match[2];
|
|
2337
|
+
const visibleLabel = match[3] ?? "";
|
|
2338
|
+
if (!href) continue;
|
|
2339
|
+
try {
|
|
2340
|
+
const parsed = new URL(href);
|
|
2341
|
+
if (decodeURIComponent(parsed.hash.replace(/^#\/?/, "").trim()) !== userId.trim()) continue;
|
|
2342
|
+
const cleaned = extractVisibleMentionText(visibleLabel);
|
|
2343
|
+
if (!cleaned) continue;
|
|
2344
|
+
if (mentionRegexes.some((pattern) => pattern.test(cleaned))) return true;
|
|
2345
|
+
const localpart = resolveMatrixUserLocalpart(userId);
|
|
2346
|
+
if ([
|
|
2347
|
+
extractVisibleMentionText(userId),
|
|
2348
|
+
localpart ? extractVisibleMentionText(localpart) : null,
|
|
2349
|
+
localpart ? extractVisibleMentionText(`@${localpart}`) : null,
|
|
2350
|
+
displayName ? extractVisibleMentionText(displayName) : null,
|
|
2351
|
+
displayName ? extractVisibleMentionText(`@${displayName}`) : null,
|
|
2352
|
+
displayName ? extractVisibleMentionText(`@[${displayName}]`) : null
|
|
2353
|
+
].filter((value) => Boolean(value)).includes(cleaned)) return true;
|
|
2354
|
+
} catch {
|
|
2355
|
+
continue;
|
|
2356
|
+
}
|
|
2357
|
+
}
|
|
2358
|
+
return false;
|
|
2359
|
+
}
|
|
2360
|
+
const mentionedInFormattedBody = params.userId ? checkFormattedBodyMention(params.userId) : false;
|
|
2542
2361
|
const metadataBackedUserMention = Boolean(params.userId && mentionedUsers.has(params.userId) && (mentionedInFormattedBody || textMentioned || hasVisibleNativeMatrixUserMention(params.text, params.userId)));
|
|
2543
2362
|
const metadataBackedRoomMention = Boolean(mentions?.room) && visibleRoomMention;
|
|
2544
2363
|
const explicitMention = mentionedInFormattedBody || metadataBackedUserMention || metadataBackedRoomMention;
|
|
@@ -2550,9 +2369,9 @@ function resolveMentions(params) {
|
|
|
2550
2369
|
//#endregion
|
|
2551
2370
|
//#region extensions/matrix/src/matrix/monitor/handler-ingress-content.ts
|
|
2552
2371
|
async function resolveMatrixIngressContent(config) {
|
|
2553
|
-
const { handler, params: paramsLocal, access, roomId, event, eventType, isPollEvent, eventTs, senderId, roomHistoryTracker, resolveThreadContext
|
|
2372
|
+
const { handler, params: paramsLocal, access, roomId, event, eventType, isPollEvent, eventTs, senderId, roomHistoryTracker, resolveThreadContext } = config;
|
|
2554
2373
|
const { client, core, accountId, accountConfig, logger, logVerboseMessage, historyLimit, mediaMaxBytes, dmSessionScope, getMemberDisplayName } = handler;
|
|
2555
|
-
const { cfg, content: accessContent, messageId, audioPreflightMode, isDirectMessage, isRoom, locationPayload, reservedHistorySlot, threadRootId, thread, historyThreadId, discardReservedHistorySlot, markReservedHistorySlotConsumed,
|
|
2374
|
+
const { cfg, content: accessContent, messageId, audioPreflightMode, isDirectMessage, isRoom, locationPayload, reservedHistorySlot, threadRootId, thread, historyThreadId, discardReservedHistorySlot, markReservedHistorySlotConsumed, roomConfig, allowBotsMode, isConfiguredBotSender, selfUserId, roomMatchMeta, getSenderName, accessState } = access;
|
|
2556
2375
|
const { resolveMessageIngress } = accessState;
|
|
2557
2376
|
let content = accessContent;
|
|
2558
2377
|
let pollSnapshotPromise = null;
|
|
@@ -2578,7 +2397,7 @@ async function resolveMatrixIngressContent(config) {
|
|
|
2578
2397
|
});
|
|
2579
2398
|
const pendingHistoryPollText = !pendingHistoryText && isPollEvent && historyLimit > 0 ? (await getPollSnapshot())?.text : "";
|
|
2580
2399
|
if (!mentionPrecheckText && !mediaUrl && !isPollEvent) {
|
|
2581
|
-
|
|
2400
|
+
discardReservedHistorySlot();
|
|
2582
2401
|
return;
|
|
2583
2402
|
}
|
|
2584
2403
|
let preflightMedia = null;
|
|
@@ -2642,16 +2461,23 @@ async function resolveMatrixIngressContent(config) {
|
|
|
2642
2461
|
}
|
|
2643
2462
|
if (shouldRunMatrixAudioPreflight) {
|
|
2644
2463
|
preflightMedia = await downloadMedia(preflightAudioMediaUrl);
|
|
2645
|
-
if (preflightMedia) preflightAudioTranscript = await
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
2464
|
+
if (preflightMedia) preflightAudioTranscript = await matrixPreflightAudio.resolve({ request: {
|
|
2465
|
+
ctx: {
|
|
2466
|
+
media: [{
|
|
2467
|
+
path: preflightMedia.path,
|
|
2468
|
+
contentType: preflightMedia.contentType
|
|
2469
|
+
}],
|
|
2470
|
+
Provider: "matrix",
|
|
2471
|
+
Surface: "matrix",
|
|
2472
|
+
OriginatingChannel: "matrix",
|
|
2473
|
+
OriginatingTo: `room:${roomId}`,
|
|
2474
|
+
AccountId: accountId,
|
|
2475
|
+
MessageThreadId: thread.threadId,
|
|
2476
|
+
ChatType: isDirectMessage ? "direct" : "channel",
|
|
2477
|
+
SessionKey: _route.sessionKey
|
|
2478
|
+
},
|
|
2479
|
+
cfg
|
|
2480
|
+
} });
|
|
2655
2481
|
}
|
|
2656
2482
|
const agentMentionRegexes = core.channel.mentions.buildMentionRegexes(cfg, _route.agentId, {
|
|
2657
2483
|
provider: "matrix",
|
|
@@ -2669,7 +2495,7 @@ async function resolveMatrixIngressContent(config) {
|
|
|
2669
2495
|
});
|
|
2670
2496
|
if (isConfiguredBotSender && allowBotsMode === "mentions" && !isDirectMessage && !wasMentioned) {
|
|
2671
2497
|
logVerboseMessage(`matrix: drop configured bot sender=${senderId} (allowBots=mentions, missing mention, ${roomMatchMeta})`);
|
|
2672
|
-
|
|
2498
|
+
discardReservedHistorySlot();
|
|
2673
2499
|
return;
|
|
2674
2500
|
}
|
|
2675
2501
|
const allowTextCommands = core.channel.commands.shouldHandleTextCommands({
|
|
@@ -2684,7 +2510,6 @@ async function resolveMatrixIngressContent(config) {
|
|
|
2684
2510
|
});
|
|
2685
2511
|
const hasControlCommandInMessage = core.channel.text.hasControlCommand(commandCheckText, cfg);
|
|
2686
2512
|
const commandAccess = await resolveMatrixMonitorCommandAccess(accessState, {
|
|
2687
|
-
useAccessGroups: true,
|
|
2688
2513
|
allowTextCommands,
|
|
2689
2514
|
hasControlCommand: hasControlCommandInMessage
|
|
2690
2515
|
});
|
|
@@ -2696,7 +2521,7 @@ async function resolveMatrixIngressContent(config) {
|
|
|
2696
2521
|
reason: "control command (unauthorized)",
|
|
2697
2522
|
target: senderId
|
|
2698
2523
|
});
|
|
2699
|
-
|
|
2524
|
+
discardReservedHistorySlot();
|
|
2700
2525
|
return;
|
|
2701
2526
|
}
|
|
2702
2527
|
const configuredRequireMention = isRoom ? roomConfig?.autoReply === true ? false : roomConfig?.autoReply === false ? true : typeof roomConfig?.requireMention === "boolean" ? roomConfig?.requireMention : true : false;
|
|
@@ -2744,7 +2569,6 @@ async function resolveMatrixIngressContent(config) {
|
|
|
2744
2569
|
roomId,
|
|
2745
2570
|
reason: "no-mention"
|
|
2746
2571
|
});
|
|
2747
|
-
await commitInboundEventIfClaimed();
|
|
2748
2572
|
return;
|
|
2749
2573
|
}
|
|
2750
2574
|
if (preflightAudioTranscript) await matrixPreflightAudio.send({
|
|
@@ -2769,40 +2593,47 @@ async function resolveMatrixIngressContent(config) {
|
|
|
2769
2593
|
let media = preflightMedia;
|
|
2770
2594
|
const finalMediaUrl = mediaContent.url;
|
|
2771
2595
|
if (!media && !mediaDownloadFailed && finalMediaUrl?.startsWith("mxc://")) media = await downloadMedia(finalMediaUrl);
|
|
2772
|
-
|
|
2773
|
-
|
|
2774
|
-
|
|
2775
|
-
|
|
2596
|
+
const rawBody = locationPayload?.text ?? mediaContent.body;
|
|
2597
|
+
const filename = typeof content.filename === "string" ? content.filename : void 0;
|
|
2598
|
+
const mediaPlaceholder = media?.placeholder;
|
|
2599
|
+
let bodyText = rawBody;
|
|
2600
|
+
if (mediaPlaceholder) {
|
|
2601
|
+
bodyText = rawBody || mediaPlaceholder;
|
|
2602
|
+
if (filename?.trim()) {
|
|
2603
|
+
const attachment = resolveMatrixMessageAttachment({
|
|
2604
|
+
body: rawBody,
|
|
2605
|
+
filename,
|
|
2606
|
+
msgtype: content.msgtype
|
|
2607
|
+
});
|
|
2608
|
+
if (attachment && !attachment.caption) bodyText = mediaPlaceholder;
|
|
2609
|
+
}
|
|
2610
|
+
} else if (mediaDownloadFailed && Boolean(finalMediaUrl)) bodyText = formatMatrixMessageText({
|
|
2611
|
+
body: rawBody,
|
|
2612
|
+
filename,
|
|
2776
2613
|
msgtype: content.msgtype,
|
|
2777
|
-
|
|
2778
|
-
|
|
2779
|
-
|
|
2780
|
-
});
|
|
2614
|
+
tooLarge: mediaSizeLimitExceeded,
|
|
2615
|
+
unavailable: true
|
|
2616
|
+
}) ?? "";
|
|
2781
2617
|
if (preflightMedia && bodyText && bodyText !== preflightMedia.placeholder && isLikelyBareFilename(bodyText)) bodyText = preflightMedia.placeholder;
|
|
2782
2618
|
if (preflightAudioTranscript) {
|
|
2783
2619
|
const transcriptBody = formatAudioTranscriptForAgent(preflightAudioTranscript);
|
|
2784
2620
|
bodyText = !bodyText || bodyText === media?.placeholder ? transcriptBody : `${bodyText}\n${transcriptBody}`;
|
|
2785
2621
|
}
|
|
2786
2622
|
if (!bodyText) {
|
|
2787
|
-
|
|
2623
|
+
discardReservedHistorySlot();
|
|
2788
2624
|
return;
|
|
2789
2625
|
}
|
|
2790
2626
|
const commandBodyText = hasControlCommandInMessage ? commandCheckText : bodyText;
|
|
2791
2627
|
const senderName = await getSenderName();
|
|
2792
2628
|
if (_configuredBinding) {
|
|
2793
2629
|
const { ensureConfiguredAcpBindingReady } = await loadAcpBindingRuntime();
|
|
2794
|
-
|
|
2630
|
+
const ensured = await ensureConfiguredAcpBindingReady({
|
|
2795
2631
|
cfg,
|
|
2796
2632
|
configuredBinding: _configuredBinding
|
|
2797
|
-
})
|
|
2798
|
-
|
|
2799
|
-
log: logVerboseMessage,
|
|
2800
|
-
channel: "matrix",
|
|
2801
|
-
reason: "configured ACP binding unavailable",
|
|
2802
|
-
target: _configuredBinding.spec.conversationId
|
|
2803
|
-
});
|
|
2633
|
+
});
|
|
2634
|
+
if (!ensured.ok) {
|
|
2804
2635
|
discardReservedHistorySlot();
|
|
2805
|
-
|
|
2636
|
+
throw new Error(`Matrix configured ACP binding is unavailable: ${ensured.error}`);
|
|
2806
2637
|
}
|
|
2807
2638
|
}
|
|
2808
2639
|
if (_runtimeBindingId) {
|
|
@@ -2846,115 +2677,7 @@ async function resolveMatrixIngressContent(config) {
|
|
|
2846
2677
|
};
|
|
2847
2678
|
}
|
|
2848
2679
|
//#endregion
|
|
2849
|
-
//#region extensions/matrix/src/matrix/monitor/
|
|
2850
|
-
function decodeGeoUriParamValue(value) {
|
|
2851
|
-
try {
|
|
2852
|
-
return decodeURIComponent(value);
|
|
2853
|
-
} catch {
|
|
2854
|
-
return value;
|
|
2855
|
-
}
|
|
2856
|
-
}
|
|
2857
|
-
function parseGeoUri(value) {
|
|
2858
|
-
if (!value.toLowerCase().startsWith("geo:")) return null;
|
|
2859
|
-
const [coordsPart, ...paramParts] = value.slice(4).split(";");
|
|
2860
|
-
if (!coordsPart) return null;
|
|
2861
|
-
const coords = coordsPart.split(",");
|
|
2862
|
-
if (coords.length < 2) return null;
|
|
2863
|
-
const latitude = parseStrictFiniteNumber(coords[0] ?? "");
|
|
2864
|
-
const longitude = parseStrictFiniteNumber(coords[1] ?? "");
|
|
2865
|
-
if (latitude === void 0 || longitude === void 0) return null;
|
|
2866
|
-
const params = /* @__PURE__ */ new Map();
|
|
2867
|
-
for (const part of paramParts) {
|
|
2868
|
-
const segment = part.trim();
|
|
2869
|
-
if (!segment) continue;
|
|
2870
|
-
const eqIndex = segment.indexOf("=");
|
|
2871
|
-
const rawKey = eqIndex === -1 ? segment : segment.slice(0, eqIndex);
|
|
2872
|
-
const rawValue = eqIndex === -1 ? "" : segment.slice(eqIndex + 1);
|
|
2873
|
-
const key = normalizeLowercaseStringOrEmpty(rawKey);
|
|
2874
|
-
if (!key) continue;
|
|
2875
|
-
const valuePart = rawValue.trim();
|
|
2876
|
-
params.set(key, valuePart ? decodeGeoUriParamValue(valuePart) : "");
|
|
2877
|
-
}
|
|
2878
|
-
const accuracyRaw = params.get("u");
|
|
2879
|
-
return {
|
|
2880
|
-
latitude,
|
|
2881
|
-
longitude,
|
|
2882
|
-
accuracy: accuracyRaw ? parseStrictFiniteNumber(accuracyRaw) : void 0
|
|
2883
|
-
};
|
|
2884
|
-
}
|
|
2885
|
-
function resolveMatrixLocation(params) {
|
|
2886
|
-
const { eventType, content } = params;
|
|
2887
|
-
if (!(eventType === EventType.Location || eventType === EventType.RoomMessage && content.msgtype === EventType.Location)) return null;
|
|
2888
|
-
const geoUri = normalizeOptionalString(content.geo_uri) ?? "";
|
|
2889
|
-
if (!geoUri) return null;
|
|
2890
|
-
const parsed = parseGeoUri(geoUri);
|
|
2891
|
-
if (!parsed) return null;
|
|
2892
|
-
const caption = normalizeOptionalString(content.body) ?? "";
|
|
2893
|
-
const location = {
|
|
2894
|
-
latitude: parsed.latitude,
|
|
2895
|
-
longitude: parsed.longitude,
|
|
2896
|
-
accuracy: parsed.accuracy,
|
|
2897
|
-
caption: caption || void 0,
|
|
2898
|
-
source: "pin",
|
|
2899
|
-
isLive: false
|
|
2900
|
-
};
|
|
2901
|
-
return {
|
|
2902
|
-
text: formatLocationText(location),
|
|
2903
|
-
context: toLocationContext(location)
|
|
2904
|
-
};
|
|
2905
|
-
}
|
|
2906
|
-
//#endregion
|
|
2907
|
-
//#region extensions/matrix/src/matrix/monitor/handler-ingress-prefix.ts
|
|
2908
|
-
async function readMatrixIngressPrefix(config) {
|
|
2909
|
-
const { client, senderId, dropPreStartupMessages, eventTs, eventAge, startupMs, event, eventType, eventId, inboundDeduper, roomId, logVerboseMessage, directTracker, claimInboundReplay } = config;
|
|
2910
|
-
const selfUserId = await client.getUserId();
|
|
2911
|
-
if (senderId === selfUserId) return;
|
|
2912
|
-
if (dropPreStartupMessages) {
|
|
2913
|
-
if (typeof eventTs === "number" && eventTs < startupMs) return;
|
|
2914
|
-
if (typeof eventTs !== "number" && typeof eventAge === "number" && eventAge > 0) return;
|
|
2915
|
-
}
|
|
2916
|
-
const content = event.content;
|
|
2917
|
-
if (eventType === EventType.RoomMessage && isMatrixVerificationRoomMessage({
|
|
2918
|
-
msgtype: content.msgtype,
|
|
2919
|
-
body: content.body
|
|
2920
|
-
})) {
|
|
2921
|
-
logVerboseMessage(`matrix: skip verification/system room message room=${roomId}`);
|
|
2922
|
-
return;
|
|
2923
|
-
}
|
|
2924
|
-
const locationPayload = resolveMatrixLocation({
|
|
2925
|
-
eventType,
|
|
2926
|
-
content
|
|
2927
|
-
});
|
|
2928
|
-
const relates = content["m.relates_to"];
|
|
2929
|
-
if (relates && "rel_type" in relates && relates.rel_type === RelationType.Replace) return;
|
|
2930
|
-
if (hasBundledMatrixReplacementRelation(event)) return;
|
|
2931
|
-
if (eventId && inboundDeduper) {
|
|
2932
|
-
const claim = await inboundDeduper.claim({
|
|
2933
|
-
roomId,
|
|
2934
|
-
eventId
|
|
2935
|
-
});
|
|
2936
|
-
if (claim.kind === "claimed") claimInboundReplay(claim.handle);
|
|
2937
|
-
else if (claim.kind !== "invalid") {
|
|
2938
|
-
logVerboseMessage(`matrix: skip duplicate inbound event room=${roomId} id=${eventId}`);
|
|
2939
|
-
return;
|
|
2940
|
-
}
|
|
2941
|
-
}
|
|
2942
|
-
return {
|
|
2943
|
-
content,
|
|
2944
|
-
isDirectMessage: await directTracker.isDirectMessage({
|
|
2945
|
-
roomId,
|
|
2946
|
-
senderId,
|
|
2947
|
-
selfUserId
|
|
2948
|
-
}),
|
|
2949
|
-
locationPayload,
|
|
2950
|
-
selfUserId
|
|
2951
|
-
};
|
|
2952
|
-
}
|
|
2953
|
-
//#endregion
|
|
2954
|
-
//#region extensions/matrix/src/matrix/monitor/replies.ts
|
|
2955
|
-
function joinMatrixVisibleContent(contents) {
|
|
2956
|
-
return contents.filter((content) => Boolean(content)).join("\n");
|
|
2957
|
-
}
|
|
2680
|
+
//#region extensions/matrix/src/matrix/monitor/handler-reply-dispatcher.ts
|
|
2958
2681
|
function mergeMatrixReplyDeliveryResults(results) {
|
|
2959
2682
|
const single = results.length === 1 ? results[0] : void 0;
|
|
2960
2683
|
if (single?.visibleReplySent) return single;
|
|
@@ -2963,7 +2686,7 @@ function mergeMatrixReplyDeliveryResults(results) {
|
|
|
2963
2686
|
visibleReplySent: false,
|
|
2964
2687
|
suppression: { reason: "no_visible_result" }
|
|
2965
2688
|
};
|
|
2966
|
-
const content =
|
|
2689
|
+
const content = visibleResults.map((result) => result.content).filter(Boolean).join("\n");
|
|
2967
2690
|
if (visibleResults.some((result) => result.receipt || result.messageIds?.length)) return createAcceptedChannelDeliveryResult({
|
|
2968
2691
|
deliveryResults: visibleResults,
|
|
2969
2692
|
content
|
|
@@ -2992,84 +2715,63 @@ function resolveVisibleMatrixReplyText(text) {
|
|
|
2992
2715
|
});
|
|
2993
2716
|
return visibleText.trim() ? visibleText : void 0;
|
|
2994
2717
|
}
|
|
2995
|
-
|
|
2996
|
-
const
|
|
2997
|
-
const
|
|
2998
|
-
|
|
2999
|
-
|
|
3000
|
-
|
|
3001
|
-
|
|
3002
|
-
|
|
3003
|
-
|
|
3004
|
-
|
|
3005
|
-
|
|
3006
|
-
|
|
3007
|
-
|
|
3008
|
-
|
|
3009
|
-
|
|
3010
|
-
|
|
3011
|
-
|
|
3012
|
-
|
|
3013
|
-
|
|
3014
|
-
|
|
3015
|
-
|
|
3016
|
-
|
|
3017
|
-
|
|
3018
|
-
|
|
3019
|
-
|
|
3020
|
-
|
|
3021
|
-
|
|
3022
|
-
|
|
3023
|
-
|
|
3024
|
-
|
|
3025
|
-
|
|
3026
|
-
|
|
3027
|
-
const
|
|
3028
|
-
|
|
3029
|
-
|
|
3030
|
-
cfg: params.cfg,
|
|
2718
|
+
function createMatrixReplyDispatcher(config) {
|
|
2719
|
+
const { cfg, prefixOptions, humanDelay, typingCallbacks, streaming, draftStream, draftController, client, roomId, runtime, replyToMode, threadTarget, replyToEventId, accountId, mediaLocalRoots, logVerboseMessage } = config;
|
|
2720
|
+
const quietDraftStreaming = streaming === "quiet" || streaming === "progress";
|
|
2721
|
+
let hasReplied = false;
|
|
2722
|
+
const deliverPayload = async (reply) => {
|
|
2723
|
+
const core = getMatrixRuntime();
|
|
2724
|
+
const logVerbose = (message) => {
|
|
2725
|
+
if (core.logging.shouldLogVerbose()) runtime.log?.(message);
|
|
2726
|
+
};
|
|
2727
|
+
const accepted = createChannelDeliveryAccumulator();
|
|
2728
|
+
const visibleText = resolveVisibleMatrixReplyText(reply.text);
|
|
2729
|
+
const { hasMedia, hasText, mediaUrls } = resolveSendableOutboundReplyParts(reply);
|
|
2730
|
+
if (reply.isReasoning === true || !hasMedia && reply.text && visibleText === void 0) {
|
|
2731
|
+
logVerbose("matrix reply suppressed as reasoning-only");
|
|
2732
|
+
return accepted.result();
|
|
2733
|
+
}
|
|
2734
|
+
if (!hasText && !hasMedia) {
|
|
2735
|
+
if (reply.audioAsVoice) logVerbose("matrix reply has audioAsVoice without media/text; skipping");
|
|
2736
|
+
else runtime.error?.("matrix reply missing text/media");
|
|
2737
|
+
return accepted.result();
|
|
2738
|
+
}
|
|
2739
|
+
const explicitReplyToId = reply.replyToTag || reply.replyToCurrent ? reply.replyToId?.trim() : void 0;
|
|
2740
|
+
const ambientReplyToId = threadTarget ?? replyToEventId;
|
|
2741
|
+
const replyToIdForReply = explicitReplyToId || (!threadTarget && replyToMode !== "off" && (replyToMode === "all" || !hasReplied) ? (reply.replyToId ?? ambientReplyToId)?.trim() : void 0);
|
|
2742
|
+
const fallbackReplyToId = threadTarget ? (reply.replyToId ?? ambientReplyToId)?.trim() : void 0;
|
|
2743
|
+
const onDeliveryResult = (result) => {
|
|
2744
|
+
accepted.add({ receipt: result.receipt }, result.content);
|
|
2745
|
+
if (replyToIdForReply) hasReplied = true;
|
|
2746
|
+
};
|
|
2747
|
+
const extraContent = resolveMatrixExtraContent(reply);
|
|
2748
|
+
const targets = mediaUrls.length > 0 ? mediaUrls : [void 0];
|
|
2749
|
+
try {
|
|
2750
|
+
for (const [index, mediaUrl] of targets.entries()) await sendMessageMatrix(roomId, index === 0 ? visibleText ?? "" : "", {
|
|
2751
|
+
client,
|
|
2752
|
+
cfg,
|
|
3031
2753
|
...mediaUrl !== void 0 ? {
|
|
3032
2754
|
mediaUrl,
|
|
3033
|
-
mediaLocalRoots
|
|
2755
|
+
mediaLocalRoots,
|
|
3034
2756
|
audioAsVoice: reply.audioAsVoice
|
|
3035
2757
|
} : {},
|
|
3036
2758
|
replyToId: replyToIdForReply,
|
|
3037
2759
|
fallbackReplyToId,
|
|
3038
|
-
threadId:
|
|
3039
|
-
accountId
|
|
2760
|
+
threadId: threadTarget,
|
|
2761
|
+
accountId,
|
|
3040
2762
|
extraContent: index === 0 ? extraContent : void 0,
|
|
3041
2763
|
onDeliveryResult
|
|
3042
2764
|
});
|
|
2765
|
+
} catch (error) {
|
|
2766
|
+
throw toMatrixPartialDeliveryError(error, [accepted.result()]);
|
|
3043
2767
|
}
|
|
3044
|
-
|
|
3045
|
-
|
|
3046
|
-
}
|
|
3047
|
-
return accepted.result();
|
|
3048
|
-
}
|
|
3049
|
-
//#endregion
|
|
3050
|
-
//#region extensions/matrix/src/matrix/monitor/handler-reply-dispatcher.ts
|
|
3051
|
-
function createMatrixReplyDispatcher(config) {
|
|
3052
|
-
const { cfg, prefixOptions, humanDelay, typingCallbacks, streaming, draftStream, draftController, client, roomId, runtime, replyToMode, threadTarget, replyToEventId, accountId, mediaLocalRoots, logVerboseMessage } = config;
|
|
3053
|
-
const quietDraftStreaming = streaming === "quiet" || streaming === "progress";
|
|
3054
|
-
const hasRepliedRef = { value: false };
|
|
3055
|
-
const deliverPayload = (reply) => deliverMatrixReplies({
|
|
3056
|
-
cfg,
|
|
3057
|
-
replies: [reply],
|
|
3058
|
-
roomId,
|
|
3059
|
-
client,
|
|
3060
|
-
runtime,
|
|
3061
|
-
replyToMode,
|
|
3062
|
-
hasRepliedRef,
|
|
3063
|
-
threadId: threadTarget,
|
|
3064
|
-
replyToId: threadTarget ?? replyToEventId ?? void 0,
|
|
3065
|
-
accountId,
|
|
3066
|
-
mediaLocalRoots
|
|
3067
|
-
});
|
|
2768
|
+
return accepted.result();
|
|
2769
|
+
};
|
|
3068
2770
|
const { previewLifecycle } = draftController;
|
|
3069
2771
|
let nonFinalReplyDeliveryFailed = false;
|
|
3070
|
-
const beginNextBlockDraft = () => {
|
|
2772
|
+
const beginNextBlockDraft = (boundary) => {
|
|
3071
2773
|
draftController.beginDraftGeneration();
|
|
3072
|
-
draftController.advanceDraftBlockBoundary(
|
|
2774
|
+
draftController.advanceDraftBlockBoundary(boundary);
|
|
3073
2775
|
draftStream?.reset();
|
|
3074
2776
|
draftController.resetReplyToIdForNextBlock();
|
|
3075
2777
|
draftController.updateDraftFromLatestFullText();
|
|
@@ -3104,6 +2806,7 @@ function createMatrixReplyDispatcher(config) {
|
|
|
3104
2806
|
} : payload;
|
|
3105
2807
|
const { hasMedia } = resolveSendableOutboundReplyParts(payload);
|
|
3106
2808
|
const payloadText = payload.text ?? ttsSupplement?.spokenText;
|
|
2809
|
+
const blockBoundary = info.kind === "block" && !payload.isCompactionNotice ? draftController.captureDraftBlockBoundary(payloadText, info) : void 0;
|
|
3107
2810
|
const payloadReplyMismatch = (!threadTarget && replyToMode !== "off" || payload.replyToTag || payload.replyToCurrent) && normalizeOptionalString(payload.replyToId) !== draftController.currentReplyToId();
|
|
3108
2811
|
let retainedDraftDelivery;
|
|
3109
2812
|
let deliveryResult;
|
|
@@ -3133,8 +2836,7 @@ function createMatrixReplyDispatcher(config) {
|
|
|
3133
2836
|
});
|
|
3134
2837
|
return createDraftDeliveryResult(draftEventId, prepareMatrixSingleText(edit.text, {
|
|
3135
2838
|
cfg,
|
|
3136
|
-
accountId
|
|
3137
|
-
preserveWhitespace: true
|
|
2839
|
+
accountId
|
|
3138
2840
|
}).convertedText);
|
|
3139
2841
|
},
|
|
3140
2842
|
createPreviewReceipt: createDraftReceipt,
|
|
@@ -3158,12 +2860,17 @@ function createMatrixReplyDispatcher(config) {
|
|
|
3158
2860
|
})).deliveryResult;
|
|
3159
2861
|
} catch (error) {
|
|
3160
2862
|
if (retainedDraftDelivery) previewLifecycle.retainPreview();
|
|
2863
|
+
if (blockBoundary) beginNextBlockDraft(retainedDraftDelivery ? {
|
|
2864
|
+
...blockBoundary,
|
|
2865
|
+
messageGeneration: blockBoundary.previewMessageGeneration,
|
|
2866
|
+
endOffset: blockBoundary.messageGeneration === blockBoundary.previewMessageGeneration ? Math.max(blockBoundary.endOffset, blockBoundary.previewEndOffset) : blockBoundary.previewEndOffset
|
|
2867
|
+
} : blockBoundary);
|
|
3161
2868
|
throw toMatrixPartialDeliveryError(error, retainedDraftDelivery ? [retainedDraftDelivery] : []);
|
|
3162
2869
|
}
|
|
3163
2870
|
if (retainedDraftDelivery && !deliveryResult?.visibleReplySent) previewLifecycle.retainPreview();
|
|
3164
2871
|
const mergedDelivery = mergeMatrixReplyDeliveryResults([retainedDraftDelivery?.messageIds?.includes(draftStream?.eventId() ?? "") ? retainedDraftDelivery : void 0, deliveryResult].filter((result) => result !== void 0));
|
|
3165
|
-
if (
|
|
3166
|
-
beginNextBlockDraft();
|
|
2872
|
+
if (blockBoundary) {
|
|
2873
|
+
beginNextBlockDraft(blockBoundary);
|
|
3167
2874
|
await typingCallbacks.onReplyStart();
|
|
3168
2875
|
}
|
|
3169
2876
|
return mergedDelivery;
|
|
@@ -3171,7 +2878,6 @@ function createMatrixReplyDispatcher(config) {
|
|
|
3171
2878
|
onReplyError: (err, info) => {
|
|
3172
2879
|
if (info.kind === "final") previewLifecycle.observeFailure();
|
|
3173
2880
|
else nonFinalReplyDeliveryFailed = true;
|
|
3174
|
-
if (info.kind === "block") beginNextBlockDraft();
|
|
3175
2881
|
runtime.error?.(`matrix ${info.kind} reply failed: ${String(err)}`);
|
|
3176
2882
|
},
|
|
3177
2883
|
nonFinalReplyDeliveryFailed: () => nonFinalReplyDeliveryFailed
|
|
@@ -3183,7 +2889,7 @@ const ALLOW_FROM_STORE_CACHE_TTL_MS = 3e4;
|
|
|
3183
2889
|
const PAIRING_REPLY_COOLDOWN_MS = 3e5;
|
|
3184
2890
|
const MAX_TRACKED_PAIRING_REPLY_SENDERS = 512;
|
|
3185
2891
|
function createMatrixHandlerState(config) {
|
|
3186
|
-
const { core, accountId, runtime, allowFromResolvedEntries, groupAllowFromResolvedEntries
|
|
2892
|
+
const { core, accountId, runtime, allowFromResolvedEntries, groupAllowFromResolvedEntries } = config;
|
|
3187
2893
|
let cachedStoreAllowFrom = null;
|
|
3188
2894
|
const liveAllowlistCache = /* @__PURE__ */ new Map();
|
|
3189
2895
|
const resolveCachedLiveAllowlist = async (paramsValue) => {
|
|
@@ -3198,7 +2904,7 @@ function createMatrixHandlerState(config) {
|
|
|
3198
2904
|
});
|
|
3199
2905
|
const cached = liveAllowlistCache.get(paramsValue.scope);
|
|
3200
2906
|
if (cached?.signature === signature) return cached.entries;
|
|
3201
|
-
const entries = await
|
|
2907
|
+
const entries = await resolveMatrixMonitorLiveUserAllowlist({
|
|
3202
2908
|
cfg: paramsValue.cfg,
|
|
3203
2909
|
accountId,
|
|
3204
2910
|
entries: paramsValue.entries,
|
|
@@ -3238,24 +2944,23 @@ function createMatrixHandlerState(config) {
|
|
|
3238
2944
|
};
|
|
3239
2945
|
const readStoreAllowFrom = async () => {
|
|
3240
2946
|
const now = Date.now();
|
|
3241
|
-
if (cachedStoreAllowFrom &&
|
|
2947
|
+
if (cachedStoreAllowFrom && cachedStoreAllowFrom.expiresAtMs > now) return cachedStoreAllowFrom.value;
|
|
3242
2948
|
cachedStoreAllowFrom = null;
|
|
3243
2949
|
const value = await core.channel.pairing.readAllowFromStore({
|
|
3244
2950
|
channel: "matrix",
|
|
3245
2951
|
env: process.env,
|
|
3246
2952
|
accountId
|
|
3247
2953
|
}).catch(() => []);
|
|
3248
|
-
|
|
3249
|
-
cachedStoreAllowFrom = expiresAtMs === void 0 ? null : {
|
|
2954
|
+
cachedStoreAllowFrom = {
|
|
3250
2955
|
value,
|
|
3251
|
-
expiresAtMs
|
|
2956
|
+
expiresAtMs: now + ALLOW_FROM_STORE_CACHE_TTL_MS
|
|
3252
2957
|
};
|
|
3253
2958
|
return value;
|
|
3254
2959
|
};
|
|
3255
2960
|
const shouldSendPairingReply = (senderId, created) => {
|
|
3256
2961
|
const now = Date.now();
|
|
3257
2962
|
const lastSentAtMs = pairingReplySentAtMsBySender.get(senderId);
|
|
3258
|
-
if (!created &&
|
|
2963
|
+
if (!created && lastSentAtMs !== void 0 && now - lastSentAtMs < PAIRING_REPLY_COOLDOWN_MS) return false;
|
|
3259
2964
|
setBoundedMap(pairingReplySentAtMsBySender, senderId, now, MAX_TRACKED_PAIRING_REPLY_SENDERS);
|
|
3260
2965
|
return true;
|
|
3261
2966
|
};
|
|
@@ -3266,28 +2971,71 @@ function createMatrixHandlerState(config) {
|
|
|
3266
2971
|
};
|
|
3267
2972
|
}
|
|
3268
2973
|
//#endregion
|
|
2974
|
+
//#region extensions/matrix/src/matrix/monitor/location.ts
|
|
2975
|
+
function decodeGeoUriParamValue(value) {
|
|
2976
|
+
try {
|
|
2977
|
+
return decodeURIComponent(value);
|
|
2978
|
+
} catch {
|
|
2979
|
+
return value;
|
|
2980
|
+
}
|
|
2981
|
+
}
|
|
2982
|
+
function resolveMatrixLocation(params) {
|
|
2983
|
+
const { eventType, content } = params;
|
|
2984
|
+
if (!(eventType === EventType.Location || eventType === EventType.RoomMessage && content.msgtype === EventType.Location)) return null;
|
|
2985
|
+
const geoUri = normalizeOptionalString(content.geo_uri) ?? "";
|
|
2986
|
+
if (!geoUri) return null;
|
|
2987
|
+
if (!geoUri.toLowerCase().startsWith("geo:")) return null;
|
|
2988
|
+
const [coordsPart, ...paramParts] = geoUri.slice(4).split(";");
|
|
2989
|
+
if (!coordsPart) return null;
|
|
2990
|
+
const coords = coordsPart.split(",");
|
|
2991
|
+
if (coords.length < 2) return null;
|
|
2992
|
+
const latitude = parseStrictFiniteNumber(coords[0] ?? "");
|
|
2993
|
+
const longitude = parseStrictFiniteNumber(coords[1] ?? "");
|
|
2994
|
+
if (latitude === void 0 || longitude === void 0) return null;
|
|
2995
|
+
const geoParams = /* @__PURE__ */ new Map();
|
|
2996
|
+
for (const part of paramParts) {
|
|
2997
|
+
const segment = part.trim();
|
|
2998
|
+
if (!segment) continue;
|
|
2999
|
+
const eqIndex = segment.indexOf("=");
|
|
3000
|
+
const rawKey = eqIndex === -1 ? segment : segment.slice(0, eqIndex);
|
|
3001
|
+
const rawValue = eqIndex === -1 ? "" : segment.slice(eqIndex + 1);
|
|
3002
|
+
const key = normalizeLowercaseStringOrEmpty(rawKey);
|
|
3003
|
+
if (!key) continue;
|
|
3004
|
+
const valuePart = rawValue.trim();
|
|
3005
|
+
geoParams.set(key, valuePart ? decodeGeoUriParamValue(valuePart) : "");
|
|
3006
|
+
}
|
|
3007
|
+
const accuracyRaw = geoParams.get("u");
|
|
3008
|
+
const location = {
|
|
3009
|
+
latitude,
|
|
3010
|
+
longitude,
|
|
3011
|
+
accuracy: accuracyRaw ? parseStrictFiniteNumber(accuracyRaw) : void 0,
|
|
3012
|
+
caption: (normalizeOptionalString(content.body) ?? "") || void 0,
|
|
3013
|
+
source: "pin",
|
|
3014
|
+
isLive: false
|
|
3015
|
+
};
|
|
3016
|
+
return {
|
|
3017
|
+
text: formatLocationText(location),
|
|
3018
|
+
context: toLocationContext(location)
|
|
3019
|
+
};
|
|
3020
|
+
}
|
|
3021
|
+
//#endregion
|
|
3269
3022
|
//#region extensions/matrix/src/matrix/monitor/handler.ts
|
|
3270
3023
|
const SESSION_RESTART_RECOVERY_TOMBSTONE_ERROR_CODE = "SESSION_RESTART_RECOVERY_TOMBSTONE";
|
|
3271
3024
|
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.";
|
|
3272
3025
|
function createMatrixRoomMessageHandler(params) {
|
|
3273
|
-
const { client, core, cfg: startupConfig, accountId, runtime, logger, logVerboseMessage, allowFromResolvedEntries = [], groupAllowFromResolvedEntries = [], configuredBotUserIds = /* @__PURE__ */ new Set(), replyToMode, streaming, previewToolProgressEnabled, blockStreamingEnabled, historyLimit,
|
|
3026
|
+
const { client, core, cfg: startupConfig, accountId, runtime, logger, logVerboseMessage, allowFromResolvedEntries = [], groupAllowFromResolvedEntries = [], configuredBotUserIds = /* @__PURE__ */ new Set(), replyToMode, streaming, previewToolProgressEnabled, blockStreamingEnabled, historyLimit, directTracker, getMemberDisplayName } = params;
|
|
3274
3027
|
const handlerConfig = {
|
|
3275
3028
|
...params,
|
|
3276
3029
|
allowFromResolvedEntries,
|
|
3277
3030
|
groupAllowFromResolvedEntries,
|
|
3278
|
-
configuredBotUserIds
|
|
3279
|
-
resolveLiveUserAllowlist,
|
|
3280
|
-
resolveStorePath: resolveStorePathImpl,
|
|
3281
|
-
createChannelInboundEnvelopeBuilderAsync: createChannelInboundEnvelopeBuilderImpl,
|
|
3282
|
-
resolveHumanDelayConfig: resolveHumanDelayConfigImpl
|
|
3031
|
+
configuredBotUserIds
|
|
3283
3032
|
};
|
|
3284
3033
|
const handlerState = createMatrixHandlerState({
|
|
3285
3034
|
core,
|
|
3286
3035
|
accountId,
|
|
3287
3036
|
runtime,
|
|
3288
3037
|
allowFromResolvedEntries,
|
|
3289
|
-
groupAllowFromResolvedEntries
|
|
3290
|
-
resolveLiveUserAllowlist
|
|
3038
|
+
groupAllowFromResolvedEntries
|
|
3291
3039
|
});
|
|
3292
3040
|
const resolveThreadContext = createMatrixEventContextResolver({
|
|
3293
3041
|
kind: "thread",
|
|
@@ -3304,9 +3052,8 @@ function createMatrixRoomMessageHandler(params) {
|
|
|
3304
3052
|
const roomHistoryTracker = createRoomHistoryTracker();
|
|
3305
3053
|
const roomIngressQueue = new KeyedAsyncQueue();
|
|
3306
3054
|
const sharedDmContextNoticeRooms = /* @__PURE__ */ new Set();
|
|
3307
|
-
return async (roomId, event) => {
|
|
3055
|
+
return async (roomId, event, lifecycle) => {
|
|
3308
3056
|
const eventId = typeof event.event_id === "string" ? event.event_id.trim() : "";
|
|
3309
|
-
let inboundReplayClaim;
|
|
3310
3057
|
let draftControllerRef;
|
|
3311
3058
|
try {
|
|
3312
3059
|
const eventType = event.type;
|
|
@@ -3321,39 +3068,42 @@ function createMatrixRoomMessageHandler(params) {
|
|
|
3321
3068
|
const senderId = event.sender;
|
|
3322
3069
|
if (!senderId) return;
|
|
3323
3070
|
const eventTs = event.origin_server_ts;
|
|
3324
|
-
const
|
|
3325
|
-
|
|
3326
|
-
|
|
3327
|
-
|
|
3328
|
-
|
|
3329
|
-
|
|
3330
|
-
|
|
3331
|
-
|
|
3332
|
-
|
|
3333
|
-
|
|
3334
|
-
dropPreStartupMessages,
|
|
3335
|
-
eventTs: eventTs ?? void 0,
|
|
3336
|
-
eventAge: eventAge ?? void 0,
|
|
3337
|
-
startupMs,
|
|
3338
|
-
event,
|
|
3339
|
-
eventType,
|
|
3340
|
-
eventId,
|
|
3341
|
-
inboundDeduper,
|
|
3342
|
-
roomId,
|
|
3343
|
-
logVerboseMessage,
|
|
3344
|
-
directTracker,
|
|
3345
|
-
claimInboundReplay: (handle) => {
|
|
3346
|
-
inboundReplayClaim = handle;
|
|
3071
|
+
const readIngressPrefix = async () => {
|
|
3072
|
+
const selfUserId = await client.getUserId();
|
|
3073
|
+
if (senderId === selfUserId) return;
|
|
3074
|
+
const content = locationContent;
|
|
3075
|
+
if (eventType === EventType.RoomMessage && isMatrixVerificationRoomMessage({
|
|
3076
|
+
msgtype: content.msgtype,
|
|
3077
|
+
body: content.body
|
|
3078
|
+
})) {
|
|
3079
|
+
logVerboseMessage(`matrix: skip verification/system room message room=${roomId}`);
|
|
3080
|
+
return;
|
|
3347
3081
|
}
|
|
3348
|
-
|
|
3082
|
+
const locationPayload = resolveMatrixLocation({
|
|
3083
|
+
eventType,
|
|
3084
|
+
content
|
|
3085
|
+
});
|
|
3086
|
+
const relates = content["m.relates_to"];
|
|
3087
|
+
if (relates && "rel_type" in relates && relates.rel_type === RelationType.Replace) return;
|
|
3088
|
+
if (hasBundledMatrixReplacementRelation(event)) return;
|
|
3089
|
+
return {
|
|
3090
|
+
content,
|
|
3091
|
+
isDirectMessage: await directTracker.isDirectMessage({
|
|
3092
|
+
roomId,
|
|
3093
|
+
senderId,
|
|
3094
|
+
selfUserId
|
|
3095
|
+
}),
|
|
3096
|
+
locationPayload,
|
|
3097
|
+
selfUserId
|
|
3098
|
+
};
|
|
3099
|
+
};
|
|
3349
3100
|
const ingressContext = {
|
|
3350
3101
|
handler: handlerConfig,
|
|
3351
3102
|
roomId,
|
|
3352
3103
|
event,
|
|
3353
3104
|
eventTs: eventTs ?? void 0,
|
|
3354
3105
|
senderId,
|
|
3355
|
-
roomHistoryTracker
|
|
3356
|
-
commitInboundEventIfClaimed
|
|
3106
|
+
roomHistoryTracker
|
|
3357
3107
|
};
|
|
3358
3108
|
const continueIngress = async (paramsLocal) => {
|
|
3359
3109
|
const access = await resolveMatrixIngressAccess({
|
|
@@ -3450,7 +3200,7 @@ function createMatrixRoomMessageHandler(params) {
|
|
|
3450
3200
|
const replyDispatcher = createMatrixReplyDispatcher({
|
|
3451
3201
|
cfg,
|
|
3452
3202
|
prefixOptions,
|
|
3453
|
-
humanDelay:
|
|
3203
|
+
humanDelay: resolveHumanDelayConfig(cfg, _route.agentId),
|
|
3454
3204
|
typingCallbacks,
|
|
3455
3205
|
streaming,
|
|
3456
3206
|
draftStream,
|
|
@@ -3475,27 +3225,11 @@ function createMatrixRoomMessageHandler(params) {
|
|
|
3475
3225
|
route: _route,
|
|
3476
3226
|
sessionKey: _route.sessionKey
|
|
3477
3227
|
});
|
|
3478
|
-
const replayClaimAtDispatch = inboundReplayClaim;
|
|
3479
|
-
const turnAdoptionLifecycle = replayClaimAtDispatch ? {
|
|
3480
|
-
admission: "exclusive",
|
|
3481
|
-
onDeferred: () => {
|
|
3482
|
-
if (inboundReplayClaim !== replayClaimAtDispatch) return false;
|
|
3483
|
-
inboundReplayClaim = void 0;
|
|
3484
|
-
},
|
|
3485
|
-
onAdopted: async () => {
|
|
3486
|
-
if (inboundReplayClaim === replayClaimAtDispatch) inboundReplayClaim = void 0;
|
|
3487
|
-
await replayClaimAtDispatch.commit();
|
|
3488
|
-
},
|
|
3489
|
-
onAbandoned: () => {
|
|
3490
|
-
if (inboundReplayClaim === replayClaimAtDispatch) inboundReplayClaim = void 0;
|
|
3491
|
-
replayClaimAtDispatch.release();
|
|
3492
|
-
}
|
|
3493
|
-
} : void 0;
|
|
3494
3228
|
const turnResultPromise = core.channel.inbound.run({
|
|
3495
3229
|
channel: "matrix",
|
|
3496
3230
|
accountId: _route.accountId,
|
|
3497
3231
|
raw: event,
|
|
3498
|
-
|
|
3232
|
+
turnAdoptionLifecycle: lifecycle,
|
|
3499
3233
|
adapter: {
|
|
3500
3234
|
ingest: () => ({
|
|
3501
3235
|
id: messageId,
|
|
@@ -3560,11 +3294,6 @@ function createMatrixRoomMessageHandler(params) {
|
|
|
3560
3294
|
skillFilter: roomConfig?.skills,
|
|
3561
3295
|
disableBlockStreaming: !blockStreamingEnabled,
|
|
3562
3296
|
onPartialReply: draftStream ? (payload) => draftController.onPartialReply(payload.text ?? "") : void 0,
|
|
3563
|
-
onBlockReplyQueued: draftStream ? (payload, context) => {
|
|
3564
|
-
if (payload.isCompactionNotice === true) return false;
|
|
3565
|
-
draftController.queueDraftBlockBoundary(payload, context);
|
|
3566
|
-
return false;
|
|
3567
|
-
} : void 0,
|
|
3568
3297
|
onAssistantMessageStart: draftStream ? () => {
|
|
3569
3298
|
draftController.resetDraftBlockOffsets();
|
|
3570
3299
|
draftController.beginAssistantMessage();
|
|
@@ -3597,36 +3326,29 @@ function createMatrixRoomMessageHandler(params) {
|
|
|
3597
3326
|
deliveryPartCount: 1,
|
|
3598
3327
|
extraContent: { msgtype: "m.notice" }
|
|
3599
3328
|
});
|
|
3600
|
-
await commitInboundEventIfClaimed();
|
|
3601
3329
|
} catch (noticeError) {
|
|
3602
3330
|
runtime.error?.(`matrix: failed completing restart-recovery tombstone notice room=${roomId} id=${eventId || "unknown"}: ${String(noticeError)}`);
|
|
3331
|
+
throw noticeError;
|
|
3603
3332
|
}
|
|
3604
3333
|
return;
|
|
3605
3334
|
}
|
|
3606
|
-
if (!turnResult.dispatched)
|
|
3607
|
-
if (turnResult.admission.kind === "drop" && turnResult.admission.reason === "bot-loop-protection") await commitInboundEventIfClaimed();
|
|
3608
|
-
return;
|
|
3609
|
-
}
|
|
3335
|
+
if (!turnResult.dispatched) return;
|
|
3610
3336
|
const { dispatchResult } = turnResult;
|
|
3611
3337
|
const { queuedFinal } = dispatchResult;
|
|
3612
3338
|
const failedDeliveryKind = draftController.previewLifecycle.finalFailed ? "final" : !queuedFinal && replyDispatcher.nonFinalReplyDeliveryFailed() ? "non-final" : void 0;
|
|
3613
3339
|
if (failedDeliveryKind) {
|
|
3614
|
-
logVerboseMessage(`matrix: ${failedDeliveryKind} reply delivery failed room=${roomId} id=${messageId};
|
|
3615
|
-
await commitInboundEventIfClaimed();
|
|
3340
|
+
logVerboseMessage(`matrix: ${failedDeliveryKind} reply delivery failed room=${roomId} id=${messageId}; turn already adopted`);
|
|
3616
3341
|
return;
|
|
3617
3342
|
}
|
|
3618
3343
|
if (isRoom && triggerSnapshot) roomHistoryTracker.consumeHistory(_route.agentId, roomId, triggerSnapshot, messageId, threadRootId ? thread.threadId : void 0);
|
|
3619
|
-
if (!hasFinalInboundReplyDispatch(dispatchResult))
|
|
3620
|
-
await commitInboundEventIfClaimed();
|
|
3621
|
-
return;
|
|
3622
|
-
}
|
|
3344
|
+
if (!hasFinalInboundReplyDispatch(dispatchResult)) return;
|
|
3623
3345
|
const finalCount = resolveInboundReplyDispatchCounts(dispatchResult).final;
|
|
3624
3346
|
logVerboseMessage(`matrix: delivered ${finalCount} reply${finalCount === 1 ? "" : "ies"} to ${replyTarget}`);
|
|
3625
|
-
await commitInboundEventIfClaimed();
|
|
3626
3347
|
} catch (err) {
|
|
3627
3348
|
const draftController = draftControllerRef;
|
|
3628
3349
|
if (draftController?.draftStream?.eventId()) draftController.previewLifecycle.retainPreview();
|
|
3629
3350
|
runtime.error?.(`matrix handler failed: ${String(err)}`);
|
|
3351
|
+
throw err;
|
|
3630
3352
|
} finally {
|
|
3631
3353
|
const draftStream = draftControllerRef?.draftStream;
|
|
3632
3354
|
if (draftStream) {
|
|
@@ -3634,11 +3356,142 @@ function createMatrixRoomMessageHandler(params) {
|
|
|
3634
3356
|
await draftControllerRef?.previewLifecycle.cleanup();
|
|
3635
3357
|
await draftStream.cleanupPending();
|
|
3636
3358
|
}
|
|
3637
|
-
inboundReplayClaim?.release();
|
|
3638
3359
|
}
|
|
3639
3360
|
};
|
|
3640
3361
|
}
|
|
3641
3362
|
//#endregion
|
|
3363
|
+
//#region extensions/matrix/src/matrix/monitor/ingress.ts
|
|
3364
|
+
const MatrixIngressPayloadError = createChannelIngressError("MatrixIngressPayloadError");
|
|
3365
|
+
function inspectMatrixIngressEvent(raw) {
|
|
3366
|
+
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");
|
|
3367
|
+
return {
|
|
3368
|
+
eventId: raw.event.event_id,
|
|
3369
|
+
laneKey: `room:${raw.roomId}`
|
|
3370
|
+
};
|
|
3371
|
+
}
|
|
3372
|
+
function createMatrixIngressMonitor(params) {
|
|
3373
|
+
const diagnosticId = randomUUID();
|
|
3374
|
+
let diagnosticCount = 0;
|
|
3375
|
+
const observe = (phase, facts = {}) => {
|
|
3376
|
+
if (diagnosticCount >= 64) return;
|
|
3377
|
+
diagnosticCount += 1;
|
|
3378
|
+
try {
|
|
3379
|
+
emitMatrixLog("debug", "MatrixIngress", [JSON.stringify({
|
|
3380
|
+
monitor: diagnosticId,
|
|
3381
|
+
sequence: diagnosticCount,
|
|
3382
|
+
phase,
|
|
3383
|
+
...facts,
|
|
3384
|
+
exhausted: diagnosticCount === 64
|
|
3385
|
+
})]);
|
|
3386
|
+
} catch {}
|
|
3387
|
+
};
|
|
3388
|
+
let queue = params.queue;
|
|
3389
|
+
const getQueue = () => queue ??= getMatrixRuntime().state.openChannelIngressQueue({ accountId: params.accountId });
|
|
3390
|
+
let lastReceivedAt = 0;
|
|
3391
|
+
let initializeOrder;
|
|
3392
|
+
const monitor = createChannelIngressMonitor({
|
|
3393
|
+
queue: getQueue,
|
|
3394
|
+
inspect: inspectMatrixIngressEvent,
|
|
3395
|
+
payload: {
|
|
3396
|
+
version: 1,
|
|
3397
|
+
serialize: (raw) => raw,
|
|
3398
|
+
deserialize: (body) => body,
|
|
3399
|
+
encode: ({ body }) => ({
|
|
3400
|
+
version: 1,
|
|
3401
|
+
...body
|
|
3402
|
+
}),
|
|
3403
|
+
decode: (payload) => {
|
|
3404
|
+
inspectMatrixIngressEvent(payload);
|
|
3405
|
+
return {
|
|
3406
|
+
version: payload.version,
|
|
3407
|
+
body: payload
|
|
3408
|
+
};
|
|
3409
|
+
},
|
|
3410
|
+
createClaimError: (kind) => new MatrixIngressPayloadError(kind === "invalid-version" ? "Matrix ingress payload version is unsupported" : "Matrix event identity changed after durable admission")
|
|
3411
|
+
},
|
|
3412
|
+
deliver: async ({ roomId, event, historical }, lifecycle) => {
|
|
3413
|
+
observe("deliver-entered", { historical: historical === true });
|
|
3414
|
+
if (historical) {
|
|
3415
|
+
observe("historical-skipped");
|
|
3416
|
+
return;
|
|
3417
|
+
}
|
|
3418
|
+
if (event.type === EventType.RoomMessageEncrypted && !params.client.crypto) {
|
|
3419
|
+
observe("crypto-unavailable");
|
|
3420
|
+
return;
|
|
3421
|
+
}
|
|
3422
|
+
observe("hydrate-entered");
|
|
3423
|
+
const [hydrated] = await params.client.hydrateEvents(roomId, [event]);
|
|
3424
|
+
observe("hydrate-returned", { hydrated: Boolean(hydrated) });
|
|
3425
|
+
if (!hydrated || hydrated.type === EventType.RoomMessageEncrypted || getMatrixEventProjection(hydrated)?.decryptionFailure) throw new Error("Matrix ingress event is waiting for decryption");
|
|
3426
|
+
observe("dispatch-entered");
|
|
3427
|
+
const result = await params.dispatch(roomId, hydrated, lifecycle);
|
|
3428
|
+
observe("dispatch-returned", { outcome: result?.kind ?? "void" });
|
|
3429
|
+
return result;
|
|
3430
|
+
},
|
|
3431
|
+
pollIntervalMs: 1e3,
|
|
3432
|
+
retention: "standard",
|
|
3433
|
+
waitForDeliveryIdleOnStop: false,
|
|
3434
|
+
drain: {
|
|
3435
|
+
deferredLaneOccupancy: "release",
|
|
3436
|
+
onLog: params.onError,
|
|
3437
|
+
resolveNonRetryableFailure: (error) => error instanceof MatrixIngressPayloadError ? {
|
|
3438
|
+
reason: "invalid-event",
|
|
3439
|
+
message: error.message
|
|
3440
|
+
} : null
|
|
3441
|
+
},
|
|
3442
|
+
onError: params.onError
|
|
3443
|
+
});
|
|
3444
|
+
const admitSync = async (sync, { hasSavedSync }) => {
|
|
3445
|
+
const events = [];
|
|
3446
|
+
const rooms = [...Object.entries(sync.rooms?.join ?? {}), ...Object.entries(sync.rooms?.leave ?? {})];
|
|
3447
|
+
for (const [roomId, room] of rooms) for (const event of room.timeline?.events ?? []) {
|
|
3448
|
+
if (!(event.type === EventType.RoomMessage || event.type === EventType.RoomMessageEncrypted || event.type === EventType.Location || event.type === EventType.Reaction || isPollEventType(event.type))) continue;
|
|
3449
|
+
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);
|
|
3450
|
+
events.push({
|
|
3451
|
+
roomId,
|
|
3452
|
+
event: {
|
|
3453
|
+
...event,
|
|
3454
|
+
room_id: roomId
|
|
3455
|
+
},
|
|
3456
|
+
...historical ? { historical: true } : {}
|
|
3457
|
+
});
|
|
3458
|
+
}
|
|
3459
|
+
if (events.length === 0) return;
|
|
3460
|
+
observe("sync-selected", {
|
|
3461
|
+
count: events.length,
|
|
3462
|
+
hasSavedSync
|
|
3463
|
+
});
|
|
3464
|
+
await (initializeOrder ??= (async () => {
|
|
3465
|
+
observe("order-load-entered");
|
|
3466
|
+
const ingressQueue = getQueue();
|
|
3467
|
+
const { pending, claims } = ingressQueue.listUnsettled ? await ingressQueue.listUnsettled() : {
|
|
3468
|
+
pending: await ingressQueue.listPending({ limit: "all" }),
|
|
3469
|
+
claims: await ingressQueue.listClaims()
|
|
3470
|
+
};
|
|
3471
|
+
observe("order-load-returned", {
|
|
3472
|
+
pending: pending.length,
|
|
3473
|
+
claims: claims.length
|
|
3474
|
+
});
|
|
3475
|
+
for (const row of [...pending, ...claims]) lastReceivedAt = Math.max(lastReceivedAt, row.receivedAt);
|
|
3476
|
+
})());
|
|
3477
|
+
for (const event of events) {
|
|
3478
|
+
observe("admit-entered", { historical: event.historical === true });
|
|
3479
|
+
const result = await monitor.admit(event, { receivedAt: Math.max(Date.now(), lastReceivedAt + 1) });
|
|
3480
|
+
observe("admit-returned", { outcome: result.kind === "durable" ? result.queueResult.kind : result.kind });
|
|
3481
|
+
if (result.kind === "durable") {
|
|
3482
|
+
const admitted = result.queueResult;
|
|
3483
|
+
if (admitted.kind === "accepted" || admitted.kind === "pending" || admitted.kind === "claimed") lastReceivedAt = Math.max(lastReceivedAt, admitted.record.receivedAt);
|
|
3484
|
+
}
|
|
3485
|
+
}
|
|
3486
|
+
};
|
|
3487
|
+
return {
|
|
3488
|
+
admitSync,
|
|
3489
|
+
start: monitor.start,
|
|
3490
|
+
stop: monitor.stop,
|
|
3491
|
+
waitForIdle: monitor.waitForIdle
|
|
3492
|
+
};
|
|
3493
|
+
}
|
|
3494
|
+
//#endregion
|
|
3642
3495
|
//#region extensions/matrix/src/matrix/monitor/recent-invite.ts
|
|
3643
3496
|
function shouldPromoteRecentInviteRoom(params) {
|
|
3644
3497
|
if (!params.roomInfo.nameResolved || !params.roomInfo.aliasesResolved) return false;
|
|
@@ -3653,18 +3506,18 @@ function shouldPromoteRecentInviteRoom(params) {
|
|
|
3653
3506
|
//#endregion
|
|
3654
3507
|
//#region extensions/matrix/src/matrix/monitor/startup.ts
|
|
3655
3508
|
const loadMatrixStartupMaintenanceDeps = createLazyRuntimeModule(() => Promise.all([
|
|
3656
|
-
import("./setup-core-
|
|
3657
|
-
import("./device-health-
|
|
3658
|
-
import("./setup-core-
|
|
3659
|
-
import("./startup-verification-
|
|
3509
|
+
import("./setup-core-DcqQbLZv.mjs").then((n) => n.f),
|
|
3510
|
+
import("./device-health-Ck2YpEVN.mjs").then((n) => n.t),
|
|
3511
|
+
import("./setup-core-DcqQbLZv.mjs").then((n) => n.u),
|
|
3512
|
+
import("./startup-verification-UkaoSldm.mjs")
|
|
3660
3513
|
]).then(([configUpdateModule, deviceHealthModule, profileModule, startupVerificationModule]) => ({
|
|
3661
3514
|
updateMatrixAccountConfig: configUpdateModule.updateMatrixAccountConfig,
|
|
3662
|
-
|
|
3515
|
+
listStaleOpenClawMatrixDevices: deviceHealthModule.listStaleOpenClawMatrixDevices,
|
|
3663
3516
|
syncMatrixOwnProfile: profileModule.syncMatrixOwnProfile,
|
|
3664
3517
|
ensureMatrixStartupVerification: startupVerificationModule.ensureMatrixStartupVerification
|
|
3665
3518
|
})));
|
|
3666
|
-
async function runMatrixStartupMaintenance(params
|
|
3667
|
-
const runtimeDeps =
|
|
3519
|
+
async function runMatrixStartupMaintenance(params) {
|
|
3520
|
+
const runtimeDeps = await loadMatrixStartupMaintenanceDeps();
|
|
3668
3521
|
throwIfMatrixStartupAborted(params.abortSignal);
|
|
3669
3522
|
try {
|
|
3670
3523
|
const profileSync = await runtimeDeps.syncMatrixOwnProfile({
|
|
@@ -3691,8 +3544,8 @@ async function runMatrixStartupMaintenance(params, deps) {
|
|
|
3691
3544
|
if (!(params.auth.encryption && params.client.crypto)) return;
|
|
3692
3545
|
try {
|
|
3693
3546
|
throwIfMatrixStartupAborted(params.abortSignal);
|
|
3694
|
-
const
|
|
3695
|
-
if (
|
|
3547
|
+
const staleOpenClawDevices = runtimeDeps.listStaleOpenClawMatrixDevices(await params.client.listOwnDevices());
|
|
3548
|
+
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.`);
|
|
3696
3549
|
} catch (err) {
|
|
3697
3550
|
if (isMatrixStartupAbortError(err)) throw err;
|
|
3698
3551
|
params.logger.debug?.("Failed to inspect matrix device hygiene (non-fatal)", { error: String(err) });
|
|
@@ -3720,10 +3573,6 @@ async function runMatrixStartupMaintenance(params, deps) {
|
|
|
3720
3573
|
}
|
|
3721
3574
|
//#endregion
|
|
3722
3575
|
//#region extensions/matrix/src/matrix/monitor/status.ts
|
|
3723
|
-
function cloneLastDisconnect(value) {
|
|
3724
|
-
if (!value || typeof value === "string") return value ?? null;
|
|
3725
|
-
return { ...value };
|
|
3726
|
-
}
|
|
3727
3576
|
function formatSyncError(error) {
|
|
3728
3577
|
if (!error) return null;
|
|
3729
3578
|
if (error instanceof Error) return error.message || error.name || "unknown";
|
|
@@ -3741,12 +3590,9 @@ function createMatrixMonitorStatusController(params) {
|
|
|
3741
3590
|
lifecycle: "starting"
|
|
3742
3591
|
};
|
|
3743
3592
|
const emit = () => {
|
|
3744
|
-
params.statusSink?.({
|
|
3745
|
-
...status,
|
|
3746
|
-
lastDisconnect: cloneLastDisconnect(status.lastDisconnect)
|
|
3747
|
-
});
|
|
3593
|
+
params.statusSink?.({ ...status });
|
|
3748
3594
|
};
|
|
3749
|
-
let startupComplete =
|
|
3595
|
+
let startupComplete = false;
|
|
3750
3596
|
let pendingReadyAt = null;
|
|
3751
3597
|
let pendingTransportActivity = false;
|
|
3752
3598
|
const noteConnected = (at = Date.now(), options) => {
|
|
@@ -3844,60 +3690,6 @@ function createMatrixMonitorStatusController(params) {
|
|
|
3844
3690
|
};
|
|
3845
3691
|
}
|
|
3846
3692
|
//#endregion
|
|
3847
|
-
//#region extensions/matrix/src/matrix/monitor/sync-lifecycle.ts
|
|
3848
|
-
function formatSyncLifecycleError(state, error) {
|
|
3849
|
-
if (error instanceof Error) return error;
|
|
3850
|
-
const message = typeof error === "string" && error.trim() ? error.trim() : void 0;
|
|
3851
|
-
if (state === "STOPPED") return new Error(message ?? "Matrix sync stopped unexpectedly");
|
|
3852
|
-
return new Error(message ?? `Matrix sync entered ${state} unexpectedly`);
|
|
3853
|
-
}
|
|
3854
|
-
function createMatrixMonitorSyncLifecycle(params) {
|
|
3855
|
-
let fatalError = null;
|
|
3856
|
-
let resolveFatalWait = null;
|
|
3857
|
-
let rejectFatalWait = null;
|
|
3858
|
-
const settleFatal = (error) => {
|
|
3859
|
-
if (fatalError) return;
|
|
3860
|
-
fatalError = error;
|
|
3861
|
-
rejectFatalWait?.(error);
|
|
3862
|
-
resolveFatalWait = null;
|
|
3863
|
-
rejectFatalWait = null;
|
|
3864
|
-
};
|
|
3865
|
-
const onSyncState = (state, _prevState, error) => {
|
|
3866
|
-
if (isMatrixTerminalSyncState(state) && !params.isStopping?.()) {
|
|
3867
|
-
const fatalErrorLocal = formatSyncLifecycleError(state, error);
|
|
3868
|
-
params.statusController.noteUnexpectedError(fatalErrorLocal);
|
|
3869
|
-
settleFatal(fatalErrorLocal);
|
|
3870
|
-
return;
|
|
3871
|
-
}
|
|
3872
|
-
if (fatalError) return;
|
|
3873
|
-
if (params.isStopping?.() && !isMatrixTerminalSyncState(state)) return;
|
|
3874
|
-
params.statusController.noteSyncState(state, error);
|
|
3875
|
-
};
|
|
3876
|
-
const onUnexpectedError = (error) => {
|
|
3877
|
-
if (params.isStopping?.()) return;
|
|
3878
|
-
params.statusController.noteUnexpectedError(error);
|
|
3879
|
-
settleFatal(error);
|
|
3880
|
-
};
|
|
3881
|
-
params.client.on("sync.state", onSyncState);
|
|
3882
|
-
params.client.on("sync.unexpected_error", onUnexpectedError);
|
|
3883
|
-
return {
|
|
3884
|
-
async waitForFatalStop() {
|
|
3885
|
-
if (fatalError) throw fatalError;
|
|
3886
|
-
await new Promise((resolve, reject) => {
|
|
3887
|
-
resolveFatalWait = resolve;
|
|
3888
|
-
rejectFatalWait = (error) => reject(error);
|
|
3889
|
-
});
|
|
3890
|
-
},
|
|
3891
|
-
dispose() {
|
|
3892
|
-
resolveFatalWait?.();
|
|
3893
|
-
resolveFatalWait = null;
|
|
3894
|
-
rejectFatalWait = null;
|
|
3895
|
-
params.client.off("sync.state", onSyncState);
|
|
3896
|
-
params.client.off("sync.unexpected_error", onUnexpectedError);
|
|
3897
|
-
}
|
|
3898
|
-
};
|
|
3899
|
-
}
|
|
3900
|
-
//#endregion
|
|
3901
3693
|
//#region extensions/matrix/src/matrix/monitor/index.ts
|
|
3902
3694
|
function resolveMatrixStreamingMode(streaming) {
|
|
3903
3695
|
const mode = streaming?.mode;
|
|
@@ -3910,6 +3702,12 @@ function resolveMatrixPreviewToolProgressEnabled(streaming) {
|
|
|
3910
3702
|
if (mode === "progress") return streaming?.progress?.toolProgress ?? streaming?.preview?.toolProgress ?? false;
|
|
3911
3703
|
return streaming?.preview?.toolProgress ?? true;
|
|
3912
3704
|
}
|
|
3705
|
+
function formatSyncLifecycleError(state, error) {
|
|
3706
|
+
if (error instanceof Error) return error;
|
|
3707
|
+
const message = typeof error === "string" && error.trim() ? error.trim() : void 0;
|
|
3708
|
+
if (state === "STOPPED") return new Error(message ?? "Matrix sync stopped unexpectedly");
|
|
3709
|
+
return new Error(message ?? `Matrix sync entered ${state} unexpectedly`);
|
|
3710
|
+
}
|
|
3913
3711
|
const DEFAULT_MEDIA_MAX_MB = 20;
|
|
3914
3712
|
async function monitorMatrixProvider(opts = {}) {
|
|
3915
3713
|
if (opts.abortSignal?.aborted) return;
|
|
@@ -3990,8 +3788,7 @@ async function monitorMatrixProvider(opts = {}) {
|
|
|
3990
3788
|
const statusController = createMatrixMonitorStatusController({
|
|
3991
3789
|
accountId: auth.accountId,
|
|
3992
3790
|
baseUrl: auth.homeserver,
|
|
3993
|
-
statusSink: opts.setStatus
|
|
3994
|
-
deferReadyUntilStartupComplete: true
|
|
3791
|
+
statusSink: opts.setStatus
|
|
3995
3792
|
});
|
|
3996
3793
|
let cleanedUp = false;
|
|
3997
3794
|
let cleanupPromise = null;
|
|
@@ -4005,7 +3802,12 @@ async function monitorMatrixProvider(opts = {}) {
|
|
|
4005
3802
|
});
|
|
4006
3803
|
let disposeAutoJoin = () => {};
|
|
4007
3804
|
let disposeMonitorEvents = () => {};
|
|
4008
|
-
let
|
|
3805
|
+
let disposeSyncIngress = () => {};
|
|
3806
|
+
let ingress;
|
|
3807
|
+
let fatalError = null;
|
|
3808
|
+
let resolveFatalWait = null;
|
|
3809
|
+
let rejectFatalWait = null;
|
|
3810
|
+
const isStopping = () => cleanedUp || monitorLifecycleSignal?.aborted === true;
|
|
4009
3811
|
let monitorSetupClosed = false;
|
|
4010
3812
|
const cleanup = (mode = "persist") => {
|
|
4011
3813
|
if (cleanupPromise) return cleanupPromise;
|
|
@@ -4069,6 +3871,29 @@ async function monitorMatrixProvider(opts = {}) {
|
|
|
4069
3871
|
}
|
|
4070
3872
|
if (isMatrixDisconnectedSyncState(state)) healthySyncSinceMs = void 0;
|
|
4071
3873
|
};
|
|
3874
|
+
const settleFatal = (error) => {
|
|
3875
|
+
if (fatalError) return;
|
|
3876
|
+
fatalError = error;
|
|
3877
|
+
rejectFatalWait?.(error);
|
|
3878
|
+
resolveFatalWait = null;
|
|
3879
|
+
rejectFatalWait = null;
|
|
3880
|
+
};
|
|
3881
|
+
const onSyncLifecycleState = (state, _prevState, error) => {
|
|
3882
|
+
if (isMatrixTerminalSyncState(state) && !isStopping()) {
|
|
3883
|
+
const fatalErrorLocal = formatSyncLifecycleError(state, error);
|
|
3884
|
+
statusController.noteUnexpectedError(fatalErrorLocal);
|
|
3885
|
+
settleFatal(fatalErrorLocal);
|
|
3886
|
+
return;
|
|
3887
|
+
}
|
|
3888
|
+
if (fatalError) return;
|
|
3889
|
+
if (isStopping() && !isMatrixTerminalSyncState(state)) return;
|
|
3890
|
+
statusController.noteSyncState(state, error);
|
|
3891
|
+
};
|
|
3892
|
+
const onUnexpectedSyncError = (error) => {
|
|
3893
|
+
if (isStopping()) return;
|
|
3894
|
+
statusController.noteUnexpectedError(error);
|
|
3895
|
+
settleFatal(error);
|
|
3896
|
+
};
|
|
4072
3897
|
const monitorRetirement = {
|
|
4073
3898
|
closeTaskAdmission: () => {
|
|
4074
3899
|
monitorSetupClosed = true;
|
|
@@ -4077,17 +3902,24 @@ async function monitorMatrixProvider(opts = {}) {
|
|
|
4077
3902
|
detachListeners: () => {
|
|
4078
3903
|
disposeAutoJoin();
|
|
4079
3904
|
disposeMonitorEvents();
|
|
3905
|
+
disposeSyncIngress();
|
|
4080
3906
|
client?.off("sync.state", onSyncState);
|
|
4081
|
-
|
|
3907
|
+
resolveFatalWait?.();
|
|
3908
|
+
resolveFatalWait = null;
|
|
3909
|
+
rejectFatalWait = null;
|
|
3910
|
+
client?.off("sync.state", onSyncLifecycleState);
|
|
3911
|
+
client?.off("sync.unexpected_error", onUnexpectedSyncError);
|
|
3912
|
+
},
|
|
3913
|
+
waitForTasks: async () => {
|
|
3914
|
+
await ingress?.stop();
|
|
3915
|
+
await monitorTaskRunner.waitForIdle();
|
|
4082
3916
|
},
|
|
4083
|
-
waitForTasks: monitorTaskRunner.waitForIdle,
|
|
4084
3917
|
cleanup: () => threadBindingManager?.stop()
|
|
4085
3918
|
};
|
|
4086
3919
|
try {
|
|
4087
3920
|
clientLease = await acquireSharedMatrixClient({
|
|
4088
3921
|
cfg,
|
|
4089
3922
|
auth: authWithLimit,
|
|
4090
|
-
startClient: false,
|
|
4091
3923
|
accountId: auth.accountId,
|
|
4092
3924
|
abortSignal: opts.abortSignal,
|
|
4093
3925
|
role: "monitor"
|
|
@@ -4095,18 +3927,10 @@ async function monitorMatrixProvider(opts = {}) {
|
|
|
4095
3927
|
client = clientLease.client;
|
|
4096
3928
|
monitorLifecycleSignal = opts.abortSignal ? AbortSignal.any([opts.abortSignal, clientLease.abortSignal]) : clientLease.abortSignal;
|
|
4097
3929
|
clientLease.registerMonitorRetirement(monitorRetirement);
|
|
4098
|
-
|
|
4099
|
-
|
|
4100
|
-
env: process.env
|
|
4101
|
-
});
|
|
4102
|
-
syncLifecycle = createMatrixMonitorSyncLifecycle({
|
|
4103
|
-
client,
|
|
4104
|
-
statusController,
|
|
4105
|
-
isStopping: () => cleanedUp || monitorLifecycleSignal?.aborted === true
|
|
4106
|
-
});
|
|
3930
|
+
client.on("sync.state", onSyncLifecycleState);
|
|
3931
|
+
client.on("sync.unexpected_error", onUnexpectedSyncError);
|
|
4107
3932
|
client.on("sync.state", onSyncState);
|
|
4108
|
-
const
|
|
4109
|
-
const { getRoomInfo, getMemberDisplayName, invalidateMemberDisplayName } = createMatrixRoomInfoResolver(client);
|
|
3933
|
+
const { getRoomInfo, getMemberDisplayName, invalidateMemberDisplayName, invalidateRoomName } = createMatrixRoomInfoResolver(client);
|
|
4110
3934
|
const isExplicitlyConfiguredRoom = async (roomId) => {
|
|
4111
3935
|
const roomInfoForConfig = needsRoomAliasesForConfig ? await getRoomInfo(roomId, { includeAliases: true }) : void 0;
|
|
4112
3936
|
const aliases = roomInfoForConfig ? [roomInfoForConfig.canonicalAlias ?? "", ...roomInfoForConfig.altAliases].filter(Boolean) : [];
|
|
@@ -4175,9 +3999,6 @@ async function monitorMatrixProvider(opts = {}) {
|
|
|
4175
3999
|
dmPolicy,
|
|
4176
4000
|
mediaMaxBytes,
|
|
4177
4001
|
historyLimit,
|
|
4178
|
-
startupMs,
|
|
4179
|
-
dropPreStartupMessages,
|
|
4180
|
-
inboundDeduper,
|
|
4181
4002
|
directTracker,
|
|
4182
4003
|
getRoomInfo,
|
|
4183
4004
|
getMemberDisplayName,
|
|
@@ -4218,21 +4039,30 @@ async function monitorMatrixProvider(opts = {}) {
|
|
|
4218
4039
|
needsRoomAliasesForConfig,
|
|
4219
4040
|
getRoomInfo,
|
|
4220
4041
|
invalidateMemberDisplayName,
|
|
4042
|
+
invalidateRoomName,
|
|
4221
4043
|
logVerboseMessage,
|
|
4222
4044
|
warnedEncryptedRooms,
|
|
4223
4045
|
warnedCryptoMissingRooms,
|
|
4224
4046
|
logger,
|
|
4225
4047
|
getHealthySyncSinceMs: () => healthySyncSinceMs,
|
|
4226
4048
|
formatNativeDependencyHint: core.system.formatNativeDependencyHint,
|
|
4227
|
-
onRoomMessage: handleRoomMessage,
|
|
4228
4049
|
runDetachedTask: monitorTaskRunner.runDetachedTask
|
|
4229
4050
|
});
|
|
4051
|
+
ingress = createMatrixIngressMonitor({
|
|
4052
|
+
accountId: effectiveAccountId,
|
|
4053
|
+
client,
|
|
4054
|
+
startupMs,
|
|
4055
|
+
dispatch: (roomId, event, lifecycle) => monitorTaskRunner.runTask(() => handleRoomMessage(roomId, event, lifecycle)),
|
|
4056
|
+
onError: (error) => logger.warn("matrix ingress failed", { error: String(error) })
|
|
4057
|
+
});
|
|
4058
|
+
disposeSyncIngress = await client.bindSyncIngress(ingress.admitSync);
|
|
4230
4059
|
logVerboseMessage("matrix: starting client");
|
|
4231
4060
|
await clientLease.start(monitorLifecycleSignal);
|
|
4232
4061
|
if (monitorSetupClosed) {
|
|
4233
4062
|
await cleanup("stop");
|
|
4234
4063
|
return;
|
|
4235
4064
|
}
|
|
4065
|
+
ingress.start();
|
|
4236
4066
|
logVerboseMessage("matrix: client started");
|
|
4237
4067
|
logger.info(`matrix: logged in as ${auth.userId}`);
|
|
4238
4068
|
monitorTaskRunner.runDetachedTask("deviceId backfill", async () => {
|
|
@@ -4282,7 +4112,13 @@ async function monitorMatrixProvider(opts = {}) {
|
|
|
4282
4112
|
} catch (err) {
|
|
4283
4113
|
logger.warn("matrix: failed during monitor shutdown cleanup", { error: String(err) });
|
|
4284
4114
|
}
|
|
4285
|
-
}),
|
|
4115
|
+
}), new Promise((resolve, reject) => {
|
|
4116
|
+
if (fatalError) reject(fatalError);
|
|
4117
|
+
else {
|
|
4118
|
+
resolveFatalWait = resolve;
|
|
4119
|
+
rejectFatalWait = reject;
|
|
4120
|
+
}
|
|
4121
|
+
})]);
|
|
4286
4122
|
await cleanup();
|
|
4287
4123
|
} catch (err) {
|
|
4288
4124
|
if (monitorSetupClosed || monitorLifecycleSignal?.aborted && isMatrixStartupAbortError(err)) {
|