@openclaw/matrix 2026.7.2-beta.7 → 2026.7.34
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/README.md +1 -1
- package/dist/{account-selection-kqquRzCf.js → .setup/account-selection-BOQeTqax.mjs} +18 -17
- package/dist/{approval-handler.runtime-DSeaIsGa.js → .setup/approval-handler.runtime-CEXm9_-p.mjs} +18 -28
- package/dist/{approval-ids-BdJGPAJT.js → .setup/approval-ids-DdFnDB3h.mjs} +1 -1
- package/dist/{approval-reaction-auth-BjOpELxu.js → .setup/approval-reaction-auth-CREvd7S7.mjs} +2 -2
- package/dist/.setup/approval-reactions-Cltyp8nL.mjs +113 -0
- package/dist/.setup/async-lock-BcLS4KOc.mjs +19 -0
- package/dist/{channel-vj788dNZ.js → .setup/channel-an4umty1.mjs} +186 -144
- package/dist/{channel.runtime-CLoF2S9T.js → .setup/channel.runtime-GHcIBJ7H.mjs} +51 -45
- package/dist/{cli-DMqfDE-q.js → .setup/cli-B3WYmv5U.mjs} +882 -901
- package/dist/{cli-metadata-C7D53SND.js → .setup/cli-metadata-RUKCn0wJ.mjs} +1 -1
- package/dist/{client-6eRENr7k.js → .setup/client-Ct0bUHCo.mjs} +5 -5
- package/dist/{shared-CUMWxcMz.js → .setup/client-DFBQtzCe.mjs} +422 -179
- package/dist/.setup/client-bootstrap-Be8jvNle.mjs +74 -0
- package/dist/{config-schema-Djxw3C6b.js → .setup/config-schema-D9J_vUF6.mjs} +89 -70
- package/dist/.setup/credentials-BhZlA0kL.mjs +56 -0
- package/dist/.setup/credentials-read-CRHg6XPm.mjs +114 -0
- package/dist/{credentials-write.runtime-Be9zNSUw.js → .setup/credentials-write.runtime-dWuLafsk.mjs} +1 -1
- package/dist/{crypto-runtime-D9_6J5tZ.js → .setup/crypto-runtime-D-cZa8P0.mjs} +81 -35
- package/dist/.setup/crypto-state-store-B43k3z3W.mjs +352 -0
- package/dist/{deps-CcVJfvRM.js → .setup/deps-Dy6yreL4.mjs} +92 -25
- package/dist/{device-health-B4-YXtJR.js → .setup/device-health-D4LBxuPq.mjs} +1 -6
- package/dist/{directory-live-C8dVBiCc.js → .setup/directory-live-BTEYxMwy.mjs} +10 -9
- package/dist/.setup/doctor-BGnvMzOR.mjs +169 -0
- package/dist/.setup/doctor-contract-DNJw0fdq.mjs +246 -0
- package/dist/{draft-stream-CtvOXq0Z.js → .setup/draft-stream-C-_OhpE8.mjs} +1 -6
- package/dist/{encryption-guidance-CbEFe38F.js → .setup/encryption-guidance-CpuuwmjL.mjs} +4 -3
- package/dist/{env-auth-CQsYbz-p.js → .setup/env-auth-CYJL1jNl.mjs} +2 -2
- package/dist/{env-vars-B0NxQnPk.js → .setup/env-vars-KzaYveuy.mjs} +1 -3
- package/dist/{exec-approval-resolver-BCgqRtZS.js → .setup/exec-approval-resolver-f9j6staN.mjs} +1 -2
- package/dist/{file-sync-store-DiiFsayX.js → .setup/file-sync-store-DU0cnYAz.mjs} +30 -25
- package/dist/{http-client-CycYxU9-.js → .setup/http-client-C954In2D.mjs} +45 -25
- package/dist/{idb-persistence-B6x7dMsF.js → .setup/idb-persistence-_HKTXkVC.mjs} +76 -78
- package/dist/{idb-persistence-lock-DAJ49nZX.js → .setup/idb-persistence-lock-B3fZXyF_.mjs} +1 -1
- package/dist/.setup/legacy-crypto-inspector-Byp8LCys.mjs +42 -0
- package/dist/.setup/legacy-crypto-restore-YQVoK1B2.mjs +93 -0
- package/dist/{logger-D0GCSDQq.js → .setup/logger-DpoogOgz.mjs} +1 -1
- package/dist/{logging-DV-p52N0.js → .setup/logging-CgxQOJJP.mjs} +2 -9
- package/dist/.setup/matrix-migration.runtime-BDH5c3fN.mjs +530 -0
- package/dist/{media-text-BTwzADS_.js → .setup/media-text-Cib-dxkn.mjs} +1 -1
- package/dist/{messages-DxQJkhxs.js → .setup/messages-D4DYGHYX.mjs} +15 -67
- package/dist/.setup/migration-snapshot-backup-CpgYhiUp.mjs +70 -0
- package/dist/.setup/migration-snapshot.runtime-O8qkMVaC.mjs +2 -0
- package/dist/{monitor-VyWlSLwo.js → .setup/monitor-DNcW_oAN.mjs} +2525 -2361
- package/dist/.setup/probe.runtime-CMPh0mFk.mjs +2 -0
- package/dist/{profile-update-CffmyW_4.js → .setup/profile-update-DzOL3Wiw.mjs} +5 -4
- package/dist/{reaction-events-B00WSi98.js → .setup/reaction-events-BcvgXxHb.mjs} +14 -64
- package/dist/{resolve-targets-nm2L48sh.js → .setup/resolve-targets-Bq80X9Sn.mjs} +3 -3
- package/dist/{resolver.runtime-DS6uPaEe.js → .setup/resolver.runtime-CeBHR9-T.mjs} +1 -1
- package/dist/{runtime-api-D1xI_cvh.js → .setup/runtime-api-CEsWNdil.mjs} +4 -4
- package/dist/.setup/runtime-setter-api-DGMubGUq.mjs +3 -0
- package/dist/{sdk-bUytQHx7.js → .setup/sdk-He1quVAq.mjs} +592 -261
- package/dist/.setup/secret-contract-api-CiTJ7pd5.mjs +3 -0
- package/dist/{secret-contract-M3hRmGO-.js → .setup/secret-contract-phPvlNfV.mjs} +53 -28
- package/dist/{send-BldGYG8g.js → .setup/send-CGgl0uTn.mjs} +133 -660
- package/dist/{setup-bootstrap-Deleiibz.js → .setup/setup-bootstrap-DUXBC8X2.mjs} +4 -4
- package/dist/{setup-core-BVfBv2ai.js → .setup/setup-core-bhdcEo7v.mjs} +239 -189
- package/dist/.setup/setup-plugin-api-CAwZ_Bi7.mjs +43 -0
- package/dist/.setup/setup-plugin-api-DIFVsOs3.mjs +2 -0
- package/dist/{setup-surface-BBq3WeqX.js → .setup/setup-surface-05_G-MnT.mjs} +149 -92
- package/dist/{startup-verification-wm3_i88s.js → .setup/startup-verification-BTwIGu1J.mjs} +7 -6
- package/dist/.setup/storage-NGZq5zet.mjs +432 -0
- package/dist/{storage-paths-gUmSydsW.js → .setup/storage-paths-BWo_ZEMC.mjs} +13 -2
- package/dist/{subagent-hooks-dkPAF6Et.js → .setup/subagent-hooks-BSWPJEmo.mjs} +2 -2
- package/dist/{thread-binding-api-DRbBZlhS.js → .setup/thread-binding-api-B7UaOoKv.mjs} +1 -1
- package/dist/{thread-bindings-DGbl3vDW.js → .setup/thread-bindings-DqmjG2on.mjs} +8 -8
- package/dist/{tool-actions.runtime-uu9blSqO.js → .setup/tool-actions.runtime-CXDLk2jg.mjs} +196 -332
- package/dist/{verification-DYMQ1QpI.js → .setup/verification-DeWOtZJr.mjs} +4 -3
- package/dist/api.js +9 -9
- package/dist/auth-presence.js +21 -13
- package/dist/channel-plugin-api.js +1 -1
- package/dist/cli-metadata.js +1 -1
- package/dist/contract-api.js +2 -2
- package/dist/doctor-contract-api.js +99 -524
- package/dist/helper-api.js +4 -4
- package/dist/index.js +1 -1
- package/dist/plugin-entry.handlers.runtime.js +2 -2
- package/dist/runtime-api.js +8 -8
- package/dist/runtime-heavy-api.js +3 -0
- package/dist/runtime-setter-api.js +1 -1
- package/dist/secret-contract-api.js +1 -1
- package/dist/session-binding-contract-api.js +3 -3
- package/dist/setup-entry.js +4 -3
- package/dist/setup-plugin-api.js +1 -44
- package/dist/subagent-hooks-api.js +1 -1
- package/dist/thread-binding-api.js +1 -1
- package/dist/thread-bindings-runtime.js +1 -1
- package/node_modules/@matrix-org/matrix-sdk-crypto-wasm/package.json +1 -1
- package/node_modules/@matrix-org/matrix-sdk-crypto-wasm/pkg/matrix_sdk_crypto_wasm.d.ts +2 -14
- package/node_modules/@matrix-org/matrix-sdk-crypto-wasm/pkg/matrix_sdk_crypto_wasm_bg.cjs +384 -409
- package/node_modules/@matrix-org/matrix-sdk-crypto-wasm/pkg/matrix_sdk_crypto_wasm_bg.js +224 -246
- package/node_modules/@matrix-org/matrix-sdk-crypto-wasm/pkg/matrix_sdk_crypto_wasm_bg.wasm +0 -0
- package/node_modules/@matrix-org/matrix-sdk-crypto-wasm/pkg/matrix_sdk_crypto_wasm_bg.wasm.d.ts +58 -59
- package/node_modules/markdown-it/README.md +18 -294
- package/node_modules/markdown-it/bin/markdown-it.mjs +2 -2
- package/node_modules/markdown-it/dist/browser/markdown-it.esm.min.mjs +3013 -0
- package/node_modules/markdown-it/dist/browser/markdown-it.esm.min.mjs.map +1 -0
- package/node_modules/markdown-it/dist/browser/markdown-it.umd.min.js +14 -0
- package/node_modules/markdown-it/dist/browser/markdown-it.umd.min.js.map +1 -0
- package/node_modules/markdown-it/dist/markdown-it.cjs.js +4420 -0
- package/node_modules/markdown-it/dist/markdown-it.cjs.js.map +1 -0
- package/node_modules/markdown-it/dist/markdown-it.d.cts +19 -0
- package/node_modules/markdown-it/dist/markdown-it.d.mts +950 -0
- package/node_modules/markdown-it/dist/{index.cjs.js → markdown-it.mjs} +1504 -1525
- package/node_modules/markdown-it/dist/markdown-it.mjs.map +1 -0
- package/node_modules/markdown-it/node_modules/argparse/LICENSE +1 -208
- package/node_modules/markdown-it/node_modules/argparse/README.md +46 -41
- package/node_modules/markdown-it/node_modules/argparse/lib/_colorize.js +72 -0
- package/node_modules/markdown-it/node_modules/argparse/lib/argparse.d.ts +292 -0
- package/node_modules/markdown-it/node_modules/argparse/{argparse.js → lib/argparse.js} +1142 -1029
- package/node_modules/markdown-it/node_modules/argparse/lib/difflib.js +190 -0
- package/node_modules/markdown-it/node_modules/argparse/lib/sub.js +4 -4
- package/node_modules/markdown-it/node_modules/argparse/lib/textwrap.js +28 -28
- package/node_modules/markdown-it/node_modules/argparse/package.json +18 -11
- package/node_modules/markdown-it/node_modules/entities/dist/decode-codepoint.d.ts +8 -0
- package/node_modules/markdown-it/node_modules/entities/dist/decode-codepoint.d.ts.map +1 -0
- package/node_modules/markdown-it/node_modules/entities/dist/decode-codepoint.js +46 -0
- package/node_modules/markdown-it/node_modules/entities/dist/decode-codepoint.js.map +1 -0
- package/node_modules/markdown-it/node_modules/entities/{lib → dist}/decode.d.ts +28 -45
- package/node_modules/markdown-it/node_modules/entities/dist/decode.d.ts.map +1 -0
- package/node_modules/markdown-it/node_modules/entities/{lib/esm → dist}/decode.js +189 -141
- package/node_modules/markdown-it/node_modules/entities/dist/decode.js.map +1 -0
- package/node_modules/markdown-it/node_modules/entities/{lib/esm → dist}/encode.d.ts +4 -2
- package/node_modules/markdown-it/node_modules/entities/dist/encode.d.ts.map +1 -0
- package/node_modules/markdown-it/node_modules/entities/dist/encode.js +90 -0
- package/node_modules/markdown-it/node_modules/entities/dist/encode.js.map +1 -0
- package/node_modules/markdown-it/node_modules/entities/{lib → dist}/escape.d.ts +15 -10
- package/node_modules/markdown-it/node_modules/entities/dist/escape.d.ts.map +1 -0
- package/node_modules/markdown-it/node_modules/entities/dist/escape.js +132 -0
- package/node_modules/markdown-it/node_modules/entities/dist/escape.js.map +1 -0
- package/node_modules/markdown-it/node_modules/entities/dist/generated/decode-data-html.d.ts +3 -0
- package/node_modules/markdown-it/node_modules/entities/dist/generated/decode-data-html.d.ts.map +1 -0
- package/node_modules/markdown-it/node_modules/entities/dist/generated/decode-data-html.js +5 -0
- package/node_modules/markdown-it/node_modules/entities/dist/generated/decode-data-html.js.map +1 -0
- package/node_modules/markdown-it/node_modules/entities/dist/generated/decode-data-xml.d.ts +3 -0
- package/node_modules/markdown-it/node_modules/entities/dist/generated/decode-data-xml.d.ts.map +1 -0
- package/node_modules/markdown-it/node_modules/entities/dist/generated/decode-data-xml.js +5 -0
- package/node_modules/markdown-it/node_modules/entities/dist/generated/decode-data-xml.js.map +1 -0
- package/node_modules/markdown-it/node_modules/entities/dist/generated/encode-html.d.ts +5 -0
- package/node_modules/markdown-it/node_modules/entities/dist/generated/encode-html.d.ts.map +1 -0
- package/node_modules/markdown-it/node_modules/entities/dist/generated/encode-html.js +12 -0
- package/node_modules/markdown-it/node_modules/entities/dist/generated/encode-html.js.map +1 -0
- package/node_modules/markdown-it/node_modules/entities/{lib/esm → dist}/index.d.ts +14 -21
- package/node_modules/markdown-it/node_modules/entities/dist/index.d.ts.map +1 -0
- package/node_modules/markdown-it/node_modules/entities/dist/index.js +91 -0
- package/node_modules/markdown-it/node_modules/entities/dist/index.js.map +1 -0
- package/node_modules/markdown-it/node_modules/entities/dist/internal/bin-trie-flags.d.ts +17 -0
- package/node_modules/markdown-it/node_modules/entities/dist/internal/bin-trie-flags.d.ts.map +1 -0
- package/node_modules/markdown-it/node_modules/entities/dist/internal/bin-trie-flags.js +18 -0
- package/node_modules/markdown-it/node_modules/entities/dist/internal/bin-trie-flags.js.map +1 -0
- package/node_modules/markdown-it/node_modules/entities/dist/internal/decode-shared.d.ts +7 -0
- package/node_modules/markdown-it/node_modules/entities/dist/internal/decode-shared.d.ts.map +1 -0
- package/node_modules/markdown-it/node_modules/entities/dist/internal/decode-shared.js +17 -0
- package/node_modules/markdown-it/node_modules/entities/dist/internal/decode-shared.js.map +1 -0
- package/node_modules/markdown-it/node_modules/entities/dist/internal/encode-shared.d.ts +33 -0
- package/node_modules/markdown-it/node_modules/entities/dist/internal/encode-shared.d.ts.map +1 -0
- package/node_modules/markdown-it/node_modules/entities/dist/internal/encode-shared.js +93 -0
- package/node_modules/markdown-it/node_modules/entities/dist/internal/encode-shared.js.map +1 -0
- package/node_modules/markdown-it/node_modules/entities/package.json +63 -70
- package/node_modules/markdown-it/node_modules/entities/readme.md +54 -45
- package/node_modules/markdown-it/node_modules/entities/src/decode-codepoint.ts +50 -0
- package/node_modules/markdown-it/node_modules/entities/src/decode.ts +671 -0
- package/node_modules/markdown-it/node_modules/entities/src/encode.ts +95 -0
- package/node_modules/markdown-it/node_modules/entities/src/escape.ts +160 -0
- package/node_modules/markdown-it/node_modules/entities/src/generated/decode-data-html.ts +7 -0
- package/node_modules/markdown-it/node_modules/entities/src/generated/decode-data-xml.ts +7 -0
- package/node_modules/markdown-it/node_modules/entities/src/generated/encode-html.ts +18 -0
- package/node_modules/markdown-it/node_modules/entities/src/index.ts +162 -0
- package/node_modules/markdown-it/node_modules/entities/src/internal/bin-trie-flags.ts +16 -0
- package/node_modules/markdown-it/node_modules/entities/src/internal/decode-shared.ts +18 -0
- package/node_modules/markdown-it/node_modules/entities/src/internal/encode-shared.ts +123 -0
- package/node_modules/markdown-it/node_modules/linkify-it/README.md +49 -86
- package/node_modules/markdown-it/node_modules/linkify-it/build/index.cjs.js +636 -825
- package/node_modules/markdown-it/node_modules/linkify-it/build/index.cjs.js.map +1 -0
- package/node_modules/markdown-it/node_modules/linkify-it/build/index.d.ts +236 -0
- package/node_modules/markdown-it/node_modules/linkify-it/build/index.mjs +538 -0
- package/node_modules/markdown-it/node_modules/linkify-it/build/index.mjs.map +1 -0
- package/node_modules/markdown-it/node_modules/linkify-it/package.json +23 -20
- package/node_modules/markdown-it/node_modules/uc.micro/README.md +18 -1
- package/node_modules/markdown-it/node_modules/uc.micro/build/index.cjs.js +13 -18
- package/node_modules/markdown-it/node_modules/uc.micro/build/index.d.ts +6 -0
- package/node_modules/markdown-it/node_modules/uc.micro/build/index.mjs +8 -0
- package/node_modules/markdown-it/node_modules/uc.micro/package.json +12 -17
- package/node_modules/markdown-it/package.json +47 -30
- package/node_modules/matrix-js-sdk/CHANGELOG.md +0 -11
- package/node_modules/matrix-js-sdk/package.json +1 -1
- package/node_modules/music-metadata/lib/common/Util.d.ts +1 -1
- package/node_modules/music-metadata/lib/common/Util.js +1 -7
- package/node_modules/music-metadata/lib/id3v2/FrameHeader.js +3 -23
- package/node_modules/music-metadata/lib/id3v2/FrameParser.js +2 -2
- package/node_modules/music-metadata/lib/id3v2/ID3v2Token.js +1 -1
- package/node_modules/music-metadata/lib/mp4/AtomToken.js +13 -38
- package/node_modules/music-metadata/lib/mpeg/MpegParser.js +1 -1
- package/node_modules/music-metadata/package.json +6 -6
- package/node_modules/typebox/build/compile/validator.d.mts +4 -1
- package/node_modules/typebox/build/guard/guard.d.mts +1 -1
- package/node_modules/typebox/build/guard/guard.mjs +2 -5
- package/node_modules/typebox/build/guard/string.mjs +4 -16
- package/node_modules/typebox/build/schema/engine/_functions.mjs +15 -34
- package/node_modules/typebox/build/type/action/readonly_object.d.mts +0 -5
- package/node_modules/typebox/build/type/action/readonly_object.mjs +0 -8
- package/node_modules/typebox/build/typebox.d.mts +1 -1
- package/node_modules/typebox/build/typebox.mjs +1 -1
- package/node_modules/typebox/package.json +1 -1
- package/node_modules/typebox/readme.md +32 -29
- package/openclaw.plugin.json +146 -152
- package/package.json +31 -114
- package/dist/accounts-DfngqebB.js +0 -130
- package/dist/active-client-DXvz2gCo.js +0 -20
- package/dist/approval-reactions-D-BxBK_L.js +0 -202
- package/dist/client-Dbso3-0V.js +0 -30
- package/dist/client-bootstrap-XsIkHNt0.js +0 -110
- package/dist/create-client-BmSU-q-D.js +0 -61
- package/dist/credentials-W2EmwRhu.js +0 -65
- package/dist/credentials-read-DVmFCm7X.js +0 -77
- package/dist/doctor-CM8ijNpW.js +0 -64
- package/dist/doctor-contract-BMSJkkAE.js +0 -167
- package/dist/inbound-dedupe-CaBLblef.js +0 -48
- package/dist/probe.runtime-BuieqmS3.js +0 -3
- package/dist/record-shared-CWWx6fvI.js +0 -2
- package/dist/recovery-key-store-BNnHvXdk.js +0 -275
- package/dist/room-info-CAFZ3Z9J.js +0 -87
- package/dist/route-DY6at4qJ.js +0 -161
- package/dist/storage-BvAkgzvT.js +0 -685
- package/node_modules/markdown-it/dist/index.cjs.js.map +0 -1
- package/node_modules/markdown-it/dist/markdown-it.js +0 -3975
- package/node_modules/markdown-it/dist/markdown-it.js.map +0 -1
- package/node_modules/markdown-it/dist/markdown-it.min.js +0 -3
- package/node_modules/markdown-it/dist/markdown-it.min.js.map +0 -1
- package/node_modules/markdown-it/index.mjs +0 -1
- package/node_modules/markdown-it/lib/common/html_blocks.mjs +0 -67
- package/node_modules/markdown-it/lib/common/html_re.mjs +0 -25
- package/node_modules/markdown-it/lib/common/utils.mjs +0 -324
- package/node_modules/markdown-it/lib/helpers/index.mjs +0 -11
- package/node_modules/markdown-it/lib/helpers/parse_link_destination.mjs +0 -77
- package/node_modules/markdown-it/lib/helpers/parse_link_label.mjs +0 -49
- package/node_modules/markdown-it/lib/helpers/parse_link_title.mjs +0 -66
- package/node_modules/markdown-it/lib/index.mjs +0 -565
- package/node_modules/markdown-it/lib/parser_block.mjs +0 -134
- package/node_modules/markdown-it/lib/parser_core.mjs +0 -62
- package/node_modules/markdown-it/lib/parser_inline.mjs +0 -197
- package/node_modules/markdown-it/lib/presets/commonmark.mjs +0 -88
- package/node_modules/markdown-it/lib/presets/default.mjs +0 -47
- package/node_modules/markdown-it/lib/presets/zero.mjs +0 -70
- package/node_modules/markdown-it/lib/renderer.mjs +0 -322
- package/node_modules/markdown-it/lib/ruler.mjs +0 -340
- package/node_modules/markdown-it/lib/rules_block/blockquote.mjs +0 -209
- package/node_modules/markdown-it/lib/rules_block/code.mjs +0 -30
- package/node_modules/markdown-it/lib/rules_block/fence.mjs +0 -94
- package/node_modules/markdown-it/lib/rules_block/heading.mjs +0 -51
- package/node_modules/markdown-it/lib/rules_block/hr.mjs +0 -40
- package/node_modules/markdown-it/lib/rules_block/html_block.mjs +0 -80
- package/node_modules/markdown-it/lib/rules_block/lheading.mjs +0 -85
- package/node_modules/markdown-it/lib/rules_block/list.mjs +0 -331
- package/node_modules/markdown-it/lib/rules_block/paragraph.mjs +0 -48
- package/node_modules/markdown-it/lib/rules_block/reference.mjs +0 -212
- package/node_modules/markdown-it/lib/rules_block/state_block.mjs +0 -220
- package/node_modules/markdown-it/lib/rules_block/table.mjs +0 -228
- package/node_modules/markdown-it/lib/rules_core/block.mjs +0 -13
- package/node_modules/markdown-it/lib/rules_core/inline.mjs +0 -11
- package/node_modules/markdown-it/lib/rules_core/linkify.mjs +0 -134
- package/node_modules/markdown-it/lib/rules_core/normalize.mjs +0 -17
- package/node_modules/markdown-it/lib/rules_core/replacements.mjs +0 -101
- package/node_modules/markdown-it/lib/rules_core/smartquotes.mjs +0 -209
- package/node_modules/markdown-it/lib/rules_core/state_core.mjs +0 -17
- package/node_modules/markdown-it/lib/rules_core/text_join.mjs +0 -43
- package/node_modules/markdown-it/lib/rules_inline/autolink.mjs +0 -72
- package/node_modules/markdown-it/lib/rules_inline/backticks.mjs +0 -60
- package/node_modules/markdown-it/lib/rules_inline/balance_pairs.mjs +0 -124
- package/node_modules/markdown-it/lib/rules_inline/emphasis.mjs +0 -123
- package/node_modules/markdown-it/lib/rules_inline/entity.mjs +0 -51
- package/node_modules/markdown-it/lib/rules_inline/escape.mjs +0 -83
- package/node_modules/markdown-it/lib/rules_inline/fragments_join.mjs +0 -38
- package/node_modules/markdown-it/lib/rules_inline/html_inline.mjs +0 -50
- package/node_modules/markdown-it/lib/rules_inline/image.mjs +0 -138
- package/node_modules/markdown-it/lib/rules_inline/link.mjs +0 -139
- package/node_modules/markdown-it/lib/rules_inline/linkify.mjs +0 -63
- package/node_modules/markdown-it/lib/rules_inline/newline.mjs +0 -42
- package/node_modules/markdown-it/lib/rules_inline/state_inline.mjs +0 -154
- package/node_modules/markdown-it/lib/rules_inline/strikethrough.mjs +0 -127
- package/node_modules/markdown-it/lib/rules_inline/text.mjs +0 -86
- package/node_modules/markdown-it/lib/token.mjs +0 -191
- package/node_modules/markdown-it/node_modules/argparse/CHANGELOG.md +0 -216
- package/node_modules/markdown-it/node_modules/entities/lib/decode.d.ts.map +0 -1
- package/node_modules/markdown-it/node_modules/entities/lib/decode.js +0 -536
- package/node_modules/markdown-it/node_modules/entities/lib/decode.js.map +0 -1
- package/node_modules/markdown-it/node_modules/entities/lib/decode_codepoint.d.ts +0 -19
- package/node_modules/markdown-it/node_modules/entities/lib/decode_codepoint.d.ts.map +0 -1
- package/node_modules/markdown-it/node_modules/entities/lib/decode_codepoint.js +0 -76
- package/node_modules/markdown-it/node_modules/entities/lib/decode_codepoint.js.map +0 -1
- package/node_modules/markdown-it/node_modules/entities/lib/encode.d.ts +0 -22
- package/node_modules/markdown-it/node_modules/entities/lib/encode.d.ts.map +0 -1
- package/node_modules/markdown-it/node_modules/entities/lib/encode.js +0 -77
- package/node_modules/markdown-it/node_modules/entities/lib/encode.js.map +0 -1
- package/node_modules/markdown-it/node_modules/entities/lib/escape.d.ts.map +0 -1
- package/node_modules/markdown-it/node_modules/entities/lib/escape.js +0 -122
- package/node_modules/markdown-it/node_modules/entities/lib/escape.js.map +0 -1
- package/node_modules/markdown-it/node_modules/entities/lib/esm/decode.d.ts +0 -211
- package/node_modules/markdown-it/node_modules/entities/lib/esm/decode.d.ts.map +0 -1
- package/node_modules/markdown-it/node_modules/entities/lib/esm/decode.js.map +0 -1
- package/node_modules/markdown-it/node_modules/entities/lib/esm/decode_codepoint.d.ts +0 -19
- package/node_modules/markdown-it/node_modules/entities/lib/esm/decode_codepoint.d.ts.map +0 -1
- package/node_modules/markdown-it/node_modules/entities/lib/esm/decode_codepoint.js +0 -71
- package/node_modules/markdown-it/node_modules/entities/lib/esm/decode_codepoint.js.map +0 -1
- package/node_modules/markdown-it/node_modules/entities/lib/esm/encode.d.ts.map +0 -1
- package/node_modules/markdown-it/node_modules/entities/lib/esm/encode.js +0 -69
- package/node_modules/markdown-it/node_modules/entities/lib/esm/encode.js.map +0 -1
- package/node_modules/markdown-it/node_modules/entities/lib/esm/escape.d.ts +0 -43
- package/node_modules/markdown-it/node_modules/entities/lib/esm/escape.d.ts.map +0 -1
- package/node_modules/markdown-it/node_modules/entities/lib/esm/escape.js +0 -116
- package/node_modules/markdown-it/node_modules/entities/lib/esm/escape.js.map +0 -1
- package/node_modules/markdown-it/node_modules/entities/lib/esm/generated/decode-data-html.d.ts +0 -3
- package/node_modules/markdown-it/node_modules/entities/lib/esm/generated/decode-data-html.d.ts.map +0 -1
- package/node_modules/markdown-it/node_modules/entities/lib/esm/generated/decode-data-html.js +0 -7
- package/node_modules/markdown-it/node_modules/entities/lib/esm/generated/decode-data-html.js.map +0 -1
- package/node_modules/markdown-it/node_modules/entities/lib/esm/generated/decode-data-xml.d.ts +0 -3
- package/node_modules/markdown-it/node_modules/entities/lib/esm/generated/decode-data-xml.d.ts.map +0 -1
- package/node_modules/markdown-it/node_modules/entities/lib/esm/generated/decode-data-xml.js +0 -7
- package/node_modules/markdown-it/node_modules/entities/lib/esm/generated/decode-data-xml.js.map +0 -1
- package/node_modules/markdown-it/node_modules/entities/lib/esm/generated/encode-html.d.ts +0 -8
- package/node_modules/markdown-it/node_modules/entities/lib/esm/generated/encode-html.d.ts.map +0 -1
- package/node_modules/markdown-it/node_modules/entities/lib/esm/generated/encode-html.js +0 -10
- package/node_modules/markdown-it/node_modules/entities/lib/esm/generated/encode-html.js.map +0 -1
- package/node_modules/markdown-it/node_modules/entities/lib/esm/index.d.ts.map +0 -1
- package/node_modules/markdown-it/node_modules/entities/lib/esm/index.js +0 -99
- package/node_modules/markdown-it/node_modules/entities/lib/esm/index.js.map +0 -1
- package/node_modules/markdown-it/node_modules/entities/lib/esm/package.json +0 -1
- package/node_modules/markdown-it/node_modules/entities/lib/generated/decode-data-html.d.ts +0 -3
- package/node_modules/markdown-it/node_modules/entities/lib/generated/decode-data-html.d.ts.map +0 -1
- package/node_modules/markdown-it/node_modules/entities/lib/generated/decode-data-html.js +0 -9
- package/node_modules/markdown-it/node_modules/entities/lib/generated/decode-data-html.js.map +0 -1
- package/node_modules/markdown-it/node_modules/entities/lib/generated/decode-data-xml.d.ts +0 -3
- package/node_modules/markdown-it/node_modules/entities/lib/generated/decode-data-xml.d.ts.map +0 -1
- package/node_modules/markdown-it/node_modules/entities/lib/generated/decode-data-xml.js +0 -9
- package/node_modules/markdown-it/node_modules/entities/lib/generated/decode-data-xml.js.map +0 -1
- package/node_modules/markdown-it/node_modules/entities/lib/generated/encode-html.d.ts +0 -8
- package/node_modules/markdown-it/node_modules/entities/lib/generated/encode-html.d.ts.map +0 -1
- package/node_modules/markdown-it/node_modules/entities/lib/generated/encode-html.js +0 -12
- package/node_modules/markdown-it/node_modules/entities/lib/generated/encode-html.js.map +0 -1
- package/node_modules/markdown-it/node_modules/entities/lib/index.d.ts +0 -96
- package/node_modules/markdown-it/node_modules/entities/lib/index.d.ts.map +0 -1
- package/node_modules/markdown-it/node_modules/entities/lib/index.js +0 -126
- package/node_modules/markdown-it/node_modules/entities/lib/index.js.map +0 -1
- package/node_modules/markdown-it/node_modules/linkify-it/index.mjs +0 -646
- package/node_modules/markdown-it/node_modules/linkify-it/lib/re.mjs +0 -193
- package/node_modules/markdown-it/node_modules/uc.micro/categories/Cc/regex.mjs +0 -1
- package/node_modules/markdown-it/node_modules/uc.micro/categories/Cf/regex.mjs +0 -1
- package/node_modules/markdown-it/node_modules/uc.micro/categories/P/regex.mjs +0 -1
- package/node_modules/markdown-it/node_modules/uc.micro/categories/S/regex.mjs +0 -1
- package/node_modules/markdown-it/node_modules/uc.micro/categories/Z/regex.mjs +0 -1
- package/node_modules/markdown-it/node_modules/uc.micro/index.mjs +0 -8
- package/node_modules/markdown-it/node_modules/uc.micro/properties/Any/regex.mjs +0 -1
- /package/dist/{account-config-BZWN9tGS.js → .setup/account-config-BZWN9tGS.mjs} +0 -0
- /package/dist/{backup-health-Dm_YMVFT.js → .setup/backup-health-Dm_YMVFT.mjs} +0 -0
- /package/dist/{config-paths-CnREYb1Y.js → .setup/config-paths-CnREYb1Y.mjs} +0 -0
- /package/dist/{config-secret-input.runtime-CwsP3--c.js → .setup/config-secret-input.runtime-CwsP3--c.mjs} +0 -0
- /package/dist/{crypto-node.runtime-6Aj_ltHQ.js → .setup/crypto-node.runtime-6Aj_ltHQ.mjs} +0 -0
- /package/dist/{errors-C47hvAF8.js → .setup/errors-C47hvAF8.mjs} +0 -0
- /package/dist/{preflight-audio.runtime-BZxxQsxY.js → .setup/preflight-audio.runtime-BZxxQsxY.mjs} +0 -0
- /package/dist/{reaction-common-DkrQdBSZ.js → .setup/reaction-common-DkrQdBSZ.mjs} +0 -0
- /package/dist/{rolldown-runtime-8H4AJuhK.js → .setup/rolldown-runtime-8H4AJuhK.mjs} +0 -0
- /package/dist/{runtime-6S3DNFNv.js → .setup/runtime-6S3DNFNv.mjs} +0 -0
- /package/dist/{runtime-BefyhPWv.js → .setup/runtime-BefyhPWv.mjs} +0 -0
- /package/dist/{sync-state-CWbp0QSY.js → .setup/sync-state-CWbp0QSY.mjs} +0 -0
- /package/dist/{target-ids-B-5aQxwn.js → .setup/target-ids-B-5aQxwn.mjs} +0 -0
- /package/dist/{thread-bindings-shared-CKnY4LSd.js → .setup/thread-bindings-shared-CKnY4LSd.mjs} +0 -0
- /package/dist/{timeout-abort-signal-DMrgRFIy.js → .setup/timeout-abort-signal-DMrgRFIy.mjs} +0 -0
- /package/dist/{url-validation-GRHde6lq.js → .setup/url-validation-GRHde6lq.mjs} +0 -0
|
@@ -1,18 +1,16 @@
|
|
|
1
|
-
import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.
|
|
2
|
-
import { a as resolveMatrixAccountConfig } from "./account-config-BZWN9tGS.
|
|
3
|
-
import { t as getMatrixRuntime } from "./runtime-6S3DNFNv.
|
|
4
|
-
import { r as normalizeMatrixResolvableTarget, t as isMatrixQualifiedUserId } from "./target-ids-B-5aQxwn.
|
|
5
|
-
import { n as MATRIX_REACTION_EVENT_TYPE, r as buildMatrixReactionContent, t as MATRIX_ANNOTATION_RELATION_TYPE } from "./reaction-common-DkrQdBSZ.
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.mjs";
|
|
2
|
+
import { a as resolveMatrixAccountConfig } from "./account-config-BZWN9tGS.mjs";
|
|
3
|
+
import { t as getMatrixRuntime } from "./runtime-6S3DNFNv.mjs";
|
|
4
|
+
import { r as normalizeMatrixResolvableTarget, t as isMatrixQualifiedUserId } from "./target-ids-B-5aQxwn.mjs";
|
|
5
|
+
import { n as MATRIX_REACTION_EVENT_TYPE, r as buildMatrixReactionContent, t as MATRIX_ANNOTATION_RELATION_TYPE } from "./reaction-common-DkrQdBSZ.mjs";
|
|
6
6
|
import { createLazyRuntimeModule } from "openclaw/plugin-sdk/lazy-runtime";
|
|
7
7
|
import { createMessageReceiptFromOutboundResults } from "openclaw/plugin-sdk/channel-outbound";
|
|
8
|
-
import { normalizeLowercaseStringOrEmpty,
|
|
9
|
-
import { FormatCapabilityProfile, convertMarkdownTables, findCodeRegions, isInsideCode, markdownToIR, renderMarkdownWithMarkers, tokenizeHtmlTags } from "openclaw/plugin-sdk/text-chunking";
|
|
8
|
+
import { normalizeLowercaseStringOrEmpty, normalizeOptionalString, normalizeOptionalStringifiedId } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
10
9
|
import { requireRuntimeConfig } from "openclaw/plugin-sdk/plugin-config-runtime";
|
|
11
10
|
import { loadOutboundMediaFromUrl } from "openclaw/plugin-sdk/outbound-media";
|
|
12
11
|
import { normalizePollInput } from "openclaw/plugin-sdk/poll-runtime";
|
|
13
12
|
import MarkdownIt from "markdown-it";
|
|
14
13
|
import { isAutoLinkedFileRef } from "openclaw/plugin-sdk/text-autolink-runtime";
|
|
15
|
-
import { isVoiceMessageCompatibleAudio } from "openclaw/plugin-sdk/media-runtime";
|
|
16
14
|
import { parseBuffer } from "music-metadata";
|
|
17
15
|
import { KeyedAsyncQueue } from "openclaw/plugin-sdk/keyed-async-queue";
|
|
18
16
|
//#region extensions/matrix/src/matrix/poll-types.ts
|
|
@@ -229,296 +227,59 @@ function buildPollResponseContent(pollEventId, answerIds) {
|
|
|
229
227
|
};
|
|
230
228
|
}
|
|
231
229
|
//#endregion
|
|
232
|
-
//#region extensions/matrix/src/matrix/
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
if (
|
|
243
|
-
return {
|
|
244
|
-
open: markers[0] ?? "",
|
|
245
|
-
close: markers[1] ?? "",
|
|
246
|
-
padding: markers[2] ?? ""
|
|
247
|
-
};
|
|
248
|
-
}
|
|
249
|
-
const MATRIX_FORMAT_PROFILE = FormatCapabilityProfile.define({
|
|
250
|
-
mechanism: "html",
|
|
251
|
-
constructs: {
|
|
252
|
-
taskList: "fallback",
|
|
253
|
-
image: "fallback"
|
|
254
|
-
},
|
|
255
|
-
chunk: {
|
|
256
|
-
limit: 4e3,
|
|
257
|
-
unit: "chars"
|
|
258
|
-
}
|
|
259
|
-
});
|
|
260
|
-
function isMarkdownEscaped(markdown, index) {
|
|
261
|
-
let slashCount = 0;
|
|
262
|
-
let cursor = index - 1;
|
|
263
|
-
while (cursor >= 0 && markdown[cursor] === "\\") {
|
|
264
|
-
slashCount += 1;
|
|
265
|
-
cursor -= 1;
|
|
266
|
-
}
|
|
267
|
-
return slashCount % 2 === 1;
|
|
268
|
-
}
|
|
269
|
-
function projectMatrixMarkdown(markdown) {
|
|
270
|
-
return renderMarkdownWithMarkers({
|
|
271
|
-
text: (markdown ?? "").replace(/\r\n?/gu, "\n"),
|
|
272
|
-
styles: [],
|
|
273
|
-
links: []
|
|
274
|
-
}, {
|
|
275
|
-
styleMarkers: {},
|
|
276
|
-
escapeText: (text) => text
|
|
277
|
-
}, MATRIX_FORMAT_PROFILE);
|
|
230
|
+
//#region extensions/matrix/src/matrix/send/client.ts
|
|
231
|
+
const loadMatrixSendClientRuntime = createLazyRuntimeModule(() => import("./client-bootstrap-Be8jvNle.mjs").then((n) => n.t));
|
|
232
|
+
function resolveMediaMaxBytes(accountId, cfg) {
|
|
233
|
+
if (!cfg) throw new Error("Matrix media limits requires a resolved runtime config. Load and resolve config at the command or gateway boundary, then pass cfg through the runtime path.");
|
|
234
|
+
const resolvedCfg = requireRuntimeConfig(cfg, "Matrix media limits");
|
|
235
|
+
const matrixCfg = resolveMatrixAccountConfig({
|
|
236
|
+
cfg: resolvedCfg,
|
|
237
|
+
accountId
|
|
238
|
+
});
|
|
239
|
+
const mediaMaxMb = typeof matrixCfg.mediaMaxMb === "number" ? matrixCfg.mediaMaxMb : void 0;
|
|
240
|
+
if (typeof mediaMaxMb === "number") return mediaMaxMb * 1024 * 1024;
|
|
278
241
|
}
|
|
279
|
-
function
|
|
280
|
-
return
|
|
242
|
+
async function withResolvedMatrixSendClient(opts, run) {
|
|
243
|
+
return await withResolvedMatrixClient({
|
|
244
|
+
...opts,
|
|
245
|
+
readiness: "started"
|
|
246
|
+
}, run, "persist");
|
|
281
247
|
}
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
typographer: false
|
|
288
|
-
});
|
|
289
|
-
function findMatrixTableSourceRanges(markdown) {
|
|
290
|
-
const lineStarts = [0];
|
|
291
|
-
for (let index = 0; index < markdown.length; index += 1) if (markdown[index] === "\n") lineStarts.push(index + 1);
|
|
292
|
-
lineStarts.push(markdown.length);
|
|
293
|
-
return tableParser.parse(markdown, {}).flatMap((token) => {
|
|
294
|
-
if (token.type !== "table_open" || !token.map) return [];
|
|
295
|
-
return [{
|
|
296
|
-
start: lineStarts[token.map[0]] ?? 0,
|
|
297
|
-
end: lineStarts[token.map[1]] ?? markdown.length
|
|
298
|
-
}];
|
|
299
|
-
});
|
|
248
|
+
async function withResolvedMatrixControlClient(opts, run) {
|
|
249
|
+
return await withResolvedMatrixClient({
|
|
250
|
+
...opts,
|
|
251
|
+
readiness: "none"
|
|
252
|
+
}, run);
|
|
300
253
|
}
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
const
|
|
304
|
-
|
|
305
|
-
linkify: true,
|
|
306
|
-
typographer: false
|
|
307
|
-
});
|
|
308
|
-
function findInlineMetadataRanges(markdown, references) {
|
|
309
|
-
const ranges = [];
|
|
310
|
-
const labelStack = [];
|
|
311
|
-
const codeRegions = findCodeRegions(markdown);
|
|
312
|
-
const underlineTags = [...tokenizeHtmlTags(markdown)].filter((tag) => tag.name === "u" || tag.name === "ins");
|
|
313
|
-
for (let index = 0; index < markdown.length - 1; index += 1) {
|
|
314
|
-
const underlineTag = underlineTags.find((tag) => tag.start === index);
|
|
315
|
-
if (underlineTag) {
|
|
316
|
-
index = underlineTag.end - 1;
|
|
317
|
-
continue;
|
|
318
|
-
}
|
|
319
|
-
if (isInsideCode(index, codeRegions)) continue;
|
|
320
|
-
if (markdown[index] === "\n" && markdown[index + 1] === "\n") {
|
|
321
|
-
labelStack.length = 0;
|
|
322
|
-
continue;
|
|
323
|
-
}
|
|
324
|
-
if (markdown[index] === "[" && !isMarkdownEscaped(markdown, index)) {
|
|
325
|
-
labelStack.push(index);
|
|
326
|
-
continue;
|
|
327
|
-
}
|
|
328
|
-
if (markdown[index] === "]" && markdown[index + 1] === "(" && !isMarkdownEscaped(markdown, index) && labelStack.pop() !== void 0) {
|
|
329
|
-
const start = index + 2;
|
|
330
|
-
let cursor = start;
|
|
331
|
-
while (/[\s]/u.test(markdown[cursor] ?? "")) cursor += 1;
|
|
332
|
-
const destination = spoilerParser.helpers.parseLinkDestination(markdown, cursor, markdown.length);
|
|
333
|
-
if (destination.ok) {
|
|
334
|
-
cursor = destination.pos;
|
|
335
|
-
while (/[\s]/u.test(markdown[cursor] ?? "")) cursor += 1;
|
|
336
|
-
const title = spoilerParser.helpers.parseLinkTitle(markdown, cursor, markdown.length);
|
|
337
|
-
if (title.ok) {
|
|
338
|
-
cursor = title.pos;
|
|
339
|
-
while (/[\s]/u.test(markdown[cursor] ?? "")) cursor += 1;
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
if (destination.ok && markdown[cursor] === ")") {
|
|
343
|
-
ranges.push({
|
|
344
|
-
start,
|
|
345
|
-
end: cursor + 1
|
|
346
|
-
});
|
|
347
|
-
index = cursor;
|
|
348
|
-
}
|
|
349
|
-
continue;
|
|
350
|
-
}
|
|
351
|
-
if (markdown[index] === "]" && markdown[index + 1] === "[" && !isMarkdownEscaped(markdown, index) && labelStack.pop() !== void 0) {
|
|
352
|
-
let end = index + 2;
|
|
353
|
-
while (end < markdown.length && (markdown[end] !== "]" || isMarkdownEscaped(markdown, end))) end += 1;
|
|
354
|
-
const reference = spoilerParser.utils.normalizeReference(markdown.slice(index + 2, end));
|
|
355
|
-
if (end < markdown.length && references.has(reference)) {
|
|
356
|
-
ranges.push({
|
|
357
|
-
start: index + 2,
|
|
358
|
-
end
|
|
359
|
-
});
|
|
360
|
-
index = end;
|
|
361
|
-
}
|
|
362
|
-
continue;
|
|
363
|
-
}
|
|
364
|
-
if (markdown[index] === "]" && !isMarkdownEscaped(markdown, index)) labelStack.pop();
|
|
365
|
-
const autolink = /^<[A-Za-z][A-Za-z0-9+.-]{1,31}:[^<>\s]*>/u.exec(markdown.slice(index));
|
|
366
|
-
if (autolink && !isMarkdownEscaped(markdown, index)) {
|
|
367
|
-
ranges.push({
|
|
368
|
-
start: index,
|
|
369
|
-
end: index + autolink[0].length
|
|
370
|
-
});
|
|
371
|
-
index += autolink[0].length - 1;
|
|
372
|
-
continue;
|
|
373
|
-
}
|
|
374
|
-
const emailAutolink = /^<[^<>\s@]+@[^<>\s@]+>/u.exec(markdown.slice(index));
|
|
375
|
-
if (emailAutolink && !isMarkdownEscaped(markdown, index)) {
|
|
376
|
-
ranges.push({
|
|
377
|
-
start: index,
|
|
378
|
-
end: index + emailAutolink[0].length
|
|
379
|
-
});
|
|
380
|
-
index += emailAutolink[0].length - 1;
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
|
-
return ranges;
|
|
384
|
-
}
|
|
385
|
-
function findMatrixMarkdownMetadataRanges(markdown) {
|
|
386
|
-
const env = {};
|
|
387
|
-
const tokens = spoilerParser.parse(markdown, env);
|
|
388
|
-
const references = new Set(Object.keys(env.references ?? {}));
|
|
389
|
-
const lineStarts = [0];
|
|
390
|
-
for (let index = 0; index < markdown.length; index += 1) if (markdown[index] === "\n") lineStarts.push(index + 1);
|
|
391
|
-
lineStarts.push(markdown.length);
|
|
392
|
-
const ranges = tokens.flatMap((token) => {
|
|
393
|
-
if (token.type !== "inline" || !token.map) return [];
|
|
394
|
-
const start = lineStarts[token.map[0]] ?? 0;
|
|
395
|
-
const end = lineStarts[token.map[1]] ?? markdown.length;
|
|
396
|
-
return findInlineMetadataRanges(markdown.slice(start, end), references).map((range) => ({
|
|
397
|
-
start: start + range.start,
|
|
398
|
-
end: start + range.end
|
|
399
|
-
}));
|
|
400
|
-
});
|
|
401
|
-
for (const match of markdown.matchAll(/^\s*\[[^\]\n]+\]:\s*.+$/gmu)) {
|
|
402
|
-
const start = match.index ?? 0;
|
|
403
|
-
const labelEnd = match[0].indexOf("]:");
|
|
404
|
-
const reference = spoilerParser.utils.normalizeReference(match[0].slice(1, labelEnd));
|
|
405
|
-
if (references.has(reference)) {
|
|
406
|
-
let end = start + match[0].length;
|
|
407
|
-
const continuation = /^\n[ \t]+(?:"[^"\n]*"|'[^'\n]*'|\([^\n)]*\))[ \t]*/u.exec(markdown.slice(end));
|
|
408
|
-
end += continuation?.[0].length ?? 0;
|
|
409
|
-
ranges.push({
|
|
410
|
-
start,
|
|
411
|
-
end
|
|
412
|
-
});
|
|
413
|
-
}
|
|
414
|
-
}
|
|
415
|
-
const codeRegions = findCodeRegions(markdown);
|
|
416
|
-
for (const match of spoilerParser.linkify.match(markdown) ?? []) if (!isInsideCode(match.index, codeRegions)) ranges.push({
|
|
417
|
-
start: match.index,
|
|
418
|
-
end: match.lastIndex
|
|
419
|
-
});
|
|
420
|
-
return ranges;
|
|
421
|
-
}
|
|
422
|
-
function findMatrixSpoilerDelimiterOffsets(markdown) {
|
|
423
|
-
const projected = projectMatrixMarkdown(markdown);
|
|
424
|
-
const tokens = spoilerParser.parse(projected, {});
|
|
425
|
-
const lineStarts = [0];
|
|
426
|
-
for (let index = 0; index < projected.length; index += 1) if (projected[index] === "\n") lineStarts.push(index + 1);
|
|
427
|
-
lineStarts.push(projected.length);
|
|
428
|
-
const excludedRanges = [
|
|
429
|
-
...findCodeRegions(projected),
|
|
430
|
-
...findMatrixMarkdownMetadataRanges(projected),
|
|
431
|
-
...[...tokenizeHtmlTags(projected)].flatMap((tag) => tag.name === "u" || tag.name === "ins" ? [{
|
|
432
|
-
start: tag.start,
|
|
433
|
-
end: tag.end
|
|
434
|
-
}] : [])
|
|
435
|
-
];
|
|
436
|
-
const offsets = [];
|
|
437
|
-
for (const token of tokens) {
|
|
438
|
-
if (token.type !== "inline" || !token.map) continue;
|
|
439
|
-
const start = lineStarts[token.map[0]] ?? 0;
|
|
440
|
-
const end = lineStarts[token.map[1]] ?? projected.length;
|
|
441
|
-
const candidates = [];
|
|
442
|
-
for (let index = start; index < end - 1; index += 1) {
|
|
443
|
-
if (projected[index] !== "|" || projected[index + 1] !== "|") continue;
|
|
444
|
-
const excluded = excludedRanges.some((range) => index >= range.start && index < range.end);
|
|
445
|
-
if (isMarkdownEscaped(projected, index) || excluded) continue;
|
|
446
|
-
candidates.push(index);
|
|
447
|
-
index += 1;
|
|
448
|
-
}
|
|
449
|
-
candidates.length -= candidates.length % 2;
|
|
450
|
-
offsets.push(...candidates);
|
|
451
|
-
}
|
|
452
|
-
return [...new Set(offsets)].toSorted((left, right) => left - right);
|
|
453
|
-
}
|
|
454
|
-
function hasMatrixSpoilerMetadataCollision(markdown) {
|
|
455
|
-
const projected = projectMatrixMarkdown(markdown);
|
|
456
|
-
const ordinary = new Set(findMatrixSpoilerDelimiterOffsets(projected));
|
|
457
|
-
const tables = findMatrixTableSourceRanges(projected);
|
|
458
|
-
for (let index = 0; index < projected.length - 1; index += 1) {
|
|
459
|
-
if (projected[index] !== "|" || projected[index + 1] !== "|") continue;
|
|
460
|
-
if (ordinary.has(index) || isMarkdownEscaped(projected, index)) continue;
|
|
461
|
-
if (tables.some((range) => index >= range.start && index < range.end)) continue;
|
|
462
|
-
return true;
|
|
463
|
-
}
|
|
464
|
-
return false;
|
|
254
|
+
async function withResolvedMatrixClient(opts, run, shutdownBehavior) {
|
|
255
|
+
if (opts.client) return await run(opts.client);
|
|
256
|
+
const { withResolvedRuntimeMatrixClient } = await loadMatrixSendClientRuntime();
|
|
257
|
+
return await withResolvedRuntimeMatrixClient(opts, run, shutdownBehavior);
|
|
465
258
|
}
|
|
466
259
|
//#endregion
|
|
467
260
|
//#region extensions/matrix/src/matrix/format.ts
|
|
468
|
-
const MATRIX_STYLE_MARKERS = {
|
|
469
|
-
underline: {
|
|
470
|
-
open: "<u>",
|
|
471
|
-
close: "</u>"
|
|
472
|
-
},
|
|
473
|
-
spoiler: {
|
|
474
|
-
open: "<span data-mx-spoiler>",
|
|
475
|
-
close: "</span>"
|
|
476
|
-
}
|
|
477
|
-
};
|
|
478
261
|
const md = new MarkdownIt({
|
|
479
262
|
html: false,
|
|
480
263
|
linkify: true,
|
|
481
264
|
breaks: true,
|
|
482
265
|
typographer: false
|
|
483
266
|
});
|
|
267
|
+
md.linkify.set({ fuzzyLink: true });
|
|
484
268
|
md.enable("strikethrough");
|
|
485
269
|
const { escapeHtml } = md.utils;
|
|
486
270
|
const ESCAPED_MENTION_SENTINEL = "";
|
|
487
271
|
const MENTION_PATTERN = /@[A-Za-z0-9._=+\-/:[\]]+/g;
|
|
488
272
|
const MATRIX_MENTION_USER_ID_PATTERN = new RegExp(`^@[A-Za-z0-9._=+\\-/]+:(?:${/(?:[A-Za-z0-9](?:[A-Za-z0-9-]*[A-Za-z0-9])?)(?:\.(?:[A-Za-z0-9](?:[A-Za-z0-9-]*[A-Za-z0-9])?))*(?::\d+)?/.source}|\\[[0-9A-Fa-f:.]+\\](?::\\d+)?)$`);
|
|
489
273
|
const TRIMMABLE_MENTION_SUFFIX = /[),.!?:;\]]/;
|
|
490
|
-
const parseMatrixUnderline = (state, silent) => {
|
|
491
|
-
if (state.src.charCodeAt(state.pos) !== 60) return false;
|
|
492
|
-
const tag = tokenizeHtmlTags(state.src.slice(state.pos)).next().value;
|
|
493
|
-
if (!tag || tag.start !== 0 || tag.name !== "u" && tag.name !== "ins") return false;
|
|
494
|
-
if (!silent) {
|
|
495
|
-
const token = state.push(tag.selfClosing ? "text" : tag.closing ? "matrix_underline_close" : "matrix_underline_open", tag.selfClosing ? "" : "u", tag.selfClosing ? 0 : tag.closing ? -1 : 1);
|
|
496
|
-
if (tag.selfClosing) token.content = tag.raw;
|
|
497
|
-
}
|
|
498
|
-
state.pos += tag.end;
|
|
499
|
-
return true;
|
|
500
|
-
};
|
|
501
|
-
md.inline.ruler.before("html_inline", "matrix_underline", parseMatrixUnderline);
|
|
502
|
-
md.renderer.rules.matrix_underline_open = () => MATRIX_STYLE_MARKERS.underline.open;
|
|
503
|
-
md.renderer.rules.matrix_underline_close = () => MATRIX_STYLE_MARKERS.underline.close;
|
|
504
|
-
md.renderer.rules.matrix_spoiler_open = () => MATRIX_STYLE_MARKERS.spoiler.open;
|
|
505
|
-
md.renderer.rules.matrix_spoiler_close = () => MATRIX_STYLE_MARKERS.spoiler.close;
|
|
506
|
-
md.core.ruler.after("inline", "matrix_spoilers", (state) => {
|
|
507
|
-
const markers = state.env.matrixSpoilerMarkers;
|
|
508
|
-
if (!markers) return;
|
|
509
|
-
for (const token of state.tokens) if (token.children?.length) token.children = normalizeMatrixSpoilerNesting(injectProtectedMatrixSpoilers(token.children, markers));
|
|
510
|
-
});
|
|
511
274
|
function shouldSuppressAutoLink(tokens, idx) {
|
|
512
275
|
const token = tokens[idx];
|
|
513
276
|
if (token?.type !== "link_open" || token.info !== "auto") return false;
|
|
514
|
-
const
|
|
277
|
+
const hrefValue = token.attrGet("href");
|
|
278
|
+
const href = hrefValue === null ? "" : String(hrefValue);
|
|
515
279
|
const label = tokens[idx + 1]?.type === "text" ? tokens[idx + 1]?.content ?? "" : "";
|
|
516
280
|
return Boolean(href && label && isAutoLinkedFileRef(href, label));
|
|
517
281
|
}
|
|
518
|
-
md.renderer.rules.image = (tokens, idx
|
|
519
|
-
const token = tokens[idx];
|
|
520
|
-
return token?.children?.length ? self.renderInline(token.children, options, env) : escapeHtml(token?.content ?? "");
|
|
521
|
-
};
|
|
282
|
+
md.renderer.rules.image = (tokens, idx) => escapeHtml(tokens[idx]?.content ?? "");
|
|
522
283
|
md.renderer.rules.html_block = (tokens, idx) => escapeHtml(tokens[idx]?.content ?? "");
|
|
523
284
|
md.renderer.rules.html_inline = (tokens, idx) => escapeHtml(tokens[idx]?.content ?? "");
|
|
524
285
|
md.renderer.rules.link_open = (tokens, idx, _options, _env, self) => shouldSuppressAutoLink(tokens, idx) ? "" : self.renderToken(tokens, idx, _options);
|
|
@@ -551,6 +312,15 @@ function maskEscapedMentions(markdown) {
|
|
|
551
312
|
}
|
|
552
313
|
return masked;
|
|
553
314
|
}
|
|
315
|
+
function isMarkdownEscaped(markdown, idx) {
|
|
316
|
+
let slashCount = 0;
|
|
317
|
+
let cursor = idx - 1;
|
|
318
|
+
while (cursor >= 0 && markdown[cursor] === "\\") {
|
|
319
|
+
slashCount += 1;
|
|
320
|
+
cursor -= 1;
|
|
321
|
+
}
|
|
322
|
+
return slashCount % 2 === 1;
|
|
323
|
+
}
|
|
554
324
|
function restoreEscapedMentions(text) {
|
|
555
325
|
return text.replaceAll(ESCAPED_MENTION_SENTINEL, "@");
|
|
556
326
|
}
|
|
@@ -620,67 +390,6 @@ function createTextToken(sample, content) {
|
|
|
620
390
|
token.content = content;
|
|
621
391
|
return token;
|
|
622
392
|
}
|
|
623
|
-
function injectProtectedMatrixSpoilers(tokens, markers) {
|
|
624
|
-
const result = [];
|
|
625
|
-
for (const token of tokens) {
|
|
626
|
-
if (token.type !== "text") {
|
|
627
|
-
if (token.children?.length) token.children = normalizeMatrixSpoilerNesting(injectProtectedMatrixSpoilers(token.children, markers));
|
|
628
|
-
result.push(token);
|
|
629
|
-
continue;
|
|
630
|
-
}
|
|
631
|
-
let cursor = 0;
|
|
632
|
-
for (let index = 0; index < token.content.length; index += 1) {
|
|
633
|
-
const marker = token.content[index];
|
|
634
|
-
if (marker !== markers.open && marker !== markers.close || token.content[index + 1] !== markers.padding) continue;
|
|
635
|
-
if (index > cursor) result.push(createTextToken(token, token.content.slice(cursor, index)));
|
|
636
|
-
result.push(createToken(token, marker === markers.open ? "matrix_spoiler_open" : "matrix_spoiler_close", "span", marker === markers.open ? 1 : -1));
|
|
637
|
-
index += 1;
|
|
638
|
-
cursor = index + 1;
|
|
639
|
-
}
|
|
640
|
-
if (cursor < token.content.length) result.push(createTextToken(token, token.content.slice(cursor)));
|
|
641
|
-
}
|
|
642
|
-
return result;
|
|
643
|
-
}
|
|
644
|
-
function copyInlineToken(sample, type, tag, nesting) {
|
|
645
|
-
const token = createToken(sample, type, tag, nesting);
|
|
646
|
-
token.markup = sample.markup;
|
|
647
|
-
token.attrs = sample.attrs ? [...sample.attrs] : null;
|
|
648
|
-
return token;
|
|
649
|
-
}
|
|
650
|
-
function normalizeMatrixSpoilerNesting(tokens) {
|
|
651
|
-
const result = [];
|
|
652
|
-
const stack = [];
|
|
653
|
-
for (const token of tokens) {
|
|
654
|
-
if (token.nesting === 1) {
|
|
655
|
-
stack.push(token);
|
|
656
|
-
result.push(token);
|
|
657
|
-
continue;
|
|
658
|
-
}
|
|
659
|
-
if (token.nesting !== -1) {
|
|
660
|
-
result.push(token);
|
|
661
|
-
continue;
|
|
662
|
-
}
|
|
663
|
-
const openIndex = stack.findLastIndex((open) => open.tag === token.tag);
|
|
664
|
-
if (openIndex < 0) {
|
|
665
|
-
result.push(token);
|
|
666
|
-
continue;
|
|
667
|
-
}
|
|
668
|
-
if (openIndex === stack.length - 1) {
|
|
669
|
-
stack.pop();
|
|
670
|
-
result.push(token);
|
|
671
|
-
continue;
|
|
672
|
-
}
|
|
673
|
-
const crossing = stack.splice(openIndex + 1);
|
|
674
|
-
for (const open of crossing.toReversed()) result.push(copyInlineToken(open, open.type.replace(/_open$/u, "_close"), open.tag, -1));
|
|
675
|
-
stack.pop();
|
|
676
|
-
result.push(token);
|
|
677
|
-
for (const open of crossing) {
|
|
678
|
-
result.push(copyInlineToken(open, open.type, open.tag, 1));
|
|
679
|
-
stack.push(open);
|
|
680
|
-
}
|
|
681
|
-
}
|
|
682
|
-
return result;
|
|
683
|
-
}
|
|
684
393
|
function createMentionLinkTokens(params) {
|
|
685
394
|
const open = createToken(params.sample, "link_open", "a", 1);
|
|
686
395
|
open.attrSet("href", params.href);
|
|
@@ -773,14 +482,8 @@ function compactLooseListTokens(tokens) {
|
|
|
773
482
|
if (token.type === "list_item_close") {
|
|
774
483
|
const item = listItemStack.pop();
|
|
775
484
|
if (item && item.immediateParagraphOpenIndexes.length === 1 && item.immediateParagraphCloseIndexes.length === 1) {
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
const openToken = openIndex === void 0 ? void 0 : tokens[openIndex];
|
|
779
|
-
const closeToken = closeIndex === void 0 ? void 0 : tokens[closeIndex];
|
|
780
|
-
if (openToken && closeToken) {
|
|
781
|
-
openToken.hidden = true;
|
|
782
|
-
closeToken.hidden = true;
|
|
783
|
-
}
|
|
485
|
+
tokens[item.immediateParagraphOpenIndexes[0]].hidden = true;
|
|
486
|
+
tokens[item.immediateParagraphCloseIndexes[0]].hidden = true;
|
|
784
487
|
}
|
|
785
488
|
continue;
|
|
786
489
|
}
|
|
@@ -790,64 +493,14 @@ function compactLooseListTokens(tokens) {
|
|
|
790
493
|
else if (token.type === "paragraph_close") currentItem.immediateParagraphCloseIndexes.push(index);
|
|
791
494
|
}
|
|
792
495
|
}
|
|
793
|
-
function markdownToMatrixHtml(markdown
|
|
794
|
-
|
|
795
|
-
const tokens = parseMatrixMarkdown(projectMatrixMarkdown(markdown), options.tableMode);
|
|
496
|
+
function markdownToMatrixHtml(markdown) {
|
|
497
|
+
const tokens = md.parse(markdown ?? "", {});
|
|
796
498
|
compactLooseListTokens(tokens);
|
|
797
499
|
return md.renderer.render(tokens, md.options, {}).trimEnd();
|
|
798
500
|
}
|
|
799
|
-
function protectMatrixSpoilerDelimiters(markdown) {
|
|
800
|
-
const offsets = findMatrixSpoilerDelimiterOffsets(markdown);
|
|
801
|
-
if (offsets.length === 0) return { markdown };
|
|
802
|
-
const markers = createMatrixPrivateMarkers(markdown, "Matrix spoiler formatting exhausted its private marker pool");
|
|
803
|
-
let protectedMarkdown = "";
|
|
804
|
-
let cursor = 0;
|
|
805
|
-
for (const [index, offset] of offsets.entries()) {
|
|
806
|
-
const marker = index % 2 === 0 ? markers.open : markers.close;
|
|
807
|
-
protectedMarkdown += `${markdown.slice(cursor, offset)}${marker}${markers.padding}`;
|
|
808
|
-
cursor = offset + 2;
|
|
809
|
-
}
|
|
810
|
-
protectedMarkdown += markdown.slice(cursor);
|
|
811
|
-
return {
|
|
812
|
-
markdown: protectedMarkdown,
|
|
813
|
-
markers
|
|
814
|
-
};
|
|
815
|
-
}
|
|
816
|
-
function parseMatrixMarkdown(markdown, tableMode) {
|
|
817
|
-
const protectedSpoilers = protectMatrixSpoilerDelimiters(markdown);
|
|
818
|
-
if (tableMode === "off") md.disable("table");
|
|
819
|
-
try {
|
|
820
|
-
return md.parse(protectedSpoilers.markdown, { matrixSpoilerMarkers: protectedSpoilers.markers });
|
|
821
|
-
} finally {
|
|
822
|
-
if (tableMode === "off") md.enable("table");
|
|
823
|
-
}
|
|
824
|
-
}
|
|
825
|
-
function markdownToMatrixBody(markdown) {
|
|
826
|
-
const projected = projectMatrixMarkdown(markdown);
|
|
827
|
-
const offsets = findMatrixSpoilerDelimiterOffsets(projected);
|
|
828
|
-
const metadataCollision = hasMatrixSpoilerMetadataCollision(projected);
|
|
829
|
-
if (offsets.length === 0 && !metadataCollision) return projected;
|
|
830
|
-
let body = projected;
|
|
831
|
-
if (metadataCollision) body = "[Spoiler]";
|
|
832
|
-
else for (let index = offsets.length - 2; index >= 0; index -= 2) {
|
|
833
|
-
const open = offsets[index];
|
|
834
|
-
const close = offsets[index + 1];
|
|
835
|
-
if (open !== void 0 && close !== void 0) body = `${body.slice(0, open)}[Spoiler]${body.slice(close + 2)}`;
|
|
836
|
-
}
|
|
837
|
-
return renderMarkdownWithMarkers(markdownToIR(body, {
|
|
838
|
-
enableHtmlUnderline: true,
|
|
839
|
-
headingStyle: "rich",
|
|
840
|
-
linkify: true
|
|
841
|
-
}), {
|
|
842
|
-
styleMarkers: {},
|
|
843
|
-
escapeText: (text) => text
|
|
844
|
-
}, MATRIX_FORMAT_PROFILE);
|
|
845
|
-
}
|
|
846
|
-
function renderMatrixFallbackHtml(markdown) {
|
|
847
|
-
return `<p>${escapeHtml(markdownToMatrixBody(markdown)).replaceAll("\n", "<br>\n")}</p>`;
|
|
848
|
-
}
|
|
849
501
|
async function resolveMarkdownMentionState(params) {
|
|
850
|
-
const
|
|
502
|
+
const markdown = maskEscapedMentions(params.markdown ?? "");
|
|
503
|
+
const tokens = md.parse(markdown, {});
|
|
851
504
|
restoreEscapedMentionsInBlockTokens(tokens);
|
|
852
505
|
const selfUserId = await resolveMatrixSelfUserId(params.client);
|
|
853
506
|
const userIds = [];
|
|
@@ -877,17 +530,6 @@ async function resolveMatrixMentionsInMarkdown(params) {
|
|
|
877
530
|
}
|
|
878
531
|
async function renderMarkdownToMatrixHtmlWithMentions(params) {
|
|
879
532
|
const state = await resolveMarkdownMentionState(params);
|
|
880
|
-
if (hasMatrixSpoilerMetadataCollision(params.markdown)) {
|
|
881
|
-
const redacted = markdownToMatrixBody(params.markdown);
|
|
882
|
-
const redactedState = await resolveMarkdownMentionState({
|
|
883
|
-
...params,
|
|
884
|
-
markdown: redacted
|
|
885
|
-
});
|
|
886
|
-
return {
|
|
887
|
-
html: renderMatrixFallbackHtml(params.markdown),
|
|
888
|
-
mentions: redactedState.mentions
|
|
889
|
-
};
|
|
890
|
-
}
|
|
891
533
|
compactLooseListTokens(state.tokens);
|
|
892
534
|
return {
|
|
893
535
|
html: md.renderer.render(state.tokens, md.options, {}).trimEnd() || void 0,
|
|
@@ -895,189 +537,6 @@ async function renderMarkdownToMatrixHtmlWithMentions(params) {
|
|
|
895
537
|
};
|
|
896
538
|
}
|
|
897
539
|
//#endregion
|
|
898
|
-
//#region extensions/matrix/src/matrix/send/chunking.ts
|
|
899
|
-
const getCore$2 = () => getMatrixRuntime();
|
|
900
|
-
function protectMatrixUnderlineTags(markdown) {
|
|
901
|
-
const codeRegions = findCodeRegions(markdown);
|
|
902
|
-
const metadataRanges = findMatrixMarkdownMetadataRanges(markdown);
|
|
903
|
-
const tags = [...tokenizeHtmlTags(markdown)].filter((tag) => (tag.name === "u" || tag.name === "ins") && !tag.selfClosing && !isInsideCode(tag.start, codeRegions) && !isMarkdownEscaped(markdown, tag.start) && !metadataRanges.some((range) => tag.start >= range.start && tag.start < range.end));
|
|
904
|
-
if (tags.length === 0) return { markdown };
|
|
905
|
-
const markers = createMatrixPrivateMarkers(markdown, "Matrix underline chunking exhausted its private marker pool");
|
|
906
|
-
let depth = 0;
|
|
907
|
-
const replacements = tags.flatMap((tag) => {
|
|
908
|
-
if (!tag.closing) {
|
|
909
|
-
depth += 1;
|
|
910
|
-
return [{
|
|
911
|
-
tag,
|
|
912
|
-
marker: depth === 1 ? markers.open : ""
|
|
913
|
-
}];
|
|
914
|
-
}
|
|
915
|
-
if (depth === 0) return [];
|
|
916
|
-
depth -= 1;
|
|
917
|
-
return [{
|
|
918
|
-
tag,
|
|
919
|
-
marker: depth === 0 ? markers.close : ""
|
|
920
|
-
}];
|
|
921
|
-
});
|
|
922
|
-
let protectedMarkdown = markdown;
|
|
923
|
-
for (const { tag, marker } of replacements.toReversed()) protectedMarkdown = `${protectedMarkdown.slice(0, tag.start)}${marker}${markers.padding.repeat(tag.raw.length - marker.length)}${protectedMarkdown.slice(tag.end)}`;
|
|
924
|
-
return {
|
|
925
|
-
markdown: protectedMarkdown,
|
|
926
|
-
markers
|
|
927
|
-
};
|
|
928
|
-
}
|
|
929
|
-
function restoreMatrixStyleChunks(chunks, spoiler, underline) {
|
|
930
|
-
const stack = [];
|
|
931
|
-
const syntax = {
|
|
932
|
-
spoiler: {
|
|
933
|
-
open: "||",
|
|
934
|
-
close: "||",
|
|
935
|
-
markers: spoiler
|
|
936
|
-
},
|
|
937
|
-
underline: {
|
|
938
|
-
open: "<u>",
|
|
939
|
-
close: "</u>",
|
|
940
|
-
markers: underline
|
|
941
|
-
}
|
|
942
|
-
};
|
|
943
|
-
return chunks.map((chunk) => {
|
|
944
|
-
let restored = stack.map((style) => syntax[style].open).join("");
|
|
945
|
-
for (const character of chunk) {
|
|
946
|
-
const opening = Object.keys(syntax).find((style) => character === syntax[style].markers?.open);
|
|
947
|
-
const closing = Object.keys(syntax).find((style) => character === syntax[style].markers?.close);
|
|
948
|
-
if (opening) {
|
|
949
|
-
stack.push(opening);
|
|
950
|
-
restored += syntax[opening].open;
|
|
951
|
-
} else if (closing) {
|
|
952
|
-
const stackIndex = stack.lastIndexOf(closing);
|
|
953
|
-
if (stackIndex >= 0) {
|
|
954
|
-
const above = stack.slice(stackIndex + 1);
|
|
955
|
-
restored += above.toReversed().map((style) => syntax[style].close).join("");
|
|
956
|
-
restored += syntax[closing].close;
|
|
957
|
-
stack.splice(stackIndex, 1);
|
|
958
|
-
restored += above.map((style) => syntax[style].open).join("");
|
|
959
|
-
}
|
|
960
|
-
} else if (character !== spoiler?.padding && character !== underline?.padding) restored += character;
|
|
961
|
-
}
|
|
962
|
-
return restored + stack.toReversed().map((style) => syntax[style].close).join("");
|
|
963
|
-
});
|
|
964
|
-
}
|
|
965
|
-
function splitMatrixTableSegments(markdown) {
|
|
966
|
-
const segments = [];
|
|
967
|
-
let cursor = 0;
|
|
968
|
-
for (const range of findMatrixTableSourceRanges(markdown)) {
|
|
969
|
-
const plain = markdown.slice(cursor, range.start).replace(/(?:[ \t]*\n)+$/u, "");
|
|
970
|
-
if (plain.trim()) segments.push({
|
|
971
|
-
table: false,
|
|
972
|
-
text: plain
|
|
973
|
-
});
|
|
974
|
-
const rawTable = markdown.slice(range.start, range.end).trimEnd();
|
|
975
|
-
const indent = /^ +/u.exec(rawTable)?.[0] ?? "";
|
|
976
|
-
const table = indent ? rawTable.split("\n").map((line) => line.startsWith(indent) ? line.slice(indent.length) : line).join("\n") : rawTable;
|
|
977
|
-
segments.push({
|
|
978
|
-
table: true,
|
|
979
|
-
text: table
|
|
980
|
-
});
|
|
981
|
-
cursor = range.end;
|
|
982
|
-
}
|
|
983
|
-
const tail = markdown.slice(cursor).replace(/^(?:[ \t]*\n)+/u, "");
|
|
984
|
-
if (tail.trim()) segments.push({
|
|
985
|
-
table: false,
|
|
986
|
-
text: tail
|
|
987
|
-
});
|
|
988
|
-
return segments;
|
|
989
|
-
}
|
|
990
|
-
function prepareMatrixSingleText(text, opts) {
|
|
991
|
-
const normalizedText = text.replace(/\r\n?/gu, "\n");
|
|
992
|
-
const trimmedText = opts.preserveWhitespace ? normalizedText : normalizedText.trim();
|
|
993
|
-
const cfg = requireRuntimeConfig(opts.cfg, "Matrix text preparation");
|
|
994
|
-
const tableMode = opts.tableMode ?? getCore$2().channel.text.resolveMarkdownTableMode({
|
|
995
|
-
cfg,
|
|
996
|
-
channel: "matrix",
|
|
997
|
-
accountId: opts.accountId,
|
|
998
|
-
supportsBlockTables: MATRIX_FORMAT_PROFILE.constructs.table === "native"
|
|
999
|
-
});
|
|
1000
|
-
const singleEventLimit = Math.min(getCore$2().channel.text.resolveTextChunkLimit(cfg, "matrix", opts.accountId), MATRIX_FORMAT_PROFILE.chunk.limit);
|
|
1001
|
-
const convertedText = renderMatrixMarkdownTables(trimmedText, tableMode);
|
|
1002
|
-
const eventTextLength = Math.max(convertedText.length, markdownToMatrixBody(convertedText).length);
|
|
1003
|
-
return {
|
|
1004
|
-
trimmedText,
|
|
1005
|
-
convertedText,
|
|
1006
|
-
singleEventLimit,
|
|
1007
|
-
eventTextLength,
|
|
1008
|
-
fitsInSingleEvent: eventTextLength <= singleEventLimit,
|
|
1009
|
-
tableMode
|
|
1010
|
-
};
|
|
1011
|
-
}
|
|
1012
|
-
function chunkMatrixText(text, opts) {
|
|
1013
|
-
const preparedText = prepareMatrixSingleText(text, opts);
|
|
1014
|
-
if (preparedText.fitsInSingleEvent) return {
|
|
1015
|
-
...preparedText,
|
|
1016
|
-
chunks: preparedText.convertedText ? [preparedText.convertedText] : []
|
|
1017
|
-
};
|
|
1018
|
-
const cfg = requireRuntimeConfig(opts.cfg, "Matrix text chunking");
|
|
1019
|
-
const chunkMode = getCore$2().channel.text.resolveChunkMode(cfg, "matrix", opts.accountId);
|
|
1020
|
-
const collisionRedacted = hasMatrixSpoilerMetadataCollision(preparedText.convertedText) ? markdownToMatrixBody(preparedText.convertedText) : void 0;
|
|
1021
|
-
const chunkSegment = (segmentText) => {
|
|
1022
|
-
const protectedUnderline = protectMatrixUnderlineTags(hasMatrixSpoilerMetadataCollision(segmentText) ? markdownToMatrixBody(segmentText) : segmentText);
|
|
1023
|
-
const protectedSpoilers = protectMatrixSpoilerDelimiters(protectedUnderline.markdown);
|
|
1024
|
-
const wrapperReserve = (protectedSpoilers.markers ? 4 : 0) + (protectedUnderline.markers ? 7 : 0);
|
|
1025
|
-
const privateMarkers = [protectedSpoilers.markers, protectedUnderline.markers].flatMap((markers) => markers ? [
|
|
1026
|
-
markers.open,
|
|
1027
|
-
markers.close,
|
|
1028
|
-
markers.padding
|
|
1029
|
-
] : []);
|
|
1030
|
-
let reserve = wrapperReserve;
|
|
1031
|
-
while (reserve < preparedText.singleEventLimit) {
|
|
1032
|
-
const protectedChunks = getCore$2().channel.text.chunkMarkdownTextWithMode(protectedSpoilers.markdown, preparedText.singleEventLimit - reserve, chunkMode);
|
|
1033
|
-
const restored = restoreMatrixStyleChunks(protectedChunks, protectedSpoilers.markers, protectedUnderline.markers).filter((_, index) => {
|
|
1034
|
-
return privateMarkers.reduce((value, marker) => value.replaceAll(marker, ""), protectedChunks[index] ?? "").length > 0;
|
|
1035
|
-
});
|
|
1036
|
-
const overflow = Math.max(0, ...restored.map((chunk) => Math.max(chunk.length, markdownToMatrixBody(chunk).length) - preparedText.singleEventLimit));
|
|
1037
|
-
if (overflow === 0) return restored;
|
|
1038
|
-
reserve += overflow;
|
|
1039
|
-
}
|
|
1040
|
-
throw new Error("Matrix text chunk limit is too small for formatted content");
|
|
1041
|
-
};
|
|
1042
|
-
const chunks = collisionRedacted !== void 0 ? chunkSegment(collisionRedacted) : preparedText.tableMode === "block" ? splitMatrixTableSegments(preparedText.convertedText).flatMap((segment) => {
|
|
1043
|
-
if (!segment.table) return chunkSegment(segment.text);
|
|
1044
|
-
return segment.text.length <= preparedText.singleEventLimit ? [segment.text] : chunkSegment(renderMatrixMarkdownTables(segment.text, "bullets"));
|
|
1045
|
-
}) : chunkSegment(preparedText.convertedText);
|
|
1046
|
-
return {
|
|
1047
|
-
...preparedText,
|
|
1048
|
-
chunks
|
|
1049
|
-
};
|
|
1050
|
-
}
|
|
1051
|
-
//#endregion
|
|
1052
|
-
//#region extensions/matrix/src/matrix/send/client.ts
|
|
1053
|
-
const loadMatrixSendClientRuntime = createLazyRuntimeModule(() => import("./client-bootstrap-XsIkHNt0.js").then((n) => n.t));
|
|
1054
|
-
function resolveMediaMaxBytes(accountId, cfg) {
|
|
1055
|
-
if (!cfg) throw new Error("Matrix media limits requires a resolved runtime config. Load and resolve config at the command or gateway boundary, then pass cfg through the runtime path.");
|
|
1056
|
-
const matrixCfg = resolveMatrixAccountConfig({
|
|
1057
|
-
cfg: requireRuntimeConfig(cfg, "Matrix media limits"),
|
|
1058
|
-
accountId
|
|
1059
|
-
});
|
|
1060
|
-
const mediaMaxMb = typeof matrixCfg.mediaMaxMb === "number" ? matrixCfg.mediaMaxMb : void 0;
|
|
1061
|
-
if (typeof mediaMaxMb === "number") return mediaMaxMb * 1024 * 1024;
|
|
1062
|
-
}
|
|
1063
|
-
async function withResolvedMatrixSendClient(opts, run) {
|
|
1064
|
-
return await withResolvedMatrixClient({
|
|
1065
|
-
...opts,
|
|
1066
|
-
readiness: "started"
|
|
1067
|
-
}, run, "persist");
|
|
1068
|
-
}
|
|
1069
|
-
async function withResolvedMatrixControlClient(opts, run) {
|
|
1070
|
-
return await withResolvedMatrixClient({
|
|
1071
|
-
...opts,
|
|
1072
|
-
readiness: "none"
|
|
1073
|
-
}, run);
|
|
1074
|
-
}
|
|
1075
|
-
async function withResolvedMatrixClient(opts, run, shutdownBehavior) {
|
|
1076
|
-
if (opts.client) return await run(opts.client);
|
|
1077
|
-
const { withResolvedRuntimeMatrixClient } = await loadMatrixSendClientRuntime();
|
|
1078
|
-
return await withResolvedRuntimeMatrixClient(opts, run, shutdownBehavior);
|
|
1079
|
-
}
|
|
1080
|
-
//#endregion
|
|
1081
540
|
//#region extensions/matrix/src/matrix/send/types.ts
|
|
1082
541
|
const MsgType = {
|
|
1083
542
|
Text: "m.text",
|
|
@@ -1109,21 +568,15 @@ const MATRIX_OPENCLAW_FINALIZED_PREVIEW_KEY = "com.openclaw.finalized_preview";
|
|
|
1109
568
|
const MSC4357_LIVE_KEY = "org.matrix.msc4357.live";
|
|
1110
569
|
//#endregion
|
|
1111
570
|
//#region extensions/matrix/src/matrix/send/formatting.ts
|
|
1112
|
-
const getCore$
|
|
571
|
+
const getCore$2 = () => getMatrixRuntime();
|
|
1113
572
|
async function renderMatrixFormattedContent(params) {
|
|
1114
573
|
const markdown = params.markdown ?? "";
|
|
1115
|
-
|
|
1116
|
-
if (params.includeMentions === false) return {
|
|
1117
|
-
body,
|
|
1118
|
-
html: markdownToMatrixHtml(markdown, { tableMode: params.tableMode }).trimEnd() || void 0
|
|
1119
|
-
};
|
|
574
|
+
if (params.includeMentions === false) return { html: markdownToMatrixHtml(markdown).trimEnd() || void 0 };
|
|
1120
575
|
const { html, mentions } = await renderMarkdownToMatrixHtmlWithMentions({
|
|
1121
576
|
markdown,
|
|
1122
|
-
client: params.client
|
|
1123
|
-
tableMode: params.tableMode
|
|
577
|
+
client: params.client
|
|
1124
578
|
});
|
|
1125
579
|
return {
|
|
1126
|
-
body,
|
|
1127
580
|
html,
|
|
1128
581
|
mentions
|
|
1129
582
|
};
|
|
@@ -1140,13 +593,11 @@ function buildTextContent(body, relation, opts = {}) {
|
|
|
1140
593
|
};
|
|
1141
594
|
}
|
|
1142
595
|
async function enrichMatrixFormattedContent(params) {
|
|
1143
|
-
const {
|
|
596
|
+
const { html, mentions } = await renderMatrixFormattedContent({
|
|
1144
597
|
client: params.client,
|
|
1145
598
|
markdown: params.markdown,
|
|
1146
|
-
includeMentions: params.includeMentions
|
|
1147
|
-
tableMode: params.tableMode
|
|
599
|
+
includeMentions: params.includeMentions
|
|
1148
600
|
});
|
|
1149
|
-
params.content.body = body || params.content.body;
|
|
1150
601
|
if (mentions) params.content["m.mentions"] = mentions;
|
|
1151
602
|
else delete params.content["m.mentions"];
|
|
1152
603
|
if (!html) {
|
|
@@ -1203,7 +654,7 @@ function buildThreadRelation(threadId, replyToId) {
|
|
|
1203
654
|
return relation;
|
|
1204
655
|
}
|
|
1205
656
|
function resolveMatrixMsgType(contentType, _fileName) {
|
|
1206
|
-
switch (getCore$
|
|
657
|
+
switch (getCore$2().media.mediaKindFromMime(contentType ?? "")) {
|
|
1207
658
|
case "image": return MsgType.Image;
|
|
1208
659
|
case "audio": return MsgType.Audio;
|
|
1209
660
|
case "video": return MsgType.Video;
|
|
@@ -1216,14 +667,14 @@ function resolveMatrixVoiceDecision(opts) {
|
|
|
1216
667
|
return { useVoice: false };
|
|
1217
668
|
}
|
|
1218
669
|
function isMatrixVoiceCompatibleAudio(opts) {
|
|
1219
|
-
return
|
|
670
|
+
return getCore$2().media.isVoiceCompatibleAudio({
|
|
1220
671
|
contentType: opts.contentType,
|
|
1221
672
|
fileName: opts.fileName
|
|
1222
673
|
});
|
|
1223
674
|
}
|
|
1224
675
|
//#endregion
|
|
1225
676
|
//#region extensions/matrix/src/matrix/send/media.ts
|
|
1226
|
-
const getCore = () => getMatrixRuntime();
|
|
677
|
+
const getCore$1 = () => getMatrixRuntime();
|
|
1227
678
|
function buildMatrixMediaInfo(params) {
|
|
1228
679
|
const base = {};
|
|
1229
680
|
if (Number.isFinite(params.size)) base.size = params.size;
|
|
@@ -1271,20 +722,20 @@ function buildMediaContent(params) {
|
|
|
1271
722
|
const THUMBNAIL_MAX_SIDE = 800;
|
|
1272
723
|
const THUMBNAIL_QUALITY = 80;
|
|
1273
724
|
async function prepareImageInfo(params) {
|
|
1274
|
-
const meta = await getCore().media.getImageMetadata(params.buffer).catch(() => null);
|
|
725
|
+
const meta = await getCore$1().media.getImageMetadata(params.buffer).catch(() => null);
|
|
1275
726
|
if (!meta) return;
|
|
1276
727
|
const imageInfo = {
|
|
1277
728
|
w: meta.width,
|
|
1278
729
|
h: meta.height
|
|
1279
730
|
};
|
|
1280
731
|
if (Math.max(meta.width, meta.height) > THUMBNAIL_MAX_SIDE) try {
|
|
1281
|
-
const thumbBuffer = await getCore().media.resizeToJpeg({
|
|
732
|
+
const thumbBuffer = await getCore$1().media.resizeToJpeg({
|
|
1282
733
|
buffer: params.buffer,
|
|
1283
734
|
maxSide: THUMBNAIL_MAX_SIDE,
|
|
1284
735
|
quality: THUMBNAIL_QUALITY,
|
|
1285
736
|
withoutEnlargement: true
|
|
1286
737
|
});
|
|
1287
|
-
const thumbMeta = await getCore().media.getImageMetadata(thumbBuffer).catch(() => null);
|
|
738
|
+
const thumbMeta = await getCore$1().media.getImageMetadata(thumbBuffer).catch(() => null);
|
|
1288
739
|
const result = await uploadMediaWithEncryption(params.client, thumbBuffer, {
|
|
1289
740
|
contentType: "image/jpeg",
|
|
1290
741
|
filename: "thumbnail.jpg",
|
|
@@ -1352,13 +803,18 @@ var direct_room_exports = /* @__PURE__ */ __exportAll({
|
|
|
1352
803
|
isStrictDirectRoom: () => isStrictDirectRoom,
|
|
1353
804
|
readJoinedMatrixMembers: () => readJoinedMatrixMembers
|
|
1354
805
|
});
|
|
806
|
+
function trimMaybeString(value) {
|
|
807
|
+
if (typeof value !== "string") return null;
|
|
808
|
+
const trimmed = value.trim();
|
|
809
|
+
return trimmed.length > 0 ? trimmed : null;
|
|
810
|
+
}
|
|
1355
811
|
function normalizeJoinedMatrixMembers(joinedMembers) {
|
|
1356
812
|
if (!Array.isArray(joinedMembers)) return [];
|
|
1357
|
-
return joinedMembers.map((entry) =>
|
|
813
|
+
return joinedMembers.map((entry) => trimMaybeString(entry)).filter((entry) => Boolean(entry));
|
|
1358
814
|
}
|
|
1359
815
|
function isStrictDirectMembership(params) {
|
|
1360
|
-
const selfUserId =
|
|
1361
|
-
const remoteUserId =
|
|
816
|
+
const selfUserId = trimMaybeString(params.selfUserId);
|
|
817
|
+
const remoteUserId = trimMaybeString(params.remoteUserId);
|
|
1362
818
|
const joinedMembers = params.joinedMembers ?? [];
|
|
1363
819
|
return Boolean(selfUserId && remoteUserId && joinedMembers.length === 2 && joinedMembers.includes(selfUserId) && joinedMembers.includes(remoteUserId));
|
|
1364
820
|
}
|
|
@@ -1370,7 +826,7 @@ async function readJoinedMatrixMembers(client, roomId) {
|
|
|
1370
826
|
}
|
|
1371
827
|
}
|
|
1372
828
|
async function hasDirectMatrixMemberFlag(client, roomId, userId) {
|
|
1373
|
-
const normalizedUserId =
|
|
829
|
+
const normalizedUserId = trimMaybeString(userId);
|
|
1374
830
|
if (!normalizedUserId) return null;
|
|
1375
831
|
try {
|
|
1376
832
|
const state = await client.getRoomStateEvent(roomId, "m.room.member", normalizedUserId);
|
|
@@ -1382,7 +838,7 @@ async function hasDirectMatrixMemberFlag(client, roomId, userId) {
|
|
|
1382
838
|
}
|
|
1383
839
|
}
|
|
1384
840
|
async function inspectMatrixDirectRoomEvidence(params) {
|
|
1385
|
-
const selfUserId = params.selfUserId !== void 0 ?
|
|
841
|
+
const selfUserId = params.selfUserId !== void 0 ? trimMaybeString(params.selfUserId) : trimMaybeString(await params.client.getUserId().catch(() => null));
|
|
1386
842
|
const joinedMembers = await readJoinedMatrixMembers(params.client, params.roomId);
|
|
1387
843
|
const strict = isStrictDirectMembership({
|
|
1388
844
|
selfUserId,
|
|
@@ -1706,6 +1162,8 @@ var send_exports = /* @__PURE__ */ __exportAll({
|
|
|
1706
1162
|
sendSingleTextMessageMatrix: () => sendSingleTextMessageMatrix,
|
|
1707
1163
|
sendTypingMatrix: () => sendTypingMatrix
|
|
1708
1164
|
});
|
|
1165
|
+
const MATRIX_TEXT_LIMIT = 4e3;
|
|
1166
|
+
const getCore = () => getMatrixRuntime();
|
|
1709
1167
|
function createMatrixSendReceipt(params) {
|
|
1710
1168
|
return createMessageReceiptFromOutboundResults({
|
|
1711
1169
|
kind: params.kind,
|
|
@@ -1768,6 +1226,32 @@ async function resolvePreviousEditMentions(params) {
|
|
|
1768
1226
|
body
|
|
1769
1227
|
});
|
|
1770
1228
|
}
|
|
1229
|
+
function prepareMatrixSingleText(text, opts) {
|
|
1230
|
+
const trimmedText = text.trim();
|
|
1231
|
+
const cfg = requireRuntimeConfig(opts.cfg, "Matrix text preparation");
|
|
1232
|
+
const tableMode = opts.tableMode ?? getCore().channel.text.resolveMarkdownTableMode({
|
|
1233
|
+
cfg,
|
|
1234
|
+
channel: "matrix",
|
|
1235
|
+
accountId: opts.accountId
|
|
1236
|
+
});
|
|
1237
|
+
const convertedText = getCore().channel.text.convertMarkdownTables(trimmedText, tableMode);
|
|
1238
|
+
const singleEventLimit = Math.min(getCore().channel.text.resolveTextChunkLimit(cfg, "matrix", opts.accountId), MATRIX_TEXT_LIMIT);
|
|
1239
|
+
return {
|
|
1240
|
+
trimmedText,
|
|
1241
|
+
convertedText,
|
|
1242
|
+
singleEventLimit,
|
|
1243
|
+
fitsInSingleEvent: convertedText.length <= singleEventLimit
|
|
1244
|
+
};
|
|
1245
|
+
}
|
|
1246
|
+
function chunkMatrixText(text, opts) {
|
|
1247
|
+
const preparedText = prepareMatrixSingleText(text, opts);
|
|
1248
|
+
const cfg = requireRuntimeConfig(opts.cfg, "Matrix text chunking");
|
|
1249
|
+
const chunkMode = getCore().channel.text.resolveChunkMode(cfg, "matrix", opts.accountId);
|
|
1250
|
+
return {
|
|
1251
|
+
...preparedText,
|
|
1252
|
+
chunks: getCore().channel.text.chunkMarkdownTextWithMode(preparedText.convertedText, preparedText.singleEventLimit, chunkMode)
|
|
1253
|
+
};
|
|
1254
|
+
}
|
|
1771
1255
|
async function sendMessageMatrix(to, message, opts) {
|
|
1772
1256
|
const trimmedMessage = message?.trim() ?? "";
|
|
1773
1257
|
if (!trimmedMessage && !opts.mediaUrl) throw new Error("Matrix send requires text or media");
|
|
@@ -1779,7 +1263,7 @@ async function sendMessageMatrix(to, message, opts) {
|
|
|
1779
1263
|
}, async (client) => {
|
|
1780
1264
|
const roomId = await resolveMatrixRoomId(client, to);
|
|
1781
1265
|
const cfg = requireRuntimeConfig(opts.cfg, "Matrix send");
|
|
1782
|
-
const { chunks
|
|
1266
|
+
const { chunks } = chunkMatrixText(trimmedMessage, {
|
|
1783
1267
|
cfg,
|
|
1784
1268
|
accountId: opts.accountId
|
|
1785
1269
|
});
|
|
@@ -1790,27 +1274,21 @@ async function sendMessageMatrix(to, message, opts) {
|
|
|
1790
1274
|
const contentWithExtra = withMatrixExtraContentFields(content, pendingExtraContent);
|
|
1791
1275
|
pendingExtraContent = void 0;
|
|
1792
1276
|
const eventId = await client.sendMessage(roomId, contentWithExtra);
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1277
|
+
if (eventId) await opts.onDeliveryResult?.({
|
|
1278
|
+
messageId: eventId,
|
|
1279
|
+
roomId,
|
|
1280
|
+
primaryMessageId: eventId,
|
|
1281
|
+
receipt: createMatrixSendReceipt({
|
|
1798
1282
|
roomId,
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
threadId
|
|
1806
|
-
}),
|
|
1807
|
-
content: visibleContent
|
|
1808
|
-
});
|
|
1809
|
-
}
|
|
1283
|
+
platformMessageIds: [eventId],
|
|
1284
|
+
kind,
|
|
1285
|
+
replyToId: opts.replyToId,
|
|
1286
|
+
threadId
|
|
1287
|
+
})
|
|
1288
|
+
});
|
|
1810
1289
|
return eventId;
|
|
1811
1290
|
};
|
|
1812
1291
|
const platformMessageIds = [];
|
|
1813
|
-
const acceptedContents = [];
|
|
1814
1292
|
let lastMessageId = "";
|
|
1815
1293
|
let receiptKind = "text";
|
|
1816
1294
|
if (opts.mediaUrl) {
|
|
@@ -1829,7 +1307,7 @@ async function sendMessageMatrix(to, message, opts) {
|
|
|
1829
1307
|
buffer: media.buffer,
|
|
1830
1308
|
contentType: media.contentType,
|
|
1831
1309
|
fileName: media.fileName,
|
|
1832
|
-
kind: media.kind
|
|
1310
|
+
kind: media.kind ?? "unknown"
|
|
1833
1311
|
});
|
|
1834
1312
|
const baseMsgType = resolveMatrixMsgType(media.contentType, media.fileName);
|
|
1835
1313
|
const { useVoice } = resolveMatrixVoiceDecision({
|
|
@@ -1862,8 +1340,7 @@ async function sendMessageMatrix(to, message, opts) {
|
|
|
1862
1340
|
await enrichMatrixFormattedContent({
|
|
1863
1341
|
client,
|
|
1864
1342
|
content,
|
|
1865
|
-
markdown: captionMarkdown
|
|
1866
|
-
tableMode
|
|
1343
|
+
markdown: captionMarkdown
|
|
1867
1344
|
});
|
|
1868
1345
|
const eventId = await sendContent(content, receiptKind);
|
|
1869
1346
|
lastMessageId = eventId ?? lastMessageId;
|
|
@@ -1871,28 +1348,26 @@ async function sendMessageMatrix(to, message, opts) {
|
|
|
1871
1348
|
const textChunks = useVoice ? chunks : rest;
|
|
1872
1349
|
const followupRelation = useVoice || threadId ? relation : void 0;
|
|
1873
1350
|
for (const chunk of textChunks) {
|
|
1874
|
-
const text = chunk;
|
|
1875
|
-
if (!text
|
|
1351
|
+
const text = chunk.trim();
|
|
1352
|
+
if (!text) continue;
|
|
1876
1353
|
const followup = buildTextContent(text, followupRelation);
|
|
1877
1354
|
await enrichMatrixFormattedContent({
|
|
1878
1355
|
client,
|
|
1879
1356
|
content: followup,
|
|
1880
|
-
markdown: text
|
|
1881
|
-
tableMode
|
|
1357
|
+
markdown: text
|
|
1882
1358
|
});
|
|
1883
1359
|
const followupEventId = await sendContent(followup, "text");
|
|
1884
1360
|
lastMessageId = followupEventId ?? lastMessageId;
|
|
1885
1361
|
if (followupEventId) platformMessageIds.push(followupEventId);
|
|
1886
1362
|
}
|
|
1887
1363
|
} else for (const chunk of chunks.length ? chunks : [""]) {
|
|
1888
|
-
const text = chunk;
|
|
1889
|
-
if (!text
|
|
1364
|
+
const text = chunk.trim();
|
|
1365
|
+
if (!text) continue;
|
|
1890
1366
|
const content = buildTextContent(text, relation);
|
|
1891
1367
|
await enrichMatrixFormattedContent({
|
|
1892
1368
|
client,
|
|
1893
1369
|
content,
|
|
1894
|
-
markdown: text
|
|
1895
|
-
tableMode
|
|
1370
|
+
markdown: text
|
|
1896
1371
|
});
|
|
1897
1372
|
const eventId = await sendContent(content, "text");
|
|
1898
1373
|
lastMessageId = eventId ?? lastMessageId;
|
|
@@ -1908,8 +1383,7 @@ async function sendMessageMatrix(to, message, opts) {
|
|
|
1908
1383
|
kind: receiptKind,
|
|
1909
1384
|
replyToId: opts.replyToId,
|
|
1910
1385
|
threadId
|
|
1911
|
-
})
|
|
1912
|
-
content: acceptedContents.join("\n")
|
|
1386
|
+
})
|
|
1913
1387
|
};
|
|
1914
1388
|
});
|
|
1915
1389
|
}
|
|
@@ -1967,12 +1441,12 @@ async function sendReadReceiptMatrix(roomId, eventId, client) {
|
|
|
1967
1441
|
});
|
|
1968
1442
|
}
|
|
1969
1443
|
async function sendSingleTextMessageMatrix(roomId, text, opts) {
|
|
1970
|
-
const { trimmedText, convertedText, singleEventLimit,
|
|
1444
|
+
const { trimmedText, convertedText, singleEventLimit, fitsInSingleEvent } = prepareMatrixSingleText(text, {
|
|
1971
1445
|
cfg: opts.cfg,
|
|
1972
1446
|
accountId: opts.accountId
|
|
1973
1447
|
});
|
|
1974
1448
|
if (!trimmedText) throw new Error("Matrix single-message send requires text");
|
|
1975
|
-
if (!fitsInSingleEvent) throw new Error(`Matrix single-message text exceeds limit (${
|
|
1449
|
+
if (!fitsInSingleEvent) throw new Error(`Matrix single-message text exceeds limit (${convertedText.length} > ${singleEventLimit})`);
|
|
1976
1450
|
return await withResolvedMatrixSendClient({
|
|
1977
1451
|
client: opts.client,
|
|
1978
1452
|
cfg: opts.cfg,
|
|
@@ -1986,8 +1460,7 @@ async function sendSingleTextMessageMatrix(roomId, text, opts) {
|
|
|
1986
1460
|
client,
|
|
1987
1461
|
content,
|
|
1988
1462
|
markdown: convertedText,
|
|
1989
|
-
includeMentions: opts.includeMentions
|
|
1990
|
-
tableMode
|
|
1463
|
+
includeMentions: opts.includeMentions
|
|
1991
1464
|
});
|
|
1992
1465
|
if (opts.live) content[MSC4357_LIVE_KEY] = {};
|
|
1993
1466
|
const eventId = await client.sendMessage(resolvedRoom, content);
|
|
@@ -2001,8 +1474,7 @@ async function sendSingleTextMessageMatrix(roomId, text, opts) {
|
|
|
2001
1474
|
kind: "text",
|
|
2002
1475
|
replyToId: opts.replyToId,
|
|
2003
1476
|
threadId: normalizedThreadId
|
|
2004
|
-
})
|
|
2005
|
-
content: content.body
|
|
1477
|
+
})
|
|
2006
1478
|
};
|
|
2007
1479
|
});
|
|
2008
1480
|
}
|
|
@@ -2019,18 +1491,19 @@ async function editMessageMatrix(roomId, originalEventId, newText, opts) {
|
|
|
2019
1491
|
timeoutMs: opts.timeoutMs
|
|
2020
1492
|
}, async (client) => {
|
|
2021
1493
|
const resolvedRoom = await resolveMatrixRoomId(client, roomId);
|
|
2022
|
-
const
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
1494
|
+
const cfg = requireRuntimeConfig(opts.cfg, "Matrix message edit");
|
|
1495
|
+
const tableMode = getCore().channel.text.resolveMarkdownTableMode({
|
|
1496
|
+
cfg,
|
|
1497
|
+
channel: "matrix",
|
|
1498
|
+
accountId: opts.accountId
|
|
2026
1499
|
});
|
|
1500
|
+
const convertedText = getCore().channel.text.convertMarkdownTables(newText, tableMode);
|
|
2027
1501
|
const newContent = withMatrixExtraContentFields(buildTextContent(convertedText, void 0, { msgtype: opts.msgtype }), opts.extraContent);
|
|
2028
1502
|
await enrichMatrixFormattedContent({
|
|
2029
1503
|
client,
|
|
2030
1504
|
content: newContent,
|
|
2031
1505
|
markdown: convertedText,
|
|
2032
|
-
includeMentions: opts.includeMentions
|
|
2033
|
-
tableMode
|
|
1506
|
+
includeMentions: opts.includeMentions
|
|
2034
1507
|
});
|
|
2035
1508
|
const previousEvent = await getPreviousMatrixEvent(client, resolvedRoom, originalEventId);
|
|
2036
1509
|
const replaceMentions = opts.includeMentions === false ? void 0 : diffMatrixMentions(extractMatrixMentions(newContent), await resolvePreviousEditMentions({
|
|
@@ -2047,7 +1520,7 @@ async function editMessageMatrix(roomId, originalEventId, newText, opts) {
|
|
|
2047
1520
|
}
|
|
2048
1521
|
const content = {
|
|
2049
1522
|
...newContent,
|
|
2050
|
-
body: `* ${
|
|
1523
|
+
body: `* ${convertedText}`,
|
|
2051
1524
|
...typeof newContent.formatted_body === "string" ? { formatted_body: `* ${newContent.formatted_body}` } : {},
|
|
2052
1525
|
"m.new_content": newContent,
|
|
2053
1526
|
"m.relates_to": replaceRelation
|
|
@@ -2074,4 +1547,4 @@ async function reactMatrixMessage(roomId, messageId, emoji, opts) {
|
|
|
2074
1547
|
});
|
|
2075
1548
|
}
|
|
2076
1549
|
//#endregion
|
|
2077
|
-
export { formatPollResultsAsText as C, parsePollStartContent as D, parsePollStart as E, resolvePollReferenceEventId as O, formatPollAsText as S, isPollStartType as T,
|
|
1550
|
+
export { formatPollResultsAsText as C, parsePollStartContent as D, parsePollStart as E, resolvePollReferenceEventId as O, formatPollAsText as S, isPollStartType as T, readJoinedMatrixMembers as _, sendMessageMatrix as a, buildPollResponseContent as b, sendTypingMatrix as c, direct_management_exports as d, promoteMatrixDirectRoomCandidate as f, isStrictDirectMembership as g, hasDirectMatrixMemberFlag as h, reactMatrixMessage as i, send_exports as l, direct_room_exports as m, editMessageMatrix as n, sendPollMatrix as o, repairMatrixDirectRooms as p, prepareMatrixSingleText as r, sendSingleTextMessageMatrix as s, chunkMatrixText as t, resolveMatrixRoomId as u, MATRIX_OPENCLAW_FINALIZED_PREVIEW_KEY as v, isPollEventType as w, buildPollResultsSummary as x, MsgType as y };
|