@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,23 +1,26 @@
|
|
|
1
|
-
import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.
|
|
2
|
-
import { a as resolveMatrixDefaultOrOnlyAccountId, n as requiresExplicitMatrixDefaultAccount,
|
|
3
|
-
import { t as getMatrixScopedEnvVarNames } from "./env-vars-
|
|
4
|
-
import { o as resolveMatrixBaseConfig, r as listNormalizedMatrixAccountIds, t as findMatrixAccountConfig } from "./account-config-BZWN9tGS.
|
|
5
|
-
import {
|
|
6
|
-
import { t as resolveMatrixConfigFieldPath } from "./config-paths-CnREYb1Y.
|
|
7
|
-
import { t as resolveValidatedMatrixHomeserverUrl } from "./url-validation-GRHde6lq.
|
|
8
|
-
import { s as repairCurrentTokenStorageMetaDeviceId } from "./storage-
|
|
9
|
-
import { n as LogService } from "./logger-
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.mjs";
|
|
2
|
+
import { a as resolveMatrixDefaultOrOnlyAccountId, n as requiresExplicitMatrixDefaultAccount, s as resolveMatrixAccountStringValues } from "./account-selection-BOQeTqax.mjs";
|
|
3
|
+
import { t as getMatrixScopedEnvVarNames } from "./env-vars-KzaYveuy.mjs";
|
|
4
|
+
import { o as resolveMatrixBaseConfig, r as listNormalizedMatrixAccountIds, t as findMatrixAccountConfig } from "./account-config-BZWN9tGS.mjs";
|
|
5
|
+
import { r as resolveScopedMatrixEnvConfig, t as resolveGlobalMatrixEnvConfig } from "./env-auth-CYJL1jNl.mjs";
|
|
6
|
+
import { t as resolveMatrixConfigFieldPath } from "./config-paths-CnREYb1Y.mjs";
|
|
7
|
+
import { t as resolveValidatedMatrixHomeserverUrl } from "./url-validation-GRHde6lq.mjs";
|
|
8
|
+
import { d as writeStorageMeta, l as resolveMatrixStoragePaths, r as maybeMigrateLegacyStorage, s as repairCurrentTokenStorageMetaDeviceId } from "./storage-NGZq5zet.mjs";
|
|
9
|
+
import { n as LogService } from "./logger-DpoogOgz.mjs";
|
|
10
10
|
import { createLazyRuntimeModule } from "openclaw/plugin-sdk/lazy-runtime";
|
|
11
|
+
import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
11
12
|
import { DEFAULT_ACCOUNT_ID as DEFAULT_ACCOUNT_ID$1, normalizeAccountId as normalizeAccountId$1, normalizeOptionalAccountId, normalizeOptionalAccountId as normalizeOptionalAccountId$1 } from "openclaw/plugin-sdk/account-id";
|
|
12
13
|
import { coerceSecretRef, normalizeResolvedSecretInputString } from "openclaw/plugin-sdk/secret-input-runtime";
|
|
13
|
-
import
|
|
14
|
-
import {
|
|
14
|
+
import fs from "node:fs";
|
|
15
|
+
import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
|
|
16
|
+
import { isPrivateNetworkOptInEnabled, ssrfPolicyFromDangerouslyAllowPrivateNetwork, ssrfPolicyFromDangerouslyAllowPrivateNetwork as ssrfPolicyFromDangerouslyAllowPrivateNetwork$1 } from "openclaw/plugin-sdk/ssrf-runtime";
|
|
15
17
|
import { resolveOptionalIntegerOption } from "openclaw/plugin-sdk/number-runtime";
|
|
16
18
|
import { requireRuntimeConfig } from "openclaw/plugin-sdk/plugin-config-runtime";
|
|
17
19
|
import { retryAsync } from "openclaw/plugin-sdk/retry-runtime";
|
|
18
|
-
import {
|
|
20
|
+
import { createDeferred } from "openclaw/plugin-sdk/extension-shared";
|
|
21
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
19
22
|
//#region extensions/matrix/src/matrix/client/config.ts
|
|
20
|
-
const loadDefaultMatrixAuthClientDeps = createLazyRuntimeModule(() => Promise.all([import("./sdk-
|
|
23
|
+
const loadDefaultMatrixAuthClientDeps = createLazyRuntimeModule(() => Promise.all([import("./sdk-He1quVAq.mjs").then((n) => n.t), import("./logging-CgxQOJJP.mjs")]).then(([sdkModule, loggingModule]) => ({
|
|
21
24
|
MatrixClient: sdkModule.MatrixClient,
|
|
22
25
|
ensureMatrixSdkLoggingConfigured: loggingModule.ensureMatrixSdkLoggingConfigured
|
|
23
26
|
})));
|
|
@@ -25,12 +28,12 @@ const MATRIX_AUTH_REQUEST_RETRY_RE = /\b(fetch failed|econnreset|econnrefused|en
|
|
|
25
28
|
async function loadMatrixAuthClientDeps() {
|
|
26
29
|
return await loadDefaultMatrixAuthClientDeps();
|
|
27
30
|
}
|
|
28
|
-
const loadMatrixCredentialsReadDeps = createLazyRuntimeModule(() => import("./credentials-read-
|
|
31
|
+
const loadMatrixCredentialsReadDeps = createLazyRuntimeModule(() => import("./credentials-read-CRHg6XPm.mjs").then((n) => n.r).then((credentialsReadModule) => ({
|
|
29
32
|
loadMatrixCredentials: credentialsReadModule.loadMatrixCredentials,
|
|
30
33
|
credentialsMatchConfig: credentialsReadModule.credentialsMatchConfig
|
|
31
34
|
})));
|
|
32
|
-
const loadMatrixCredentialsWriteRuntime = createLazyRuntimeModule(() => import("./credentials-write.runtime-
|
|
33
|
-
const loadMatrixSecretInputDeps = createLazyRuntimeModule(() => import("./config-secret-input.runtime-CwsP3--c.
|
|
35
|
+
const loadMatrixCredentialsWriteRuntime = createLazyRuntimeModule(() => import("./credentials-write.runtime-dWuLafsk.mjs"));
|
|
36
|
+
const loadMatrixSecretInputDeps = createLazyRuntimeModule(() => import("./config-secret-input.runtime-CwsP3--c.mjs").then((runtime) => ({ resolveConfiguredSecretInputString: runtime.resolveConfiguredSecretInputString })));
|
|
34
37
|
function shouldRetryMatrixAuthRequest(err) {
|
|
35
38
|
return MATRIX_AUTH_REQUEST_RETRY_RE.test(formatErrorMessage(err));
|
|
36
39
|
}
|
|
@@ -41,15 +44,14 @@ function credentialsMatchBackfillAuthLineage(params) {
|
|
|
41
44
|
if (!params.stored) return true;
|
|
42
45
|
return params.stored.homeserver === params.auth.homeserver && params.stored.userId === params.auth.userId && params.stored.accessToken === params.auth.accessToken;
|
|
43
46
|
}
|
|
44
|
-
async function retryMatrixAuthRequest(label, run
|
|
47
|
+
async function retryMatrixAuthRequest(label, run) {
|
|
45
48
|
return await retryAsync(run, {
|
|
46
49
|
attempts: 3,
|
|
47
50
|
minDelayMs: 250,
|
|
48
51
|
maxDelayMs: 1500,
|
|
49
52
|
jitter: .1,
|
|
50
53
|
label,
|
|
51
|
-
shouldRetry: (err) => shouldRetryMatrixAuthRequest(err)
|
|
52
|
-
sleep: (ms) => sleepWithAbort(ms, signal)
|
|
54
|
+
shouldRetry: (err) => shouldRetryMatrixAuthRequest(err)
|
|
53
55
|
});
|
|
54
56
|
}
|
|
55
57
|
async function fetchMatrixWhoamiIdentity(params) {
|
|
@@ -62,7 +64,7 @@ async function fetchMatrixWhoamiIdentity(params) {
|
|
|
62
64
|
});
|
|
63
65
|
return await retryMatrixAuthRequest("matrix auth whoami", async () => {
|
|
64
66
|
return await tempClient.doRequest("GET", "/_matrix/client/v3/account/whoami");
|
|
65
|
-
}
|
|
67
|
+
});
|
|
66
68
|
}
|
|
67
69
|
function readEnvSecretRefFallback(params) {
|
|
68
70
|
const ref = coerceSecretRef(params.value, params.config?.secrets?.defaults);
|
|
@@ -80,12 +82,13 @@ function readEnvSecretRefFallback(params) {
|
|
|
80
82
|
function clean(value, path, opts) {
|
|
81
83
|
const ref = coerceSecretRef(value, opts?.config?.secrets?.defaults);
|
|
82
84
|
if (opts?.suppressSecretRef && ref) return "";
|
|
85
|
+
const normalizedValue = opts?.allowEnvSecretRefFallback ? ref?.source === "env" ? readEnvSecretRefFallback({
|
|
86
|
+
value,
|
|
87
|
+
env: opts.env,
|
|
88
|
+
config: opts.config
|
|
89
|
+
}) ?? value : ref ? "" : value : value;
|
|
83
90
|
return normalizeResolvedSecretInputString({
|
|
84
|
-
value:
|
|
85
|
-
value,
|
|
86
|
-
env: opts.env,
|
|
87
|
-
config: opts.config
|
|
88
|
-
}) ?? value : ref ? "" : value : value,
|
|
91
|
+
value: normalizedValue,
|
|
89
92
|
path,
|
|
90
93
|
defaults: opts?.config?.secrets?.defaults
|
|
91
94
|
}) ?? "";
|
|
@@ -256,15 +259,10 @@ function resolveImplicitMatrixAccountId(cfg, env = process.env) {
|
|
|
256
259
|
function resolveMatrixAuthContext(params) {
|
|
257
260
|
const cfg = requireRuntimeConfig(params.cfg, "Matrix auth context");
|
|
258
261
|
const env = params?.env ?? process.env;
|
|
259
|
-
const requestedAccountId = params?.accountId?.trim();
|
|
260
262
|
const explicitAccountId = normalizeOptionalAccountId$1(params?.accountId);
|
|
261
|
-
if (requestedAccountId && !explicitAccountId) throw new Error(`Matrix account id "${requestedAccountId}" is invalid.`);
|
|
262
263
|
const effectiveAccountId = explicitAccountId ?? resolveImplicitMatrixAccountId(cfg, env);
|
|
263
264
|
if (!effectiveAccountId) throw new Error("Multiple Matrix accounts are configured and channels.matrix.defaultAccount is not set. Set \"channels.matrix.defaultAccount\" to the intended account or pass --account <id>.");
|
|
264
265
|
if (explicitAccountId && explicitAccountId !== DEFAULT_ACCOUNT_ID$1 && !listNormalizedMatrixAccountIds(cfg).includes(explicitAccountId) && !hasScopedMatrixEnvConfig(explicitAccountId, env)) throw new Error(`Matrix account "${explicitAccountId}" is not configured. Add channels.matrix.accounts.${explicitAccountId} or define scoped ${getMatrixScopedEnvVarNames(explicitAccountId).accessToken.replace(/_ACCESS_TOKEN$/, "")}_* variables.`);
|
|
265
|
-
const matrix = resolveMatrixBaseConfig(cfg);
|
|
266
|
-
const account = findMatrixAccountConfig(cfg, effectiveAccountId);
|
|
267
|
-
if (matrix.enabled === false || account?.enabled === false) throw new Error(`Matrix account "${effectiveAccountId}" is disabled.`);
|
|
268
266
|
return {
|
|
269
267
|
cfg,
|
|
270
268
|
env,
|
|
@@ -414,21 +412,13 @@ async function backfillMatrixAuthDeviceIdAfterStartup(params) {
|
|
|
414
412
|
const knownDeviceId = params.auth.deviceId?.trim();
|
|
415
413
|
if (knownDeviceId) return knownDeviceId;
|
|
416
414
|
if (isAbortSignalTriggered(params.abortSignal)) return;
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
dispatcherPolicy: params.auth.dispatcherPolicy,
|
|
425
|
-
signal: params.abortSignal
|
|
426
|
-
});
|
|
427
|
-
} catch (err) {
|
|
428
|
-
if (isAbortSignalTriggered(params.abortSignal)) return;
|
|
429
|
-
throw err;
|
|
430
|
-
}
|
|
431
|
-
const deviceId = whoami.device_id?.trim();
|
|
415
|
+
const deviceId = (await fetchMatrixWhoamiIdentity({
|
|
416
|
+
homeserver: params.auth.homeserver,
|
|
417
|
+
accessToken: params.auth.accessToken,
|
|
418
|
+
userId: params.auth.userId,
|
|
419
|
+
ssrfPolicy: params.auth.ssrfPolicy,
|
|
420
|
+
dispatcherPolicy: params.auth.dispatcherPolicy
|
|
421
|
+
})).device_id?.trim();
|
|
432
422
|
if (!deviceId) return;
|
|
433
423
|
if (isAbortSignalTriggered(params.abortSignal)) return;
|
|
434
424
|
const env = params.env ?? process.env;
|
|
@@ -454,6 +444,96 @@ async function backfillMatrixAuthDeviceIdAfterStartup(params) {
|
|
|
454
444
|
}, env, params.auth.accountId) === "saved" ? deviceId : void 0;
|
|
455
445
|
}
|
|
456
446
|
//#endregion
|
|
447
|
+
//#region extensions/matrix/src/matrix/client/create-client.ts
|
|
448
|
+
var create_client_exports = /* @__PURE__ */ __exportAll({ createMatrixClient: () => createMatrixClient });
|
|
449
|
+
const loadMatrixCreateClientRuntimeDeps = createLazyRuntimeModule(() => Promise.all([import("./sdk-He1quVAq.mjs").then((n) => n.t), import("./logging-CgxQOJJP.mjs")]).then(([sdkModule, loggingModule]) => ({
|
|
450
|
+
MatrixClient: sdkModule.MatrixClient,
|
|
451
|
+
ensureMatrixSdkLoggingConfigured: loggingModule.ensureMatrixSdkLoggingConfigured
|
|
452
|
+
})));
|
|
453
|
+
async function createMatrixClient(params) {
|
|
454
|
+
const { MatrixClient, ensureMatrixSdkLoggingConfigured } = await loadMatrixCreateClientRuntimeDeps();
|
|
455
|
+
ensureMatrixSdkLoggingConfigured();
|
|
456
|
+
const homeserver = await resolveValidatedMatrixHomeserverUrl(params.homeserver, { dangerouslyAllowPrivateNetwork: params.allowPrivateNetwork });
|
|
457
|
+
const matrixClientUserId = normalizeOptionalString(params.userId);
|
|
458
|
+
const userId = matrixClientUserId ?? "unknown";
|
|
459
|
+
const storagePaths = params.persistStorage !== false ? resolveMatrixStoragePaths({
|
|
460
|
+
homeserver,
|
|
461
|
+
userId,
|
|
462
|
+
accessToken: params.accessToken,
|
|
463
|
+
accountId: params.accountId,
|
|
464
|
+
deviceId: params.deviceId,
|
|
465
|
+
env: process.env
|
|
466
|
+
}) : null;
|
|
467
|
+
if (storagePaths) {
|
|
468
|
+
await maybeMigrateLegacyStorage({
|
|
469
|
+
storagePaths,
|
|
470
|
+
env: process.env
|
|
471
|
+
});
|
|
472
|
+
fs.mkdirSync(storagePaths.rootDir, { recursive: true });
|
|
473
|
+
writeStorageMeta({
|
|
474
|
+
storagePaths,
|
|
475
|
+
homeserver,
|
|
476
|
+
userId,
|
|
477
|
+
accountId: params.accountId,
|
|
478
|
+
deviceId: params.deviceId
|
|
479
|
+
});
|
|
480
|
+
}
|
|
481
|
+
const cryptoDatabasePrefix = storagePaths ? `openclaw-matrix-${storagePaths.accountKey}-${storagePaths.tokenHash}` : void 0;
|
|
482
|
+
return new MatrixClient(homeserver, params.accessToken, {
|
|
483
|
+
userId: matrixClientUserId,
|
|
484
|
+
password: params.password,
|
|
485
|
+
deviceId: params.deviceId,
|
|
486
|
+
encryption: params.encryption,
|
|
487
|
+
localTimeoutMs: params.localTimeoutMs,
|
|
488
|
+
initialSyncLimit: params.initialSyncLimit,
|
|
489
|
+
storageRootDir: storagePaths?.rootDir,
|
|
490
|
+
recoveryKeyPath: storagePaths?.recoveryKeyPath,
|
|
491
|
+
idbSnapshotPath: storagePaths?.idbSnapshotPath,
|
|
492
|
+
cryptoDatabasePrefix,
|
|
493
|
+
autoBootstrapCrypto: params.autoBootstrapCrypto,
|
|
494
|
+
ssrfPolicy: params.ssrfPolicy ?? ssrfPolicyFromDangerouslyAllowPrivateNetwork(params.allowPrivateNetwork),
|
|
495
|
+
dispatcherPolicy: params.dispatcherPolicy
|
|
496
|
+
});
|
|
497
|
+
}
|
|
498
|
+
//#endregion
|
|
499
|
+
//#region extensions/matrix/src/matrix/monitor/task-runner.ts
|
|
500
|
+
const monitorTaskSignal = new AsyncLocalStorage();
|
|
501
|
+
function getMatrixMonitorTaskSignal() {
|
|
502
|
+
return monitorTaskSignal.getStore();
|
|
503
|
+
}
|
|
504
|
+
function createMatrixMonitorTaskRunner(params) {
|
|
505
|
+
const inFlight = /* @__PURE__ */ new Map();
|
|
506
|
+
let closed = false;
|
|
507
|
+
const runDetachedTask = (label, task) => {
|
|
508
|
+
if (closed) return Promise.resolve();
|
|
509
|
+
const controller = new AbortController();
|
|
510
|
+
const trackedTask = monitorTaskSignal.run(controller.signal, () => Promise.resolve().then(task)).catch((error) => {
|
|
511
|
+
const message = String(error);
|
|
512
|
+
params.logVerboseMessage(`matrix: ${label} failed (${message})`);
|
|
513
|
+
params.logger.warn("matrix background task failed", {
|
|
514
|
+
task: label,
|
|
515
|
+
error: message
|
|
516
|
+
});
|
|
517
|
+
}).finally(() => {
|
|
518
|
+
controller.abort();
|
|
519
|
+
inFlight.delete(trackedTask);
|
|
520
|
+
});
|
|
521
|
+
inFlight.set(trackedTask, controller);
|
|
522
|
+
return trackedTask;
|
|
523
|
+
};
|
|
524
|
+
const waitForIdle = async () => {
|
|
525
|
+
while (inFlight.size > 0) await Promise.allSettled(Array.from(inFlight.keys()));
|
|
526
|
+
};
|
|
527
|
+
return {
|
|
528
|
+
close: () => {
|
|
529
|
+
closed = true;
|
|
530
|
+
for (const controller of inFlight.values()) controller.abort();
|
|
531
|
+
},
|
|
532
|
+
runDetachedTask,
|
|
533
|
+
waitForIdle
|
|
534
|
+
};
|
|
535
|
+
}
|
|
536
|
+
//#endregion
|
|
457
537
|
//#region extensions/matrix/src/matrix/startup-abort.ts
|
|
458
538
|
function createMatrixStartupAbortError() {
|
|
459
539
|
const error = /* @__PURE__ */ new Error("Matrix startup aborted");
|
|
@@ -480,22 +560,21 @@ async function awaitMatrixStartupWithAbort(promise, abortSignal) {
|
|
|
480
560
|
resolve(value);
|
|
481
561
|
}, (error) => {
|
|
482
562
|
abortSignal.removeEventListener("abort", onAbort);
|
|
483
|
-
reject(
|
|
563
|
+
reject(toLintErrorObject(error, "Non-Error rejection"));
|
|
484
564
|
});
|
|
485
565
|
});
|
|
486
566
|
}
|
|
567
|
+
function toLintErrorObject(value, fallbackMessage) {
|
|
568
|
+
if (value instanceof Error) return value;
|
|
569
|
+
if (typeof value === "string") return new Error(value);
|
|
570
|
+
const error = new Error(fallbackMessage, { cause: value });
|
|
571
|
+
if (typeof value === "object" && value !== null || typeof value === "function") Object.assign(error, value);
|
|
572
|
+
return error;
|
|
573
|
+
}
|
|
487
574
|
//#endregion
|
|
488
575
|
//#region extensions/matrix/src/matrix/client/shared.ts
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
releaseSharedClientInstance: () => releaseSharedClientInstance,
|
|
492
|
-
removeSharedClientInstance: () => removeSharedClientInstance,
|
|
493
|
-
resolveSharedMatrixClient: () => resolveSharedMatrixClient,
|
|
494
|
-
stopSharedClient: () => stopSharedClient,
|
|
495
|
-
stopSharedClientForAccount: () => stopSharedClientForAccount,
|
|
496
|
-
stopSharedClientInstance: () => stopSharedClientInstance
|
|
497
|
-
});
|
|
498
|
-
const loadMatrixCreateClientDeps = createLazyRuntimeModule(() => import("./create-client-BmSU-q-D.js").then((n) => n.n).then((runtime) => ({ createMatrixClient: runtime.createMatrixClient })));
|
|
576
|
+
const loadMatrixCreateClientDeps = createLazyRuntimeModule(() => Promise.resolve().then(() => create_client_exports).then((runtime) => ({ createMatrixClient: runtime.createMatrixClient })));
|
|
577
|
+
const MATRIX_RETIREMENT_DRAIN_TIMEOUT_MS = 5e3;
|
|
499
578
|
const sharedClientStates = /* @__PURE__ */ new Map();
|
|
500
579
|
const sharedClientPromises = /* @__PURE__ */ new Map();
|
|
501
580
|
function serializeDispatcherPolicyKey(auth) {
|
|
@@ -514,160 +593,324 @@ function buildSharedClientKey(auth) {
|
|
|
514
593
|
}
|
|
515
594
|
async function createSharedMatrixClient(params) {
|
|
516
595
|
const { createMatrixClient } = await loadMatrixCreateClientDeps();
|
|
596
|
+
const client = await createMatrixClient({
|
|
597
|
+
homeserver: params.auth.homeserver,
|
|
598
|
+
userId: params.auth.userId,
|
|
599
|
+
accessToken: params.auth.accessToken,
|
|
600
|
+
password: params.auth.password,
|
|
601
|
+
deviceId: params.auth.deviceId,
|
|
602
|
+
encryption: params.auth.encryption,
|
|
603
|
+
localTimeoutMs: params.timeoutMs,
|
|
604
|
+
initialSyncLimit: params.auth.initialSyncLimit,
|
|
605
|
+
accountId: params.auth.accountId,
|
|
606
|
+
allowPrivateNetwork: params.auth.allowPrivateNetwork,
|
|
607
|
+
ssrfPolicy: params.auth.ssrfPolicy,
|
|
608
|
+
dispatcherPolicy: params.auth.dispatcherPolicy
|
|
609
|
+
});
|
|
517
610
|
return {
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
userId: params.auth.userId,
|
|
521
|
-
accessToken: params.auth.accessToken,
|
|
522
|
-
password: params.auth.password,
|
|
523
|
-
deviceId: params.auth.deviceId,
|
|
524
|
-
encryption: params.auth.encryption,
|
|
525
|
-
localTimeoutMs: params.timeoutMs,
|
|
526
|
-
initialSyncLimit: params.auth.initialSyncLimit,
|
|
527
|
-
accountId: params.auth.accountId,
|
|
528
|
-
allowPrivateNetwork: params.auth.allowPrivateNetwork,
|
|
529
|
-
ssrfPolicy: params.auth.ssrfPolicy,
|
|
530
|
-
dispatcherPolicy: params.auth.dispatcherPolicy
|
|
531
|
-
}),
|
|
611
|
+
auth: params.auth,
|
|
612
|
+
client,
|
|
532
613
|
key: buildSharedClientKey(params.auth),
|
|
533
614
|
started: false,
|
|
534
615
|
cryptoReady: false,
|
|
616
|
+
startAbortController: null,
|
|
535
617
|
startPromise: null,
|
|
536
|
-
|
|
618
|
+
phase: "open",
|
|
619
|
+
leases: /* @__PURE__ */ new Set(),
|
|
620
|
+
monitorRetirementPromises: /* @__PURE__ */ new Set(),
|
|
621
|
+
noLeases: createDeferred(),
|
|
622
|
+
retirementPromise: null,
|
|
623
|
+
poisonError: null,
|
|
624
|
+
releaseMode: "discard"
|
|
537
625
|
};
|
|
538
626
|
}
|
|
539
|
-
function findSharedClientStateByInstance(client) {
|
|
540
|
-
for (const state of sharedClientStates.values()) if (state.client === client) return state;
|
|
541
|
-
return null;
|
|
542
|
-
}
|
|
543
627
|
function deleteSharedClientState(state) {
|
|
544
|
-
sharedClientStates.delete(state.key);
|
|
628
|
+
if (sharedClientStates.get(state.key) === state) sharedClientStates.delete(state.key);
|
|
545
629
|
sharedClientPromises.delete(state.key);
|
|
546
630
|
}
|
|
547
|
-
async function ensureSharedClientStarted(
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
if (params.state.started) return;
|
|
552
|
-
if (params.state.startPromise) {
|
|
553
|
-
await waitForStart(params.state.startPromise);
|
|
631
|
+
async function ensureSharedClientStarted(state, abortSignal) {
|
|
632
|
+
if (state.started) return;
|
|
633
|
+
if (state.startPromise) {
|
|
634
|
+
await awaitMatrixStartupWithAbort(state.startPromise, abortSignal);
|
|
554
635
|
return;
|
|
555
636
|
}
|
|
637
|
+
const startAbortController = new AbortController();
|
|
638
|
+
state.startAbortController = startAbortController;
|
|
556
639
|
const guardedStart = (async () => {
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
params.state.cryptoReady = true;
|
|
640
|
+
if (state.auth.encryption && !state.cryptoReady) try {
|
|
641
|
+
const joinedRooms = await state.client.getJoinedRooms();
|
|
642
|
+
if (state.client.crypto) {
|
|
643
|
+
await state.client.crypto.prepare(joinedRooms);
|
|
644
|
+
state.cryptoReady = true;
|
|
563
645
|
}
|
|
564
646
|
} catch (err) {
|
|
565
647
|
LogService.warn("MatrixClientLite", "Failed to prepare crypto:", err);
|
|
566
648
|
}
|
|
567
|
-
await client.start({ abortSignal:
|
|
568
|
-
|
|
649
|
+
await state.client.start({ abortSignal: startAbortController.signal });
|
|
650
|
+
throwIfMatrixStartupAborted(startAbortController.signal);
|
|
651
|
+
if (state.phase !== "open") throwIfMatrixStartupAborted(AbortSignal.abort());
|
|
652
|
+
state.started = true;
|
|
569
653
|
})().finally(() => {
|
|
570
|
-
if (
|
|
654
|
+
if (state.startPromise === guardedStart) {
|
|
655
|
+
state.startPromise = null;
|
|
656
|
+
state.startAbortController = null;
|
|
657
|
+
}
|
|
571
658
|
});
|
|
572
|
-
|
|
573
|
-
await
|
|
659
|
+
state.startPromise = guardedStart;
|
|
660
|
+
await awaitMatrixStartupWithAbort(guardedStart, abortSignal);
|
|
574
661
|
}
|
|
575
|
-
async function
|
|
662
|
+
async function resolveSharedMatrixAuth(params) {
|
|
576
663
|
const requestedAccountId = normalizeOptionalAccountId(params.accountId);
|
|
577
664
|
if (params.auth && requestedAccountId && requestedAccountId !== params.auth.accountId) throw new Error(`Matrix shared client account mismatch: requested ${requestedAccountId}, auth resolved ${params.auth.accountId}`);
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
env: authContext?.env ?? params.env,
|
|
590
|
-
accountId: authContext?.accountId
|
|
665
|
+
if (params.auth) return params.auth;
|
|
666
|
+
if (!params.cfg) throw new Error("Matrix shared client requires a resolved runtime config. Load and resolve config at the command or gateway boundary, then pass cfg through the runtime path.");
|
|
667
|
+
const authContext = resolveMatrixAuthContext({
|
|
668
|
+
cfg: params.cfg,
|
|
669
|
+
env: params.env,
|
|
670
|
+
accountId: params.accountId
|
|
671
|
+
});
|
|
672
|
+
return await resolveMatrixAuth({
|
|
673
|
+
cfg: authContext.cfg,
|
|
674
|
+
env: authContext.env,
|
|
675
|
+
accountId: authContext.accountId
|
|
591
676
|
});
|
|
677
|
+
}
|
|
678
|
+
async function resolveOpenSharedMatrixClientState(params) {
|
|
679
|
+
const auth = await resolveSharedMatrixAuth(params);
|
|
592
680
|
const key = buildSharedClientKey(auth);
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
if (
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
}
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
abortSignal: params.abortSignal
|
|
681
|
+
while (true) {
|
|
682
|
+
const existing = sharedClientStates.get(key);
|
|
683
|
+
if (existing?.poisonError) throw existing.poisonError;
|
|
684
|
+
if (existing?.phase === "open") return existing;
|
|
685
|
+
if (existing?.retirementPromise) {
|
|
686
|
+
await awaitMatrixStartupWithAbort(existing.retirementPromise, params.abortSignal);
|
|
687
|
+
continue;
|
|
688
|
+
}
|
|
689
|
+
const pending = sharedClientPromises.get(key);
|
|
690
|
+
if (pending) {
|
|
691
|
+
await awaitMatrixStartupWithAbort(pending, params.abortSignal);
|
|
692
|
+
continue;
|
|
693
|
+
}
|
|
694
|
+
const creationPromise = createSharedMatrixClient({
|
|
695
|
+
auth,
|
|
696
|
+
timeoutMs: params.timeoutMs
|
|
610
697
|
});
|
|
611
|
-
|
|
698
|
+
sharedClientPromises.set(key, creationPromise);
|
|
699
|
+
try {
|
|
700
|
+
const created = await creationPromise;
|
|
701
|
+
sharedClientStates.set(key, created);
|
|
702
|
+
return created;
|
|
703
|
+
} finally {
|
|
704
|
+
sharedClientPromises.delete(key);
|
|
705
|
+
}
|
|
612
706
|
}
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
707
|
+
}
|
|
708
|
+
async function runMonitorRetirement(retirement) {
|
|
709
|
+
if (!retirement) return;
|
|
710
|
+
retirement.closeTaskAdmission();
|
|
711
|
+
retirement.detachListeners();
|
|
712
|
+
await retirement.waitForTasks();
|
|
713
|
+
await retirement.cleanup();
|
|
714
|
+
}
|
|
715
|
+
function retireMonitorLease(state, lease) {
|
|
716
|
+
if (lease.monitorRetirementPromise) return lease.monitorRetirementPromise;
|
|
717
|
+
lease.monitorRetirementPromise = runMonitorRetirement(lease.monitorRetirement ?? void 0);
|
|
718
|
+
state.monitorRetirementPromises.add(lease.monitorRetirementPromise);
|
|
719
|
+
return lease.monitorRetirementPromise;
|
|
720
|
+
}
|
|
721
|
+
async function retireMonitorLeases(state, leases) {
|
|
722
|
+
for (const lease of leases) retireMonitorLease(state, lease);
|
|
723
|
+
const failure = (await Promise.allSettled(state.monitorRetirementPromises)).find((result) => result.status === "rejected");
|
|
724
|
+
if (failure?.status === "rejected") throw failure.reason;
|
|
725
|
+
}
|
|
726
|
+
function toRetirementError(error) {
|
|
727
|
+
return error instanceof Error ? error : new Error(String(error));
|
|
728
|
+
}
|
|
729
|
+
function mergeReleaseMode(current, requested) {
|
|
730
|
+
if (current === "persist" || requested === "persist") return "persist";
|
|
731
|
+
if (current === "stop" || requested === "stop") return "stop";
|
|
732
|
+
return "discard";
|
|
733
|
+
}
|
|
734
|
+
function abortTransientLeases(state) {
|
|
735
|
+
for (const lease of state.leases) if (lease.role === "transient") lease.abortController.abort();
|
|
736
|
+
}
|
|
737
|
+
async function waitForRetirementDrain(state, task, isPending, timeoutMessage) {
|
|
738
|
+
if (!isPending()) return;
|
|
739
|
+
let deadline;
|
|
618
740
|
try {
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
741
|
+
await Promise.race([task, new Promise((_, reject) => {
|
|
742
|
+
deadline = setTimeout(() => {
|
|
743
|
+
if (!isPending()) return;
|
|
744
|
+
state.phase = "late-drain";
|
|
745
|
+
reject(new Error(timeoutMessage));
|
|
746
|
+
}, MATRIX_RETIREMENT_DRAIN_TIMEOUT_MS);
|
|
747
|
+
deadline.unref?.();
|
|
748
|
+
})]);
|
|
627
749
|
} finally {
|
|
628
|
-
|
|
750
|
+
if (deadline) clearTimeout(deadline);
|
|
629
751
|
}
|
|
630
752
|
}
|
|
631
|
-
|
|
632
|
-
|
|
753
|
+
function beginGenerationRetirement(params) {
|
|
754
|
+
const { state } = params;
|
|
755
|
+
if (state.retirementPromise) return state.retirementPromise;
|
|
756
|
+
state.phase = "quiescing";
|
|
757
|
+
state.startAbortController?.abort();
|
|
758
|
+
const result = createDeferred();
|
|
759
|
+
state.retirementPromise = result.promise;
|
|
760
|
+
Promise.resolve().then(async () => {
|
|
761
|
+
let canReplacePoisonedGeneration = false;
|
|
762
|
+
const startup = state.startPromise;
|
|
763
|
+
if (startup) try {
|
|
764
|
+
await waitForRetirementDrain(state, startup.catch(() => void 0), () => state.startPromise === startup, `Matrix client startup did not settle within ${MATRIX_RETIREMENT_DRAIN_TIMEOUT_MS}ms during retirement`);
|
|
765
|
+
} catch (error) {
|
|
766
|
+
state.poisonError = toRetirementError(error);
|
|
767
|
+
result.reject(state.poisonError);
|
|
768
|
+
await Promise.allSettled([
|
|
769
|
+
startup.catch(() => void 0).then(() => {
|
|
770
|
+
state.started = false;
|
|
771
|
+
state.client.stopWithoutPersist();
|
|
772
|
+
}),
|
|
773
|
+
retireMonitorLeases(state, params.monitorLeases ?? []),
|
|
774
|
+
state.noLeases.promise
|
|
775
|
+
]);
|
|
776
|
+
deleteSharedClientState(state);
|
|
777
|
+
throw state.poisonError;
|
|
778
|
+
}
|
|
779
|
+
try {
|
|
780
|
+
await state.client.quiesceSync();
|
|
781
|
+
state.started = false;
|
|
782
|
+
await state.client.drainPendingDecryptions("matrix monitor sync quiesce");
|
|
783
|
+
} catch (error) {
|
|
784
|
+
state.poisonError = toRetirementError(error);
|
|
785
|
+
canReplacePoisonedGeneration = true;
|
|
786
|
+
}
|
|
787
|
+
try {
|
|
788
|
+
await retireMonitorLeases(state, params.monitorLeases ?? []);
|
|
789
|
+
} catch (error) {
|
|
790
|
+
state.poisonError ??= toRetirementError(error);
|
|
791
|
+
canReplacePoisonedGeneration = false;
|
|
792
|
+
}
|
|
793
|
+
state.phase = "closing";
|
|
794
|
+
let lateLeaseDrain = null;
|
|
795
|
+
try {
|
|
796
|
+
await waitForRetirementDrain(state, state.noLeases.promise, () => state.leases.size > 0, `Matrix transient leases did not drain within ${MATRIX_RETIREMENT_DRAIN_TIMEOUT_MS}ms`);
|
|
797
|
+
} catch (error) {
|
|
798
|
+
state.poisonError ??= toRetirementError(error);
|
|
799
|
+
canReplacePoisonedGeneration = false;
|
|
800
|
+
result.reject(state.poisonError);
|
|
801
|
+
lateLeaseDrain = state.noLeases.promise;
|
|
802
|
+
}
|
|
803
|
+
if (state.poisonError) {
|
|
804
|
+
const decryptionsDrained = await state.client.drainPendingDecryptions("matrix poisoned client shutdown").then(() => true, () => false);
|
|
805
|
+
state.client.stopWithoutPersist();
|
|
806
|
+
await lateLeaseDrain;
|
|
807
|
+
if (lateLeaseDrain || canReplacePoisonedGeneration && decryptionsDrained) deleteSharedClientState(state);
|
|
808
|
+
throw state.poisonError;
|
|
809
|
+
}
|
|
810
|
+
try {
|
|
811
|
+
await state.client.drainPendingDecryptions("matrix shared client final shutdown");
|
|
812
|
+
} catch (error) {
|
|
813
|
+
state.poisonError = toRetirementError(error);
|
|
814
|
+
try {
|
|
815
|
+
state.client.stopWithoutPersist();
|
|
816
|
+
} finally {
|
|
817
|
+
deleteSharedClientState(state);
|
|
818
|
+
}
|
|
819
|
+
throw state.poisonError;
|
|
820
|
+
}
|
|
821
|
+
try {
|
|
822
|
+
if (state.releaseMode === "persist") await state.client.stopAndPersist();
|
|
823
|
+
else if (state.releaseMode === "discard") state.client.stopWithoutPersist();
|
|
824
|
+
else await state.client.stopAndPersist().catch(() => state.client.stopWithoutPersist());
|
|
825
|
+
} finally {
|
|
826
|
+
await lateLeaseDrain;
|
|
827
|
+
deleteSharedClientState(state);
|
|
828
|
+
}
|
|
829
|
+
}).then(result.resolve, result.reject);
|
|
830
|
+
abortTransientLeases(state);
|
|
831
|
+
return state.retirementPromise;
|
|
832
|
+
}
|
|
833
|
+
function createSharedMatrixClientLease(state, role) {
|
|
834
|
+
if (state.phase !== "open" || state.poisonError) return null;
|
|
835
|
+
const leaseState = {
|
|
836
|
+
abortController: new AbortController(),
|
|
837
|
+
monitorRetirement: null,
|
|
838
|
+
monitorRetirementPromise: null,
|
|
839
|
+
role,
|
|
840
|
+
releasePromise: null
|
|
841
|
+
};
|
|
842
|
+
state.leases.add(leaseState);
|
|
843
|
+
return {
|
|
844
|
+
abortSignal: leaseState.abortController.signal,
|
|
845
|
+
client: state.client,
|
|
846
|
+
role,
|
|
847
|
+
registerMonitorRetirement: (retirement) => {
|
|
848
|
+
if (role !== "monitor") throw new Error("Matrix transient leases cannot register monitor retirement");
|
|
849
|
+
if (leaseState.releasePromise || state.phase !== "open") throw new Error("Matrix monitor lease is already retiring");
|
|
850
|
+
if (leaseState.monitorRetirement && leaseState.monitorRetirement !== retirement) throw new Error("Matrix monitor retirement is already registered");
|
|
851
|
+
leaseState.monitorRetirement = retirement;
|
|
852
|
+
},
|
|
853
|
+
start: async (abortSignal) => {
|
|
854
|
+
if (leaseState.releasePromise) throw new Error("Matrix client lease has already been released");
|
|
855
|
+
if (state.phase !== "open") throw new Error("Matrix client generation is retiring");
|
|
856
|
+
await ensureSharedClientStarted(state, abortSignal ? AbortSignal.any([abortSignal, leaseState.abortController.signal]) : leaseState.abortController.signal);
|
|
857
|
+
},
|
|
858
|
+
release: (releaseParams = {}) => {
|
|
859
|
+
if (leaseState.releasePromise) return leaseState.releasePromise;
|
|
860
|
+
state.releaseMode = mergeReleaseMode(state.releaseMode, releaseParams.mode ?? "stop");
|
|
861
|
+
state.leases.delete(leaseState);
|
|
862
|
+
if (state.leases.size === 0) state.noLeases.resolve();
|
|
863
|
+
if (state.phase === "late-drain") {
|
|
864
|
+
leaseState.releasePromise = Promise.resolve();
|
|
865
|
+
return leaseState.releasePromise;
|
|
866
|
+
}
|
|
867
|
+
const finalMonitor = role === "monitor" && !Array.from(state.leases).some((lease) => lease.role === "monitor");
|
|
868
|
+
if (role === "monitor" && !finalMonitor) {
|
|
869
|
+
leaseState.releasePromise = retireMonitorLease(state, leaseState);
|
|
870
|
+
return leaseState.releasePromise;
|
|
871
|
+
}
|
|
872
|
+
if (!(state.phase === "open" && (finalMonitor || state.leases.size === 0))) {
|
|
873
|
+
leaseState.releasePromise = state.poisonError ? Promise.reject(state.poisonError) : Promise.resolve();
|
|
874
|
+
return leaseState.releasePromise;
|
|
875
|
+
}
|
|
876
|
+
leaseState.releasePromise = beginGenerationRetirement({
|
|
877
|
+
state,
|
|
878
|
+
monitorLeases: role === "monitor" ? [leaseState] : void 0
|
|
879
|
+
});
|
|
880
|
+
return leaseState.releasePromise;
|
|
881
|
+
}
|
|
882
|
+
};
|
|
633
883
|
}
|
|
634
884
|
async function acquireSharedMatrixClient(params = {}) {
|
|
635
|
-
const
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
if (!removeSharedClientInstance(client)) return;
|
|
659
|
-
client.stop();
|
|
660
|
-
}
|
|
661
|
-
async function releaseSharedClientInstance(client, mode = "stop") {
|
|
662
|
-
const state = findSharedClientStateByInstance(client);
|
|
663
|
-
if (!state) return false;
|
|
664
|
-
state.leases = Math.max(0, state.leases - 1);
|
|
665
|
-
if (state.leases > 0) return false;
|
|
666
|
-
deleteSharedClientState(state);
|
|
667
|
-
if (mode === "persist") await client.stopAndPersist();
|
|
668
|
-
else if (mode === "discard") client.stopWithoutPersist();
|
|
669
|
-
else client.stop();
|
|
670
|
-
return true;
|
|
885
|
+
const taskSignal = getMatrixMonitorTaskSignal();
|
|
886
|
+
const abortSignal = taskSignal && params.abortSignal ? AbortSignal.any([taskSignal, params.abortSignal]) : taskSignal ?? params.abortSignal;
|
|
887
|
+
const acquisition = {
|
|
888
|
+
...params,
|
|
889
|
+
abortSignal
|
|
890
|
+
};
|
|
891
|
+
while (true) {
|
|
892
|
+
throwIfMatrixStartupAborted(abortSignal);
|
|
893
|
+
const state = await resolveOpenSharedMatrixClientState(acquisition);
|
|
894
|
+
if (abortSignal?.aborted) {
|
|
895
|
+
if (state.phase === "open" && state.leases.size === 0) await beginGenerationRetirement({ state });
|
|
896
|
+
throwIfMatrixStartupAborted(abortSignal);
|
|
897
|
+
}
|
|
898
|
+
const lease = createSharedMatrixClientLease(state, params.role ?? "transient");
|
|
899
|
+
if (!lease) continue;
|
|
900
|
+
if (params.startClient !== false) try {
|
|
901
|
+
await lease.start(abortSignal);
|
|
902
|
+
} catch (error) {
|
|
903
|
+
await lease.release({ mode: "stop" }).catch(() => void 0);
|
|
904
|
+
throw error;
|
|
905
|
+
}
|
|
906
|
+
return lease;
|
|
907
|
+
}
|
|
671
908
|
}
|
|
672
909
|
//#endregion
|
|
673
|
-
|
|
910
|
+
//#region extensions/matrix/src/matrix/client.ts
|
|
911
|
+
var client_exports = /* @__PURE__ */ __exportAll({
|
|
912
|
+
acquireSharedMatrixClient: () => acquireSharedMatrixClient,
|
|
913
|
+
resolveMatrixAuthContext: () => resolveMatrixAuthContext
|
|
914
|
+
});
|
|
915
|
+
//#endregion
|
|
916
|
+
export { throwIfMatrixStartupAborted as a, backfillMatrixAuthDeviceIdAfterStartup as c, isMatrixStartupAbortError as i, resolveMatrixAuth as l, acquireSharedMatrixClient as n, createMatrixMonitorTaskRunner as o, createMatrixStartupAbortError as r, createMatrixClient as s, client_exports as t, resolveMatrixAuthContext as u };
|