@openclaw/matrix 2026.9.1-beta.1 → 2026.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/dist/{account-config-BZWN9tGS.js → account-config-CRsKoMqJ.js} +1 -1
  2. package/dist/{account-selection-CWuhuFn1.js → account-selection-DA-jfx22.js} +74 -36
  3. package/dist/{accounts-BCzyubQt.js → accounts-DR1c4xF_.js} +4 -5
  4. package/dist/api.js +5 -5
  5. package/dist/{approval-handler.runtime-G9fLHUWe.js → approval-handler.runtime-B_6ytY5I.js} +34 -11
  6. package/dist/{approval-ids-C6FD3pVY.js → approval-ids-CfHtZ9d1.js} +1 -1
  7. package/dist/{approval-reaction-auth-60xHiDtQ.js → approval-reaction-auth-BpDvJqfy.js} +2 -2
  8. package/dist/{approval-reactions-tXh9KYrW.js → approval-reactions-1fwEhoK9.js} +1 -1
  9. package/dist/{channel-CBEvelTE.js → channel-b-jES-oi.js} +63 -58
  10. package/dist/channel-plugin-api.js +1 -1
  11. package/dist/channel.runtime-BkqjwEDU.js +76 -0
  12. package/dist/{channel.setup-sWPOGyQG.js → channel.setup-BY42QaL7.js} +28 -21
  13. package/dist/{cli-DrTD2a_q.js → cli-CtYeU7ol.js} +42 -32
  14. package/dist/{cli-metadata-DrYVwQ_r.js → cli-metadata-B7MQjR5S.js} +1 -1
  15. package/dist/cli-metadata.js +1 -1
  16. package/dist/{client-BUtHbzib.js → client-D2utPQ1E.js} +2 -2
  17. package/dist/{client-hs1ePy2O.js → client-Dj4mcf-s.js} +73 -22
  18. package/dist/{client-bootstrap-BxdxjCwA.js → client-bootstrap-n1Rqc8Go.js} +1 -1
  19. package/dist/{config-update-Bor_Pjsv.js → config-update-BnX26jCO.js} +48 -31
  20. package/dist/contract-api.js +2 -2
  21. package/dist/{credentials-BdAaWuiR.js → credentials-DJj2xs3q.js} +4 -8
  22. package/dist/{credentials-read-B37cQknZ.js → credentials-read-mexhw-Ur.js} +7 -5
  23. package/dist/{credentials-write.runtime-nAV2-5uR.js → credentials-write.runtime-DQt-kgJq.js} +1 -1
  24. package/dist/{crypto-runtime-C4WDYxlP.js → crypto-runtime-m1eplj3b.js} +7 -7
  25. package/dist/crypto-snapshot-doctor.runtime-D0v841D_.js +91 -0
  26. package/dist/{deps-CcVJfvRM.js → deps-mtxF2mHI.js} +1 -1
  27. package/dist/{directory-live-D0KfJlby.js → directory-live-DLUgWBhA.js} +8 -6
  28. package/dist/{doctor-EWf9CDso.js → doctor-CJE8wO6y.js} +1 -1
  29. package/dist/{doctor-contract-DEt4O4Zt.js → doctor-contract-HyWFZQVG.js} +5 -4
  30. package/dist/doctor-contract-api.js +89 -109
  31. package/dist/{draft-stream-B_m79Ynb.js → draft-stream-DPYdv4fE.js} +1 -1
  32. package/dist/{encryption-guidance-DmLY8NiO.js → encryption-guidance-BNcZNQZI.js} +3 -2
  33. package/dist/helper-api.js +1 -1
  34. package/dist/{http-client-D8o8b9u6.js → http-client-DOmFvKvB.js} +10 -7
  35. package/dist/{idb-persistence-DfgW720p.js → idb-persistence-CU7CNLlX.js} +2 -2
  36. package/dist/{idb-persistence-lock-DAJ49nZX.js → idb-persistence-lock-B3fZXyF_.js} +1 -1
  37. package/dist/{inbound-dedupe-RvSLqdsz.js → inbound-dedupe-Ch33GU06.js} +1 -1
  38. package/dist/index.js +1 -1
  39. package/dist/{messages-Dow9EOoJ.js → messages-C1U3b1oN.js} +154 -5
  40. package/dist/{monitor-DBB47wTy.js → monitor-SNnu-0bp.js} +177 -130
  41. package/dist/outbound-CeCEtF_q.js +220 -0
  42. package/dist/plugin-entry.handlers.runtime.js +1 -1
  43. package/dist/probe.runtime-B1YPxG9x.js +2 -0
  44. package/dist/{profile-update-C61NR24_.js → profile-update-Cd1p8ABr.js} +5 -4
  45. package/dist/{profile-D-Wubo0A.js → profile-vmjsmhh4.js} +1 -1
  46. package/dist/{reaction-events-BZUgLIZI.js → reaction-events-DveJRUaX.js} +9 -7
  47. package/dist/{resolve-targets-DXzZwsIY.js → resolve-targets-B64O69Nd.js} +1 -1
  48. package/dist/{resolver.runtime-p5qJ3Kst.js → resolver.runtime-TRmePJDV.js} +1 -1
  49. package/dist/{room-info-BXQA7y10.js → room-info-DVkKDscD.js} +55 -1
  50. package/dist/runtime-api.js +2 -2
  51. package/dist/{sdk-CljOKEvc.js → sdk-C1yfda1L.js} +534 -26
  52. package/dist/{send-BKu9Ghi4.js → send-DG7Bnj7_.js} +26 -24
  53. package/dist/session-binding-contract-api.js +1 -1
  54. package/dist/{setup-bootstrap-CpE6C3qV.js → setup-bootstrap-Co985F63.js} +3 -3
  55. package/dist/{setup-core-CyvaCOOr.js → setup-core-CEF6exLW.js} +8 -7
  56. package/dist/setup-plugin-api.js +1 -1
  57. package/dist/{setup-surface-DtRvRcCT.js → setup-surface-BSlj1vnL.js} +84 -79
  58. package/dist/{startup-verification-Cs08ca8u.js → startup-verification-1Ney1mmI.js} +2 -2
  59. package/dist/{storage-BsGuHngK.js → storage-BVf4uucD.js} +5 -4
  60. package/dist/{subagent-hooks-CMoZaARG.js → subagent-hooks-DeICLbU5.js} +5 -1
  61. package/dist/subagent-hooks-api.js +1 -1
  62. package/dist/sync-cache-state-d-A_OhbU.js +234 -0
  63. package/dist/{thread-bindings-BvyU66kE.js → thread-bindings-DgxQEB99.js} +4 -4
  64. package/dist/{tool-actions.runtime-DD6jUxFK.js → tool-actions.runtime-vbkQgU7D.js} +226 -215
  65. package/dist/{verification-BP-3-XYn.js → verification-D-iOebn4.js} +2 -2
  66. package/node_modules/matrix-js-sdk/lib/client.d.ts +2 -1
  67. package/node_modules/matrix-js-sdk/lib/client.js +6 -2
  68. package/node_modules/matrix-js-sdk/lib/sync.js +8 -8
  69. package/node_modules/matrix-js-sdk/src/client.ts +7 -3
  70. package/node_modules/matrix-js-sdk/src/sync.ts +8 -8
  71. package/node_modules/typebox/build/format/email.mjs +1 -1
  72. package/node_modules/typebox/build/format/idna/idn-hostname.mjs +19 -1
  73. package/node_modules/typebox/package.json +1 -1
  74. package/openclaw.plugin.json +16 -1
  75. package/package.json +7 -6
  76. package/dist/channel.runtime-CiDl9deX.js +0 -276
  77. package/dist/env-auth-MVS-Vv41.js +0 -64
  78. package/dist/file-sync-store-DjskBX2o.js +0 -436
  79. package/dist/media-text-OR9uoC4W.js +0 -153
  80. package/dist/probe.runtime-CRM7RIrB.js +0 -2
  81. package/dist/recovery-key-store-CognuDys.js +0 -276
@@ -227,6 +227,7 @@ export let ClientEvent = /*#__PURE__*/function (ClientEvent) {
227
227
  * events received over context, search, or pagination APIs.
228
228
  *
229
229
  * The payload is the matrix event which caused this event to fire.
230
+ * The optional second argument is true when replaying a saved sync response.
230
231
  * @example
231
232
  * ```
232
233
  * matrixClient.on("event", function(event){
@@ -1093,8 +1094,11 @@ export class MatrixClient extends TypedEventEmitter {
1093
1094
  // attach the event listeners needed by RustCrypto
1094
1095
  this.on(RoomMemberEvent.Membership, rustCrypto.onRoomMembership.bind(rustCrypto));
1095
1096
  this.on(RoomStateEvent.Events, rustCrypto.onRoomStateEvent.bind(rustCrypto));
1096
- this.on(ClientEvent.Event, event => {
1097
- void rustCrypto.onLiveEventFromSync(event);
1097
+ this.on(ClientEvent.Event, (event, fromCache) => {
1098
+ // Restored room history must not restart completed verification requests.
1099
+ if (!fromCache) {
1100
+ void rustCrypto.onLiveEventFromSync(event);
1101
+ }
1098
1102
  });
1099
1103
 
1100
1104
  // re-emit the events emitted by the crypto impl
@@ -955,7 +955,7 @@ export class SyncApi {
955
955
  user.setPresenceEvent(presenceEvent);
956
956
  client.store.storeUser(user);
957
957
  }
958
- client.emit(ClientEvent.Event, presenceEvent);
958
+ client.emit(ClientEvent.Event, presenceEvent, syncEventData.fromCache);
959
959
  });
960
960
  }
961
961
 
@@ -1065,7 +1065,7 @@ export class SyncApi {
1065
1065
  room.recalculate();
1066
1066
  }
1067
1067
  stateEvents.forEach(function (e) {
1068
- client.emit(ClientEvent.Event, e);
1068
+ client.emit(ClientEvent.Event, e, syncEventData.fromCache);
1069
1069
  });
1070
1070
  }));
1071
1071
 
@@ -1243,7 +1243,7 @@ export class SyncApi {
1243
1243
  client.emit(ClientEvent.Room, room);
1244
1244
  }
1245
1245
  this.processEventsForNotifs(room, timelineEvents);
1246
- const emitEvent = e => client.emit(ClientEvent.Event, e);
1246
+ const emitEvent = e => client.emit(ClientEvent.Event, e, syncEventData.fromCache);
1247
1247
  // this fires a couple of times for some events. (eg state events are in the timeline and the state)
1248
1248
  // should this get a sync section as an additional event emission param (e, syncSection))?
1249
1249
  stateEvents.forEach(emitEvent);
@@ -1278,16 +1278,16 @@ export class SyncApi {
1278
1278
  }
1279
1279
  this.processEventsForNotifs(room, timelineEvents);
1280
1280
  stateEvents?.forEach(function (e) {
1281
- client.emit(ClientEvent.Event, e);
1281
+ client.emit(ClientEvent.Event, e, syncEventData.fromCache);
1282
1282
  });
1283
1283
  stateAfterEvents?.forEach(function (e) {
1284
- client.emit(ClientEvent.Event, e);
1284
+ client.emit(ClientEvent.Event, e, syncEventData.fromCache);
1285
1285
  });
1286
1286
  timelineEvents.forEach(function (e) {
1287
- client.emit(ClientEvent.Event, e);
1287
+ client.emit(ClientEvent.Event, e, syncEventData.fromCache);
1288
1288
  });
1289
1289
  accountDataEvents.forEach(function (e) {
1290
- client.emit(ClientEvent.Event, e);
1290
+ client.emit(ClientEvent.Event, e, syncEventData.fromCache);
1291
1291
  });
1292
1292
  }));
1293
1293
 
@@ -1305,7 +1305,7 @@ export class SyncApi {
1305
1305
  room.recalculate();
1306
1306
  }
1307
1307
  stateEvents.forEach(function (e) {
1308
- client.emit(ClientEvent.Event, e);
1308
+ client.emit(ClientEvent.Event, e, syncEventData.fromCache);
1309
1309
  });
1310
1310
  }));
1311
1311
 
@@ -1017,6 +1017,7 @@ export enum ClientEvent {
1017
1017
  * events received over context, search, or pagination APIs.
1018
1018
  *
1019
1019
  * The payload is the matrix event which caused this event to fire.
1020
+ * The optional second argument is true when replaying a saved sync response.
1020
1021
  * @example
1021
1022
  * ```
1022
1023
  * matrixClient.on("event", function(event){
@@ -1158,7 +1159,7 @@ export type EmittedEvents =
1158
1159
 
1159
1160
  export type ClientEventHandlerMap = {
1160
1161
  [ClientEvent.Sync]: (state: SyncState, prevState: SyncState | null, data?: ISyncStateData) => void;
1161
- [ClientEvent.Event]: (event: MatrixEvent) => void;
1162
+ [ClientEvent.Event]: (event: MatrixEvent, fromCache?: boolean) => void;
1162
1163
  [ClientEvent.ToDeviceEvent]: (event: MatrixEvent) => void;
1163
1164
  [ClientEvent.ReceivedToDeviceMessage]: (payload: ReceivedToDeviceMessage) => void;
1164
1165
  [ClientEvent.AccountData]: (event: MatrixEvent, lastEvent?: MatrixEvent) => void;
@@ -2049,8 +2050,11 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
2049
2050
  // attach the event listeners needed by RustCrypto
2050
2051
  this.on(RoomMemberEvent.Membership, rustCrypto.onRoomMembership.bind(rustCrypto));
2051
2052
  this.on(RoomStateEvent.Events, rustCrypto.onRoomStateEvent.bind(rustCrypto));
2052
- this.on(ClientEvent.Event, (event) => {
2053
- void rustCrypto.onLiveEventFromSync(event);
2053
+ this.on(ClientEvent.Event, (event, fromCache) => {
2054
+ // Restored room history must not restart completed verification requests.
2055
+ if (!fromCache) {
2056
+ void rustCrypto.onLiveEventFromSync(event);
2057
+ }
2054
2058
  });
2055
2059
 
2056
2060
  // re-emit the events emitted by the crypto impl
@@ -1131,7 +1131,7 @@ export class SyncApi {
1131
1131
  user.setPresenceEvent(presenceEvent);
1132
1132
  client.store.storeUser(user);
1133
1133
  }
1134
- client.emit(ClientEvent.Event, presenceEvent);
1134
+ client.emit(ClientEvent.Event, presenceEvent, syncEventData.fromCache);
1135
1135
  });
1136
1136
  }
1137
1137
 
@@ -1249,7 +1249,7 @@ export class SyncApi {
1249
1249
  room.recalculate();
1250
1250
  }
1251
1251
  stateEvents.forEach(function (e) {
1252
- client.emit(ClientEvent.Event, e);
1252
+ client.emit(ClientEvent.Event, e, syncEventData.fromCache);
1253
1253
  });
1254
1254
  }),
1255
1255
  );
@@ -1477,7 +1477,7 @@ export class SyncApi {
1477
1477
 
1478
1478
  this.processEventsForNotifs(room, timelineEvents);
1479
1479
 
1480
- const emitEvent = (e: MatrixEvent): boolean => client.emit(ClientEvent.Event, e);
1480
+ const emitEvent = (e: MatrixEvent): boolean => client.emit(ClientEvent.Event, e, syncEventData.fromCache);
1481
1481
  // this fires a couple of times for some events. (eg state events are in the timeline and the state)
1482
1482
  // should this get a sync section as an additional event emission param (e, syncSection))?
1483
1483
  stateEvents.forEach(emitEvent);
@@ -1518,16 +1518,16 @@ export class SyncApi {
1518
1518
  this.processEventsForNotifs(room, timelineEvents);
1519
1519
 
1520
1520
  stateEvents?.forEach(function (e) {
1521
- client.emit(ClientEvent.Event, e);
1521
+ client.emit(ClientEvent.Event, e, syncEventData.fromCache);
1522
1522
  });
1523
1523
  stateAfterEvents?.forEach(function (e) {
1524
- client.emit(ClientEvent.Event, e);
1524
+ client.emit(ClientEvent.Event, e, syncEventData.fromCache);
1525
1525
  });
1526
1526
  timelineEvents.forEach(function (e) {
1527
- client.emit(ClientEvent.Event, e);
1527
+ client.emit(ClientEvent.Event, e, syncEventData.fromCache);
1528
1528
  });
1529
1529
  accountDataEvents.forEach(function (e) {
1530
- client.emit(ClientEvent.Event, e);
1530
+ client.emit(ClientEvent.Event, e, syncEventData.fromCache);
1531
1531
  });
1532
1532
  }),
1533
1533
  );
@@ -1549,7 +1549,7 @@ export class SyncApi {
1549
1549
  room.recalculate();
1550
1550
  }
1551
1551
  stateEvents.forEach(function (e) {
1552
- client.emit(ClientEvent.Event, e);
1552
+ client.emit(ClientEvent.Event, e, syncEventData.fromCache);
1553
1553
  });
1554
1554
  }),
1555
1555
  );
@@ -1,4 +1,4 @@
1
- const Email = /^(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[^"\\]|\\.)*")@(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*|\[(?:IPv6:[a-f0-9:]+|(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])(?:\.(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])){3})\])$/i;
1
+ const Email = /^(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[^"\\]|\\[\x20-\x7e])*")@(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*|\[(?:IPv6:[a-f0-9:]+|(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])(?:\.(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])){3})\])$/i;
2
2
  /**
3
3
  * Returns true if the value is an Email
4
4
  * @specification https://datatracker.ietf.org/doc/html/rfc5322
@@ -1,6 +1,9 @@
1
1
  import * as FormatBidi from './format/bidi.mjs';
2
2
  import * as LabelUnicode from './label/unicode.mjs';
3
3
  import * as LabelPuny from './label/puny.mjs';
4
+ // ------------------------------------------------------------------
5
+ // IsLabel
6
+ // ------------------------------------------------------------------
4
7
  function IsValidLabelLength(value) {
5
8
  return value.length > 0 && value.length <= 63;
6
9
  }
@@ -8,9 +11,24 @@ function IsLabel(value) {
8
11
  return IsValidLabelLength(value) && (LabelPuny.IsPunyLabel(value) ||
9
12
  LabelUnicode.IsUnicodeLabel(value));
10
13
  }
14
+ // ------------------------------------------------------------------
15
+ // NormalizeHostname
16
+ //
17
+ // Normalizes a hostname for label validation. Normalizes for NFC
18
+ // such that equivalent codepoint sequences can be uniformly
19
+ // compared. It also removes codepoints that IDNA mapping ignores,
20
+ // and converts full stop variants to ASCII '.' so the hostname can
21
+ // be split into labels.
22
+ // ------------------------------------------------------------------
11
23
  function NormalizeHostname(value) {
12
- return value.normalize('NFC').replace(/[\u002E\u3002\uFF0E\uFF61]/g, '.');
24
+ return value
25
+ .normalize('NFC')
26
+ .replace(/[\u00ad\u034f\u180b-\u180d\u200b\ufe00-\ufe0f\u{e0100}-\u{e01ef}]/gu, '') // RE_IGNORED_MAPPING
27
+ .replace(/[\u002E\u3002\uFF0E\uFF61]/g, '.'); // RE_FULL_STOP_MAPPING
13
28
  }
29
+ // ------------------------------------------------------------------
30
+ // IsIdnHostname
31
+ // ------------------------------------------------------------------
14
32
  export function IsIdnHostname(value) {
15
33
  if (value.length === 0 || value.includes(' '))
16
34
  return false;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "typebox",
3
3
  "description": "Json Schema Type Builder with Static Type Resolution for TypeScript",
4
- "version": "1.3.16",
4
+ "version": "1.3.17",
5
5
  "keywords": [
6
6
  "typescript",
7
7
  "jsonschema"
@@ -48,6 +48,9 @@
48
48
  "configWrites": {
49
49
  "type": "boolean"
50
50
  },
51
+ "joinIntro": {
52
+ "type": "boolean"
53
+ },
51
54
  "defaultAccount": {
52
55
  "type": "string"
53
56
  },
@@ -56,7 +59,15 @@
56
59
  "propertyNames": {
57
60
  "type": "string"
58
61
  },
59
- "additionalProperties": {}
62
+ "additionalProperties": {
63
+ "type": "object",
64
+ "properties": {
65
+ "joinIntro": {
66
+ "type": "boolean"
67
+ }
68
+ },
69
+ "additionalProperties": {}
70
+ }
60
71
  },
61
72
  "markdown": {
62
73
  "type": "object",
@@ -957,6 +968,10 @@
957
968
  "label": "Matrix",
958
969
  "description": "open protocol; install the plugin to enable.",
959
970
  "uiHints": {
971
+ "joinIntro": {
972
+ "label": "Matrix Group Join Introduction",
973
+ "help": "Post one brief introduction when the bot joins an allowed group room (default: true). Account settings override the channel-wide setting."
974
+ },
960
975
  "mentionPatterns": {
961
976
  "label": "Matrix Mention Pattern Policy",
962
977
  "help": "Scopes configured groupChat mentionPatterns to selected Matrix room IDs. Native Matrix mention evidence still triggers even when regex patterns are denied."
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openclaw/matrix",
3
- "version": "2026.9.1-beta.1",
3
+ "version": "2026.9.1",
4
4
  "description": "OpenClaw Matrix channel plugin for rooms and direct messages.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -14,11 +14,11 @@
14
14
  "markdown-it": "15.0.0",
15
15
  "matrix-js-sdk": "42.2.0",
16
16
  "music-metadata": "11.15.0",
17
- "typebox": "1.3.16",
17
+ "typebox": "1.3.17",
18
18
  "zod": "4.4.3"
19
19
  },
20
20
  "peerDependencies": {
21
- "openclaw": ">=2026.9.1-beta.1"
21
+ "openclaw": ">=2026.9.1"
22
22
  },
23
23
  "peerDependenciesMeta": {
24
24
  "openclaw": {
@@ -162,15 +162,16 @@
162
162
  "install": {
163
163
  "clawhubSpec": "clawhub:@openclaw/matrix",
164
164
  "npmSpec": "@openclaw/matrix",
165
- "defaultChoice": "clawhub",
165
+ "defaultChoice": "npm",
166
166
  "minHostVersion": ">=2026.4.10",
167
167
  "allowInvalidConfigRecovery": true
168
168
  },
169
169
  "compat": {
170
- "pluginApi": ">=2026.9.1-beta.1"
170
+ "pluginApi": ">=2026.9.1"
171
171
  },
172
172
  "build": {
173
- "openclawVersion": "2026.9.1-beta.1"
173
+ "bundledDist": false,
174
+ "openclawVersion": "2026.9.1"
174
175
  },
175
176
  "release": {
176
177
  "publishToClawHub": true,
@@ -1,276 +0,0 @@
1
- import { b as reconcileMatrixUnknownSend, i as sendPollMatrix, o as sendTypingMatrix, r as sendMessageMatrix, y as cleanupMatrixDeliveryPlans } from "./send-BKu9Ghi4.js";
2
- import { t as isBunRuntime } from "./runtime-BefyhPWv.js";
3
- import { c as resolveMatrixAuth } from "./client-hs1ePy2O.js";
4
- import { n as listMatrixDirectoryGroupsLive, r as listMatrixDirectoryPeersLive } from "./directory-live-D0KfJlby.js";
5
- import { t as resolveMatrixTargets } from "./resolve-targets-DXzZwsIY.js";
6
- import { createLazyRuntimeModule } from "openclaw/plugin-sdk/lazy-runtime";
7
- import { createMessageReceiptFromOutboundResults, createReplyToFanout, resolveOutboundSendDep } from "openclaw/plugin-sdk/channel-outbound";
8
- import { asOptionalRecord, normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
9
- import { chunkTextForOutbound } from "openclaw/plugin-sdk/text-chunking";
10
- import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
11
- import { runChannelProbe } from "openclaw/plugin-sdk/text-utility-runtime";
12
- import { attachChannelToResult } from "openclaw/plugin-sdk/channel-send-result";
13
- import { renderMessagePresentationFallbackText } from "openclaw/plugin-sdk/interactive-runtime";
14
- import { resolveSendableOutboundReplyParts, sendPayloadMediaSequence } from "openclaw/plugin-sdk/reply-payload";
15
- //#region extensions/matrix/src/matrix/probe.ts
16
- const loadMatrixProbeRuntimeDeps = createLazyRuntimeModule(() => import("./probe.runtime-CRM7RIrB.js").then((runtimeModule) => ({ createMatrixClient: runtimeModule.createMatrixClient })));
17
- async function probeMatrix(params) {
18
- return await runChannelProbe(void 0, async () => {
19
- const result = {
20
- ok: false,
21
- status: null,
22
- error: null
23
- };
24
- if (isBunRuntime()) return {
25
- ...result,
26
- error: "Matrix probe requires Node (bun runtime not supported)"
27
- };
28
- if (!params.homeserver?.trim()) return {
29
- ...result,
30
- error: "missing homeserver"
31
- };
32
- if (!params.accessToken?.trim()) return {
33
- ...result,
34
- error: "missing access token"
35
- };
36
- const { createMatrixClient } = await loadMatrixProbeRuntimeDeps();
37
- const inputUserId = normalizeOptionalString(params.userId);
38
- const userId = await (await createMatrixClient({
39
- homeserver: params.homeserver,
40
- userId: void 0,
41
- accessToken: params.accessToken,
42
- deviceId: params.deviceId,
43
- persistStorage: false,
44
- localTimeoutMs: params.timeoutMs,
45
- accountId: params.accountId,
46
- allowPrivateNetwork: params.allowPrivateNetwork,
47
- ssrfPolicy: params.ssrfPolicy,
48
- dispatcherPolicy: params.dispatcherPolicy
49
- })).getUserId();
50
- if (inputUserId && inputUserId !== userId) return {
51
- ...result,
52
- error: "Matrix access token user does not match configured userId"
53
- };
54
- return {
55
- ...result,
56
- ok: true,
57
- userId
58
- };
59
- }, (error) => ({
60
- ok: false,
61
- status: typeof error === "object" && error && "statusCode" in error ? Number(error.statusCode) : null,
62
- error: formatErrorMessage(error)
63
- }));
64
- }
65
- //#endregion
66
- //#region extensions/matrix/src/outbound.ts
67
- const MATRIX_OPENCLAW_PRESENTATION_KEY = "com.openclaw.presentation";
68
- const MATRIX_OPENCLAW_PRESENTATION_TYPE = "message.presentation";
69
- const MATRIX_EMPTY_PRESENTATION_FALLBACK_TEXT = "---";
70
- function toMatrixOutboundResult(result) {
71
- const { roomId, ...delivery } = result;
72
- return {
73
- ...delivery,
74
- target: {
75
- kind: "room",
76
- id: roomId
77
- }
78
- };
79
- }
80
- function resolveMatrixChannelData(payload) {
81
- const raw = asOptionalRecord(payload.channelData)?.matrix;
82
- return asOptionalRecord(raw) ?? {};
83
- }
84
- function buildMatrixPresentationContent(presentation) {
85
- return {
86
- ...presentation,
87
- version: 1,
88
- type: MATRIX_OPENCLAW_PRESENTATION_TYPE
89
- };
90
- }
91
- function resolveMatrixPresentationContent(payload) {
92
- const presentation = asOptionalRecord(asOptionalRecord(resolveMatrixChannelData(payload).extraContent)?.[MATRIX_OPENCLAW_PRESENTATION_KEY]);
93
- if (!presentation || presentation.version !== 1 || presentation.type !== MATRIX_OPENCLAW_PRESENTATION_TYPE) return;
94
- return presentation;
95
- }
96
- function renderMatrixPresentationPayload(params) {
97
- const matrixData = resolveMatrixChannelData(params.payload);
98
- const fallbackText = renderMessagePresentationFallbackText({
99
- text: params.payload.text,
100
- presentation: params.presentation,
101
- emptyFallback: MATRIX_EMPTY_PRESENTATION_FALLBACK_TEXT
102
- });
103
- return {
104
- ...params.payload,
105
- text: fallbackText,
106
- channelData: {
107
- ...params.payload.channelData,
108
- matrix: {
109
- ...matrixData,
110
- extraContent: { [MATRIX_OPENCLAW_PRESENTATION_KEY]: buildMatrixPresentationContent(params.presentation) }
111
- }
112
- }
113
- };
114
- }
115
- function resolveMatrixPayloadText(payload) {
116
- const text = payload.text ?? "";
117
- if (text.trim() || !resolveMatrixPresentationContent(payload)) return text;
118
- return MATRIX_EMPTY_PRESENTATION_FALLBACK_TEXT;
119
- }
120
- function resolveMatrixExtraContent(payload) {
121
- const presentation = resolveMatrixPresentationContent(payload);
122
- return presentation ? { [MATRIX_OPENCLAW_PRESENTATION_KEY]: presentation } : void 0;
123
- }
124
- function resolveMatrixDeliveryProgress(onDeliveryResult) {
125
- return onDeliveryResult ? async (result) => {
126
- await onDeliveryResult(attachChannelToResult("matrix", toMatrixOutboundResult(result)));
127
- } : void 0;
128
- }
129
- //#endregion
130
- //#region extensions/matrix/src/channel.runtime.ts
131
- const matrixChannelRuntime = {
132
- cleanupMatrixDeliveryPlans,
133
- listMatrixDirectoryGroupsLive,
134
- listMatrixDirectoryPeersLive,
135
- matrixOutbound: {
136
- deliveryMode: "direct",
137
- chunker: chunkTextForOutbound,
138
- chunkerMode: "markdown",
139
- textChunkLimit: 4e3,
140
- presentationCapabilities: {
141
- supported: true,
142
- buttons: true,
143
- selects: true,
144
- context: true,
145
- divider: true,
146
- limits: { text: {
147
- markdownDialect: "markdown",
148
- supportsEdit: true
149
- } }
150
- },
151
- renderPresentation: ({ payload, presentation }) => renderMatrixPresentationPayload({
152
- payload,
153
- presentation
154
- }),
155
- sendPayload: async ({ cfg, to, payload, mediaLocalRoots, mediaReadFile, mediaAccess, deps, replyToId, replyToIdSource, replyToMode, threadId, accountId, audioAsVoice, deliveryQueueId, onPlatformSendDispatch, onDeliveryResult }) => {
156
- const send = resolveOutboundSendDep(deps, "matrix") ?? sendMessageMatrix;
157
- const resolvedThreadId = threadId !== void 0 && threadId !== null ? String(threadId) : void 0;
158
- const resolveReplyToId = createReplyToFanout({
159
- ...replyToId != null ? { replyToId } : {},
160
- ...replyToIdSource !== void 0 ? { replyToIdSource } : {},
161
- ...replyToMode !== void 0 ? { replyToMode } : {}
162
- });
163
- const urls = resolveSendableOutboundReplyParts(payload).mediaUrls;
164
- const payloadText = resolveMatrixPayloadText(payload);
165
- if (urls.length > 0) {
166
- const sentResults = [];
167
- const lastResult = await sendPayloadMediaSequence({
168
- text: payloadText,
169
- mediaUrls: urls,
170
- send: async ({ text, mediaUrl, index, isFirst }) => await send(to, text, {
171
- cfg,
172
- mediaUrl,
173
- mediaAccess,
174
- mediaLocalRoots,
175
- mediaReadFile,
176
- replyToId: resolveReplyToId(),
177
- threadId: resolvedThreadId,
178
- accountId: accountId ?? void 0,
179
- audioAsVoice: payload.audioAsVoice ?? audioAsVoice,
180
- deliveryQueueId,
181
- deliveryPartIndex: index,
182
- deliveryPartCount: urls.length,
183
- onPlatformSendDispatch,
184
- extraContent: isFirst ? resolveMatrixExtraContent(payload) : void 0,
185
- onDeliveryResult: resolveMatrixDeliveryProgress(onDeliveryResult)
186
- }),
187
- onResult: (result) => {
188
- sentResults.push(result);
189
- }
190
- });
191
- if (lastResult !== void 0) {
192
- const receipt = createMessageReceiptFromOutboundResults({ results: sentResults });
193
- receipt.parts = receipt.parts.map((part, index) => ({
194
- ...part,
195
- index
196
- }));
197
- return attachChannelToResult("matrix", toMatrixOutboundResult({
198
- ...lastResult,
199
- primaryMessageId: receipt.primaryPlatformMessageId,
200
- receipt,
201
- content: sentResults.map((result) => result.content).join("\n")
202
- }));
203
- }
204
- }
205
- return attachChannelToResult("matrix", toMatrixOutboundResult(await send(to, payloadText, {
206
- cfg,
207
- mediaAccess,
208
- mediaLocalRoots,
209
- mediaReadFile,
210
- replyToId: resolveReplyToId(),
211
- threadId: resolvedThreadId,
212
- accountId: accountId ?? void 0,
213
- audioAsVoice: payload.audioAsVoice ?? audioAsVoice,
214
- deliveryQueueId,
215
- deliveryPartIndex: 0,
216
- deliveryPartCount: 1,
217
- onPlatformSendDispatch,
218
- extraContent: resolveMatrixExtraContent(payload),
219
- onDeliveryResult: resolveMatrixDeliveryProgress(onDeliveryResult)
220
- })));
221
- },
222
- sendText: async ({ cfg, to, text, deps, replyToId, threadId, accountId, audioAsVoice, deliveryQueueId, deliveryPartIndex, deliveryPartCount, onPlatformSendDispatch, onDeliveryResult }) => {
223
- return attachChannelToResult("matrix", toMatrixOutboundResult(await (resolveOutboundSendDep(deps, "matrix") ?? sendMessageMatrix)(to, text, {
224
- cfg,
225
- replyToId: replyToId ?? void 0,
226
- threadId: threadId !== void 0 && threadId !== null ? String(threadId) : void 0,
227
- accountId: accountId ?? void 0,
228
- audioAsVoice,
229
- deliveryQueueId,
230
- deliveryPartIndex,
231
- ...deliveryQueueId !== void 0 ? { deliveryPartCount } : {},
232
- onPlatformSendDispatch,
233
- onDeliveryResult: resolveMatrixDeliveryProgress(onDeliveryResult)
234
- })));
235
- },
236
- sendMedia: async ({ cfg, to, text, mediaUrl, mediaLocalRoots, mediaReadFile, mediaAccess, deps, replyToId, threadId, accountId, audioAsVoice, deliveryQueueId, deliveryPartIndex, deliveryPartCount, onPlatformSendDispatch, onDeliveryResult }) => {
237
- return attachChannelToResult("matrix", toMatrixOutboundResult(await (resolveOutboundSendDep(deps, "matrix") ?? sendMessageMatrix)(to, text, {
238
- cfg,
239
- mediaUrl,
240
- mediaLocalRoots,
241
- mediaReadFile,
242
- mediaAccess,
243
- replyToId: replyToId ?? void 0,
244
- threadId: threadId !== void 0 && threadId !== null ? String(threadId) : void 0,
245
- accountId: accountId ?? void 0,
246
- audioAsVoice,
247
- deliveryQueueId,
248
- deliveryPartIndex,
249
- ...deliveryQueueId !== void 0 ? { deliveryPartCount } : {},
250
- onPlatformSendDispatch,
251
- onDeliveryResult: resolveMatrixDeliveryProgress(onDeliveryResult)
252
- })));
253
- },
254
- sendPoll: async ({ cfg, to, poll, threadId, accountId }) => {
255
- const result = await sendPollMatrix(to, poll, {
256
- cfg,
257
- threadId: threadId !== void 0 && threadId !== null ? threadId : void 0,
258
- accountId: accountId ?? void 0
259
- });
260
- return {
261
- channel: "matrix",
262
- messageId: result.eventId,
263
- roomId: result.roomId,
264
- pollId: result.eventId
265
- };
266
- }
267
- },
268
- probeMatrix,
269
- resolveMatrixAuth,
270
- resolveMatrixTargets,
271
- reconcileMatrixUnknownSend,
272
- sendMessageMatrix,
273
- sendTypingMatrix
274
- };
275
- //#endregion
276
- export { matrixChannelRuntime };
@@ -1,64 +0,0 @@
1
- import { t as getMatrixScopedEnvVarNames } from "./env-vars-dGqak9dN.js";
2
- import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
3
- import { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "openclaw/plugin-sdk/account-id";
4
- //#region extensions/matrix/src/matrix/client/env-auth.ts
5
- function cleanEnv(value) {
6
- return normalizeOptionalString(value) ?? "";
7
- }
8
- function resolveGlobalMatrixEnvConfig(env) {
9
- return {
10
- homeserver: cleanEnv(env.MATRIX_HOMESERVER),
11
- userId: cleanEnv(env.MATRIX_USER_ID),
12
- accessToken: cleanEnv(env.MATRIX_ACCESS_TOKEN) || void 0,
13
- password: cleanEnv(env.MATRIX_PASSWORD) || void 0,
14
- deviceId: cleanEnv(env.MATRIX_DEVICE_ID) || void 0,
15
- deviceName: cleanEnv(env.MATRIX_DEVICE_NAME) || void 0
16
- };
17
- }
18
- function hasReadyMatrixEnvAuth(config) {
19
- const homeserver = cleanEnv(config.homeserver);
20
- const userId = cleanEnv(config.userId);
21
- const accessToken = cleanEnv(config.accessToken);
22
- const password = cleanEnv(config.password);
23
- return Boolean(homeserver && (accessToken || userId && password));
24
- }
25
- function resolveScopedMatrixEnvConfig(accountId, env = process.env) {
26
- const keys = getMatrixScopedEnvVarNames(accountId);
27
- return {
28
- homeserver: cleanEnv(env[keys.homeserver]),
29
- userId: cleanEnv(env[keys.userId]),
30
- accessToken: cleanEnv(env[keys.accessToken]) || void 0,
31
- password: cleanEnv(env[keys.password]) || void 0,
32
- deviceId: cleanEnv(env[keys.deviceId]) || void 0,
33
- deviceName: cleanEnv(env[keys.deviceName]) || void 0
34
- };
35
- }
36
- function resolveMatrixEnvAuthReadiness(accountId, env = process.env) {
37
- const normalizedAccountId = normalizeAccountId(accountId);
38
- const scoped = resolveScopedMatrixEnvConfig(normalizedAccountId, env);
39
- const scopedReady = hasReadyMatrixEnvAuth(scoped);
40
- if (normalizedAccountId !== DEFAULT_ACCOUNT_ID) {
41
- const keys = getMatrixScopedEnvVarNames(normalizedAccountId);
42
- return {
43
- ready: scopedReady,
44
- homeserver: scoped.homeserver || void 0,
45
- userId: scoped.userId || void 0,
46
- sourceHint: `${keys.homeserver} (+ auth vars)`,
47
- missingMessage: `Set per-account env vars for "${normalizedAccountId}" (for example ${keys.homeserver} + ${keys.accessToken} or ${keys.userId} + ${keys.password}).`
48
- };
49
- }
50
- const defaultScoped = resolveScopedMatrixEnvConfig(DEFAULT_ACCOUNT_ID, env);
51
- const global = resolveGlobalMatrixEnvConfig(env);
52
- const defaultScopedReady = hasReadyMatrixEnvAuth(defaultScoped);
53
- const globalReady = hasReadyMatrixEnvAuth(global);
54
- const defaultKeys = getMatrixScopedEnvVarNames(DEFAULT_ACCOUNT_ID);
55
- return {
56
- ready: defaultScopedReady || globalReady,
57
- homeserver: defaultScoped.homeserver || global.homeserver || void 0,
58
- userId: defaultScoped.userId || global.userId || void 0,
59
- sourceHint: "MATRIX_* or MATRIX_DEFAULT_*",
60
- missingMessage: `Set Matrix env vars for the default account (for example MATRIX_HOMESERVER + MATRIX_ACCESS_TOKEN, MATRIX_USER_ID + MATRIX_PASSWORD, or ${defaultKeys.homeserver} + ${defaultKeys.accessToken}).`
61
- };
62
- }
63
- //#endregion
64
- export { resolveMatrixEnvAuthReadiness as n, resolveScopedMatrixEnvConfig as r, resolveGlobalMatrixEnvConfig as t };