@openclaw/matrix 2026.7.1-beta.6 → 2026.7.2-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/dist/{account-selection-5e4mHR1m.js → account-selection-Bz00QTmQ.js} +4 -3
  2. package/dist/api.js +8 -8
  3. package/dist/{approval-handler.runtime-DI5x9r8I.js → approval-handler.runtime--Ei44Vo2.js} +27 -17
  4. package/dist/{approval-ids-ZgqbspmS.js → approval-ids-C_2kSMdJ.js} +1 -1
  5. package/dist/{approval-reaction-auth-D9LijQhr.js → approval-reaction-auth-TdVPcgxP.js} +2 -2
  6. package/dist/approval-reactions-BgU51JGd.js +202 -0
  7. package/dist/auth-presence.js +1 -1
  8. package/dist/{channel-jUTBsjHU.js → channel-CxqDh7mS.js} +102 -143
  9. package/dist/channel-plugin-api.js +1 -1
  10. package/dist/{channel.runtime-DO1Nv9ed.js → channel.runtime-wNfJc57I.js} +7 -7
  11. package/dist/{cli-metadata-CfiEO-CE.js → cli-metadata-Gf3HSJ2c.js} +1 -1
  12. package/dist/cli-metadata.js +1 -1
  13. package/dist/{cli-CEfWwCKx.js → cli-o00oTJhx.js} +12 -12
  14. package/dist/{client-FRuyCNju.js → client-ClHisZbf.js} +2 -2
  15. package/dist/{client-tgnlQJk4.js → client-DP0nmFxK.js} +4 -4
  16. package/dist/{client-bootstrap-DjFJ7e0N.js → client-bootstrap-PqYOS-mO.js} +1 -1
  17. package/dist/{config-schema-DtnhNYd-.js → config-schema-CG9goLWp.js} +21 -55
  18. package/dist/contract-api.js +2 -2
  19. package/dist/{create-client-CNakT7zF.js → create-client-D9z9RjCM.js} +3 -3
  20. package/dist/{credentials-Ds9V1mn2.js → credentials-DnhsLAuR.js} +1 -1
  21. package/dist/{credentials-read-BlkvsNFg.js → credentials-read-BtS-HRT5.js} +3 -3
  22. package/dist/{credentials-write.runtime-CTqqxcut.js → credentials-write.runtime-J_EUt5WP.js} +1 -1
  23. package/dist/{crypto-runtime-B74cTS6A.js → crypto-runtime-BHcxauC4.js} +75 -45
  24. package/dist/{deps-CdjHvnmh.js → deps-DDbghaZH.js} +23 -90
  25. package/dist/{directory-live-Ufd4qSpX.js → directory-live-DPy2aaPF.js} +3 -3
  26. package/dist/doctor-BGTs609f.js +64 -0
  27. package/dist/{doctor-contract-BAja_fmb.js → doctor-contract-D2qTLe-C.js} +72 -6
  28. package/dist/doctor-contract-api.js +323 -45
  29. package/dist/{draft-stream-D4EH25gv.js → draft-stream-De7uikGn.js} +1 -1
  30. package/dist/{encryption-guidance-D8walY04.js → encryption-guidance-BFfgq7c7.js} +1 -1
  31. package/dist/{env-auth-DIzOApj0.js → env-auth-CQsYbz-p.js} +1 -1
  32. package/dist/{env-vars-KzaYveuy.js → env-vars-B0NxQnPk.js} +3 -1
  33. package/dist/{exec-approval-resolver-f9j6staN.js → exec-approval-resolver-BCgqRtZS.js} +2 -1
  34. package/dist/{file-sync-store-DVm0ACml.js → file-sync-store-Cxb0ckyX.js} +4 -5
  35. package/dist/helper-api.js +4 -4
  36. package/dist/{http-client-nSmFiVgk.js → http-client-W4TJQM6r.js} +17 -33
  37. package/dist/{idb-persistence-BHm97th-.js → idb-persistence-iUZoHZkp.js} +2 -2
  38. package/dist/inbound-dedupe-DcMs0YXL.js +67 -0
  39. package/dist/index.js +1 -1
  40. package/dist/{logger-D0GCSDQq.js → logger-BMClpI5b.js} +1 -1
  41. package/dist/{logging-QH-48Gr6.js → logging-CFJrbDAN.js} +1 -1
  42. package/dist/{media-text-p-LP21qs.js → media-text-DWaotsZB.js} +1 -1
  43. package/dist/{messages-DRKkiEY-.js → messages-Dm3K4ZvM.js} +3 -3
  44. package/dist/{monitor-CsGOGdwu.js → monitor-C_kgPPeV.js} +44 -382
  45. package/dist/plugin-entry.handlers.runtime.js +1 -1
  46. package/dist/probe.runtime-Dry8PTWC.js +3 -0
  47. package/dist/{profile-update-Ucc8RrJL.js → profile-update-iUHCoks3.js} +3 -3
  48. package/dist/{reaction-events-DentrVii.js → reaction-events-0tubdHRM.js} +60 -10
  49. package/dist/record-shared-CvzjvHRn.js +2 -0
  50. package/dist/{recovery-key-store-DSeLFvNx.js → recovery-key-store-Bx0zTJcB.js} +2 -2
  51. package/dist/{resolve-targets-DcV_KfgX.js → resolve-targets-DlLrfWDy.js} +1 -1
  52. package/dist/{resolver.runtime-Hr6bO5zl.js → resolver.runtime-MeaT1zXx.js} +1 -1
  53. package/dist/room-info-B6vKD5DF.js +86 -0
  54. package/dist/{runtime-6S3DNFNv.js → runtime-CveSqMOP.js} +1 -1
  55. package/dist/{runtime-api-CsBoesCU.js → runtime-api-D1xI_cvh.js} +3 -3
  56. package/dist/runtime-api.js +6 -6
  57. package/dist/runtime-setter-api.js +1 -1
  58. package/dist/{sdk-AZYVl34z.js → sdk-CI8E2TKg.js} +12 -17
  59. package/dist/{secret-contract-DTgQyQxc.js → secret-contract-OZoQf0kI.js} +7 -48
  60. package/dist/secret-contract-api.js +1 -1
  61. package/dist/{send-D92v6Yy0.js → send-C7xuGWpv.js} +10 -4
  62. package/dist/session-binding-contract-api.js +2 -2
  63. package/dist/{setup-bootstrap-Da564w5f.js → setup-bootstrap-CCsexWTZ.js} +2 -2
  64. package/dist/{setup-core-BGgbrdaJ.js → setup-core-DlmTyIP0.js} +9 -7
  65. package/dist/setup-plugin-api.js +3 -3
  66. package/dist/{setup-surface-iJ6pd-t5.js → setup-surface-2SS94JV0.js} +7 -7
  67. package/dist/{shared-DkFfq7mH.js → shared-DgvN5rBx.js} +14 -9
  68. package/dist/{startup-verification-BKMAXvcV.js → startup-verification-CbIyF7z1.js} +3 -4
  69. package/dist/storage-BtSOar8T.js +718 -0
  70. package/dist/{storage-paths-BWo_ZEMC.js → storage-paths-B4_I9iqO.js} +1 -12
  71. package/dist/{thread-bindings-BX5nmWpw.js → thread-bindings-BI8MHWp9.js} +4 -5
  72. package/dist/{tool-actions.runtime-C1d5fxE_.js → tool-actions.runtime-CnyhVPoY.js} +242 -53
  73. package/dist/{verification-BGCMiO1p.js → verification-DLSe3sP7.js} +2 -2
  74. package/npm-shrinkwrap.json +3 -3
  75. package/openclaw.plugin.json +66 -55
  76. package/package.json +4 -4
  77. package/dist/approval-reactions-BdUaUXVw.js +0 -113
  78. package/dist/crypto-state-store-Jy3qwhdy.js +0 -352
  79. package/dist/doctor-DfaOqFtr.js +0 -167
  80. package/dist/legacy-crypto-inspector-vzXSkm18.js +0 -42
  81. package/dist/legacy-crypto-restore-CIBfOmLn.js +0 -93
  82. package/dist/matrix-migration.runtime-BMCyrANT.js +0 -524
  83. package/dist/migration-snapshot-backup-YcCrSjbE.js +0 -69
  84. package/dist/migration-snapshot.runtime-VGD4QfeS.js +0 -2
  85. package/dist/probe.runtime-2MZLc6ng.js +0 -3
  86. package/dist/runtime-heavy-api.js +0 -3
  87. package/dist/storage-CQdyKcGg.js +0 -430
@@ -1,5 +1,6 @@
1
- import { n as listMatrixEnvAccountIds, t as getMatrixScopedEnvVarNames } from "./env-vars-KzaYveuy.js";
2
- import { isRecord, normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
1
+ import { n as listMatrixEnvAccountIds, t as getMatrixScopedEnvVarNames } from "./env-vars-B0NxQnPk.js";
2
+ import { t as isRecord } from "./record-shared-CvzjvHRn.js";
3
+ import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
3
4
  import { listCombinedAccountIds, listConfiguredAccountIds, resolveListedDefaultAccountId, resolveNormalizedAccountEntry } from "openclaw/plugin-sdk/account-core";
4
5
  import { DEFAULT_ACCOUNT_ID, normalizeAccountId, normalizeOptionalAccountId } from "openclaw/plugin-sdk/account-id";
5
6
  import { hasConfiguredSecretInput } from "openclaw/plugin-sdk/secret-input-runtime";
@@ -154,4 +155,4 @@ function requiresExplicitMatrixDefaultAccount(cfg, env = process.env) {
154
155
  return !(configuredDefault && configuredAccountIds.includes(configuredDefault));
155
156
  }
156
157
  //#endregion
157
- export { resolveMatrixDefaultOrOnlyAccountId as a, resolveMatrixChannelConfig as i, requiresExplicitMatrixDefaultAccount as n, isRecord as o, resolveConfiguredMatrixAccountIds as r, resolveMatrixAccountStringValues as s, findMatrixAccountEntry as t };
158
+ export { resolveMatrixDefaultOrOnlyAccountId as a, resolveMatrixChannelConfig as i, requiresExplicitMatrixDefaultAccount as n, resolveMatrixAccountStringValues as o, resolveConfiguredMatrixAccountIds as r, findMatrixAccountEntry as t };
package/dist/api.js CHANGED
@@ -1,12 +1,12 @@
1
- import { a as resolveMatrixDefaultOrOnlyAccountId, i as resolveMatrixChannelConfig, n as requiresExplicitMatrixDefaultAccount, r as resolveConfiguredMatrixAccountIds, t as findMatrixAccountEntry } from "./account-selection-5e4mHR1m.js";
2
- import { n as listMatrixEnvAccountIds, r as resolveMatrixEnvAccountToken, t as getMatrixScopedEnvVarNames } from "./env-vars-KzaYveuy.js";
3
- import { a as resolveMatrixCredentialsPath, c as resolveMatrixLegacyFlatStoreRoot, i as resolveMatrixCredentialsFilename, l as sanitizeMatrixPathSegment, n as resolveMatrixAccountStorageRoot, o as resolveMatrixHomeserverKey, r as resolveMatrixCredentialsDir, s as resolveMatrixLegacyFlatStoragePaths, t as hashMatrixAccessToken } from "./storage-paths-BWo_ZEMC.js";
4
- import { n as matrixSetupAdapter, t as createMatrixSetupWizardProxy } from "./setup-core-BGgbrdaJ.js";
5
- import { t as matrixPlugin } from "./channel-jUTBsjHU.js";
1
+ import { a as resolveMatrixDefaultOrOnlyAccountId, i as resolveMatrixChannelConfig, n as requiresExplicitMatrixDefaultAccount, r as resolveConfiguredMatrixAccountIds, t as findMatrixAccountEntry } from "./account-selection-Bz00QTmQ.js";
2
+ import { n as listMatrixEnvAccountIds, r as resolveMatrixEnvAccountToken, t as getMatrixScopedEnvVarNames } from "./env-vars-B0NxQnPk.js";
3
+ import { a as resolveMatrixCredentialsPath, i as resolveMatrixCredentialsFilename, n as resolveMatrixAccountStorageRoot, o as resolveMatrixHomeserverKey, r as resolveMatrixCredentialsDir, s as sanitizeMatrixPathSegment, t as hashMatrixAccessToken } from "./storage-paths-B4_I9iqO.js";
4
+ import { n as matrixSetupAdapter, t as createMatrixSetupWizardProxy } from "./setup-core-DlmTyIP0.js";
5
+ import { t as matrixPlugin } from "./channel-CxqDh7mS.js";
6
6
  import { d as setMatrixThreadBindingIdleTimeoutBySessionKey, n as getMatrixThreadBindingManager, p as setMatrixThreadBindingMaxAgeBySessionKey, s as resetMatrixThreadBindingsForTests } from "./thread-bindings-shared-CKnY4LSd.js";
7
- import { n as matrixOnboardingAdapter } from "./setup-surface-iJ6pd-t5.js";
8
- import { t as createMatrixThreadBindingManager } from "./thread-bindings-BX5nmWpw.js";
7
+ import { n as matrixOnboardingAdapter } from "./setup-surface-2SS94JV0.js";
8
+ import { t as createMatrixThreadBindingManager } from "./thread-bindings-BI8MHWp9.js";
9
9
  //#region extensions/matrix/api.ts
10
10
  const matrixSessionBindingAdapterChannels = ["matrix"];
11
11
  //#endregion
12
- export { createMatrixSetupWizardProxy, createMatrixThreadBindingManager, findMatrixAccountEntry, getMatrixScopedEnvVarNames, getMatrixThreadBindingManager, hashMatrixAccessToken, listMatrixEnvAccountIds, matrixOnboardingAdapter, matrixOnboardingAdapter as matrixSetupWizard, matrixPlugin, matrixSessionBindingAdapterChannels, matrixSetupAdapter, requiresExplicitMatrixDefaultAccount, resetMatrixThreadBindingsForTests, resolveConfiguredMatrixAccountIds, resolveMatrixAccountStorageRoot, resolveMatrixChannelConfig, resolveMatrixCredentialsDir, resolveMatrixCredentialsFilename, resolveMatrixCredentialsPath, resolveMatrixDefaultOrOnlyAccountId, resolveMatrixEnvAccountToken, resolveMatrixHomeserverKey, resolveMatrixLegacyFlatStoragePaths, resolveMatrixLegacyFlatStoreRoot, sanitizeMatrixPathSegment, setMatrixThreadBindingIdleTimeoutBySessionKey, setMatrixThreadBindingMaxAgeBySessionKey };
12
+ export { createMatrixSetupWizardProxy, createMatrixThreadBindingManager, findMatrixAccountEntry, getMatrixScopedEnvVarNames, getMatrixThreadBindingManager, hashMatrixAccessToken, listMatrixEnvAccountIds, matrixOnboardingAdapter, matrixOnboardingAdapter as matrixSetupWizard, matrixPlugin, matrixSessionBindingAdapterChannels, matrixSetupAdapter, requiresExplicitMatrixDefaultAccount, resetMatrixThreadBindingsForTests, resolveConfiguredMatrixAccountIds, resolveMatrixAccountStorageRoot, resolveMatrixChannelConfig, resolveMatrixCredentialsDir, resolveMatrixCredentialsFilename, resolveMatrixCredentialsPath, resolveMatrixDefaultOrOnlyAccountId, resolveMatrixEnvAccountToken, resolveMatrixHomeserverKey, sanitizeMatrixPathSegment, setMatrixThreadBindingIdleTimeoutBySessionKey, setMatrixThreadBindingMaxAgeBySessionKey };
@@ -1,16 +1,17 @@
1
- import { g as resolveMatrixAccount } from "./setup-core-BGgbrdaJ.js";
2
- import { _ as shouldHandleMatrixApprovalRequest, g as isMatrixAnyApprovalClientEnabled } from "./channel-jUTBsjHU.js";
1
+ import { g as resolveMatrixAccount } from "./setup-core-DlmTyIP0.js";
2
+ import { _ as shouldHandleMatrixApprovalRequest, g as isMatrixAnyApprovalClientEnabled } from "./channel-CxqDh7mS.js";
3
3
  import { a as resolveMatrixTargetIdentity } from "./target-ids-B-5aQxwn.js";
4
- import { a as sendMessageMatrix, i as reactMatrixMessage, p as repairMatrixDirectRooms, s as sendSingleTextMessageMatrix } from "./send-D92v6Yy0.js";
5
- import { a as unregisterMatrixApprovalReactionTarget, n as listMatrixApprovalReactionBindings, r as registerMatrixApprovalReactionTarget, t as buildMatrixApprovalReactionHint } from "./approval-reactions-BdUaUXVw.js";
6
- import { n as editMatrixMessage, t as deleteMatrixMessage } from "./messages-DRKkiEY-.js";
4
+ import { a as sendMessageMatrix, i as reactMatrixMessage, p as repairMatrixDirectRooms, s as sendSingleTextMessageMatrix } from "./send-C7xuGWpv.js";
5
+ import { a as unregisterMatrixApprovalReactionTarget, n as listMatrixApprovalReactionBindings, r as registerMatrixApprovalReactionTarget, t as buildMatrixApprovalReactionHint } from "./approval-reactions-BgU51JGd.js";
6
+ import { n as editMatrixMessage, t as deleteMatrixMessage } from "./messages-Dm3K4ZvM.js";
7
7
  import { listMessageReceiptPlatformIds, resolveMessageReceiptPrimaryId } from "openclaw/plugin-sdk/channel-outbound";
8
8
  import { normalizeUniqueStringEntries } from "openclaw/plugin-sdk/string-coerce-runtime";
9
9
  import { buildChannelApprovalNativeTargetKey } from "openclaw/plugin-sdk/approval-native-runtime";
10
- import { setTimeout } from "node:timers/promises";
10
+ import { normalizeAccountId } from "openclaw/plugin-sdk/routing";
11
11
  import { createChannelApprovalNativeRuntimeAdapter } from "openclaw/plugin-sdk/approval-handler-runtime";
12
12
  import { buildExecApprovalPendingReplyPayload, buildPluginApprovalPendingReplyPayload } from "openclaw/plugin-sdk/approval-reply-runtime";
13
13
  import { buildPluginApprovalResolvedReplyPayload } from "openclaw/plugin-sdk/approval-runtime";
14
+ import { retryAsync } from "openclaw/plugin-sdk/retry-runtime";
14
15
  //#region extensions/matrix/src/approval-handler.runtime.ts
15
16
  const MATRIX_APPROVAL_METADATA_KEY = "com.openclaw.approval";
16
17
  const MATRIX_APPROVAL_DELIVERY_ATTEMPTS = 3;
@@ -28,10 +29,12 @@ function normalizePendingMessageIds(entry) {
28
29
  return normalizeUniqueStringEntries(entry.platformMessageIds);
29
30
  }
30
31
  function normalizeReactionTargetRef(params) {
32
+ const accountId = normalizeAccountId(params.accountId);
31
33
  const roomId = params.roomId.trim();
32
34
  const eventId = params.eventId.trim();
33
- if (!roomId || !eventId) return null;
35
+ if (!accountId || !roomId || !eventId) return null;
34
36
  return {
37
+ accountId,
35
38
  roomId,
36
39
  eventId
37
40
  };
@@ -43,15 +46,11 @@ function isSingleMatrixMessageLimitError(error) {
43
46
  return error instanceof Error && error.message.includes("Matrix single-message text exceeds limit");
44
47
  }
45
48
  async function retryMatrixApprovalDelivery(operation, params = {}) {
46
- let lastError;
47
- for (let attempt = 1; attempt <= MATRIX_APPROVAL_DELIVERY_ATTEMPTS; attempt += 1) try {
48
- return await operation();
49
- } catch (error) {
50
- lastError = error;
51
- if (attempt === MATRIX_APPROVAL_DELIVERY_ATTEMPTS || params.shouldRetry?.(error) === false) break;
52
- await setTimeout(MATRIX_APPROVAL_DELIVERY_RETRY_DELAY_MS * attempt);
53
- }
54
- throw lastError;
49
+ return await retryAsync(operation, {
50
+ attempts: MATRIX_APPROVAL_DELIVERY_ATTEMPTS,
51
+ minDelayMs: MATRIX_APPROVAL_DELIVERY_RETRY_DELAY_MS,
52
+ shouldRetry: (error) => params.shouldRetry?.(error) !== false
53
+ });
55
54
  }
56
55
  async function prepareTarget(params) {
57
56
  const resolved = resolveHandlerContext(params);
@@ -208,7 +207,7 @@ const matrixApprovalNativeRuntime = createChannelApprovalNativeRuntimeAdapter({
208
207
  accountId: resolved.accountId
209
208
  });
210
209
  },
211
- shouldHandle: ({ cfg, accountId, request, context }) => {
210
+ shouldHandle: ({ cfg, accountId, approvalKind, request, context }) => {
212
211
  const resolved = resolveHandlerContext({
213
212
  cfg,
214
213
  accountId,
@@ -218,6 +217,7 @@ const matrixApprovalNativeRuntime = createChannelApprovalNativeRuntimeAdapter({
218
217
  return shouldHandleMatrixApprovalRequest({
219
218
  cfg,
220
219
  accountId: resolved.accountId,
220
+ approvalKind,
221
221
  request
222
222
  });
223
223
  }
@@ -281,9 +281,11 @@ const matrixApprovalNativeRuntime = createChannelApprovalNativeRuntimeAdapter({
281
281
  const platformMessageIds = receiptMessageIds.length ? receiptMessageIds : [result.messageId.trim()].filter(Boolean);
282
282
  const reactionEventId = resolveMessageReceiptPrimaryId(result.receipt) || result.primaryMessageId?.trim() || platformMessageIds[0] || result.messageId.trim();
283
283
  registerMatrixApprovalReactionTarget({
284
+ accountId: resolved.accountId,
284
285
  roomId: result.roomId,
285
286
  eventId: reactionEventId,
286
287
  approvalId: pendingPayload.approvalId,
288
+ approvalKind: view.approvalKind,
287
289
  allowedDecisions: pendingPayload.allowedDecisions,
288
290
  ttlMs: view.expiresAtMs - Date.now()
289
291
  });
@@ -345,15 +347,20 @@ const matrixApprovalNativeRuntime = createChannelApprovalNativeRuntimeAdapter({
345
347
  },
346
348
  interactions: {
347
349
  bindPending: (params) => {
350
+ const accountId = params.accountId?.trim();
351
+ if (!accountId) return null;
348
352
  const target = normalizeReactionTargetRef({
353
+ accountId,
349
354
  roomId: params.entry.roomId,
350
355
  eventId: params.entry.reactionEventId
351
356
  });
352
357
  if (!target) return null;
353
358
  registerMatrixApprovalReactionTarget({
359
+ accountId: target.accountId,
354
360
  roomId: target.roomId,
355
361
  eventId: target.eventId,
356
362
  approvalId: params.pendingPayload.approvalId,
363
+ approvalKind: params.view.approvalKind,
357
364
  allowedDecisions: params.pendingPayload.allowedDecisions,
358
365
  ttlMs: params.view.expiresAtMs - Date.now()
359
366
  });
@@ -365,7 +372,10 @@ const matrixApprovalNativeRuntime = createChannelApprovalNativeRuntimeAdapter({
365
372
  unregisterMatrixApprovalReactionTarget(target);
366
373
  },
367
374
  cancelDelivered: (params) => {
375
+ const accountId = params.accountId?.trim();
376
+ if (!accountId) return;
368
377
  const target = normalizeReactionTargetRef({
378
+ accountId,
369
379
  roomId: params.entry.roomId,
370
380
  eventId: params.entry.reactionEventId
371
381
  });
@@ -1,4 +1,4 @@
1
- import { a as normalizeMatrixUserId } from "./config-schema-DtnhNYd-.js";
1
+ import { a as normalizeMatrixUserId } from "./config-schema-CG9goLWp.js";
2
2
  //#region extensions/matrix/src/approval-ids.ts
3
3
  function normalizeMatrixApproverId(value) {
4
4
  return normalizeMatrixUserId(String(value)) || void 0;
@@ -1,5 +1,5 @@
1
- import { g as resolveMatrixAccount } from "./setup-core-BGgbrdaJ.js";
2
- import { t as normalizeMatrixApproverId } from "./approval-ids-ZgqbspmS.js";
1
+ import { g as resolveMatrixAccount } from "./setup-core-DlmTyIP0.js";
2
+ import { t as normalizeMatrixApproverId } from "./approval-ids-C_2kSMdJ.js";
3
3
  import { resolveApprovalApprovers } from "openclaw/plugin-sdk/approval-auth-runtime";
4
4
  //#region extensions/matrix/src/approval-reaction-auth.ts
5
5
  function normalizeMatrixExecApproverId(value) {
@@ -0,0 +1,202 @@
1
+ import { n as getOptionalMatrixRuntime } from "./runtime-CveSqMOP.js";
2
+ import { normalizeAccountId, normalizeOptionalAccountId } from "openclaw/plugin-sdk/routing";
3
+ import { createApprovalReactionTargetStore } from "openclaw/plugin-sdk/approval-reaction-runtime";
4
+ //#region extensions/matrix/src/approval-reactions.ts
5
+ const MATRIX_APPROVAL_REACTION_META = {
6
+ "allow-once": {
7
+ emoji: "✅",
8
+ label: "Allow once"
9
+ },
10
+ "allow-always": {
11
+ emoji: "♾️",
12
+ label: "Allow always"
13
+ },
14
+ deny: {
15
+ emoji: "❌",
16
+ label: "Deny"
17
+ }
18
+ };
19
+ const MATRIX_APPROVAL_REACTION_ORDER = [
20
+ "allow-once",
21
+ "allow-always",
22
+ "deny"
23
+ ];
24
+ const PERSISTENT_NAMESPACE = "matrix.approval-reactions";
25
+ const PERSISTENT_MAX_ENTRIES = 1e3;
26
+ const DEFAULT_REACTION_TARGET_TTL_MS = 1440 * 60 * 1e3;
27
+ function reportPersistentApprovalReactionError(error) {
28
+ try {
29
+ getOptionalMatrixRuntime()?.logging.getChildLogger({
30
+ plugin: "matrix",
31
+ feature: "approval-reaction-state"
32
+ }).warn("Matrix persistent approval reaction state failed", { error: String(error) });
33
+ } catch {}
34
+ }
35
+ function readPersistedTarget(target) {
36
+ const value = target;
37
+ const accountId = typeof value?.accountId === "string" ? normalizeOptionalAccountId(value.accountId) : void 0;
38
+ const approvalId = typeof value?.approvalId === "string" ? value.approvalId.trim() : "";
39
+ const roomId = typeof value?.roomId === "string" ? value.roomId.trim() : "";
40
+ const eventId = typeof value?.eventId === "string" ? value.eventId.trim() : "";
41
+ if (!value || !accountId || !approvalId || !Array.isArray(value.allowedDecisions) || !roomId || !eventId || value.approvalKind !== "exec" && value.approvalKind !== "plugin") return null;
42
+ return {
43
+ accountId,
44
+ approvalId,
45
+ approvalKind: value.approvalKind,
46
+ roomId,
47
+ eventId,
48
+ allowedDecisions: value.allowedDecisions
49
+ };
50
+ }
51
+ function openPersistentMatrixApprovalReactionStore() {
52
+ return getOptionalMatrixRuntime()?.state.openKeyedStore({
53
+ namespace: PERSISTENT_NAMESPACE,
54
+ maxEntries: PERSISTENT_MAX_ENTRIES,
55
+ defaultTtlMs: DEFAULT_REACTION_TARGET_TTL_MS
56
+ });
57
+ }
58
+ const matrixApprovalReactionTargets = createApprovalReactionTargetStore({
59
+ namespace: PERSISTENT_NAMESPACE,
60
+ maxEntries: PERSISTENT_MAX_ENTRIES,
61
+ defaultTtlMs: DEFAULT_REACTION_TARGET_TTL_MS,
62
+ openStore: openPersistentMatrixApprovalReactionStore,
63
+ logPersistentError: reportPersistentApprovalReactionError,
64
+ readPersistedTarget
65
+ });
66
+ const matrixApprovalReactionTargetIndex = /* @__PURE__ */ new Map();
67
+ function pruneMatrixApprovalReactionTargetIndex() {
68
+ const nowMs = Date.now();
69
+ for (const [key, entry] of matrixApprovalReactionTargetIndex) if (entry.expiresAtMs <= nowMs) matrixApprovalReactionTargetIndex.delete(key);
70
+ while (matrixApprovalReactionTargetIndex.size > PERSISTENT_MAX_ENTRIES) {
71
+ const oldestKey = matrixApprovalReactionTargetIndex.keys().next().value;
72
+ if (!oldestKey) return;
73
+ matrixApprovalReactionTargetIndex.delete(oldestKey);
74
+ }
75
+ }
76
+ function buildReactionTargetKey(accountId, roomId, eventId) {
77
+ const normalizedAccountId = normalizeAccountId(accountId);
78
+ const normalizedRoomId = roomId.trim();
79
+ const normalizedEventId = eventId.trim();
80
+ if (!normalizedAccountId || !normalizedRoomId || !normalizedEventId) return null;
81
+ return JSON.stringify([
82
+ normalizedAccountId,
83
+ normalizedRoomId,
84
+ normalizedEventId
85
+ ]);
86
+ }
87
+ function listMatrixApprovalReactionBindings(allowedDecisions) {
88
+ const allowed = new Set(allowedDecisions);
89
+ return MATRIX_APPROVAL_REACTION_ORDER.filter((decision) => allowed.has(decision)).map((decision) => ({
90
+ decision,
91
+ emoji: MATRIX_APPROVAL_REACTION_META[decision].emoji,
92
+ label: MATRIX_APPROVAL_REACTION_META[decision].label
93
+ }));
94
+ }
95
+ function buildMatrixApprovalReactionHint(allowedDecisions) {
96
+ const bindings = listMatrixApprovalReactionBindings(allowedDecisions);
97
+ if (bindings.length === 0) return null;
98
+ return `React here: ${bindings.map((binding) => `${binding.emoji} ${binding.label}`).join(", ")}`;
99
+ }
100
+ function resolveMatrixApprovalReactionDecision(reactionKey, allowedDecisions) {
101
+ const normalizedReaction = reactionKey.trim();
102
+ if (!normalizedReaction) return null;
103
+ const allowed = new Set(allowedDecisions);
104
+ for (const decision of MATRIX_APPROVAL_REACTION_ORDER) {
105
+ if (!allowed.has(decision)) continue;
106
+ if (MATRIX_APPROVAL_REACTION_META[decision].emoji === normalizedReaction) return decision;
107
+ }
108
+ return null;
109
+ }
110
+ function registerMatrixApprovalReactionTarget(params) {
111
+ const accountId = normalizeAccountId(params.accountId);
112
+ const key = buildReactionTargetKey(accountId, params.roomId, params.eventId);
113
+ const approvalId = params.approvalId.trim();
114
+ const allowedDecisions = Array.from(new Set(params.allowedDecisions.filter((decision) => decision === "allow-once" || decision === "allow-always" || decision === "deny")));
115
+ if (!key || !approvalId || params.approvalKind !== "exec" && params.approvalKind !== "plugin" || allowedDecisions.length === 0) return;
116
+ const ttlMs = Math.max(1, params.ttlMs ?? DEFAULT_REACTION_TARGET_TTL_MS);
117
+ const target = {
118
+ accountId,
119
+ approvalId,
120
+ approvalKind: params.approvalKind,
121
+ roomId: params.roomId.trim(),
122
+ eventId: params.eventId.trim(),
123
+ allowedDecisions
124
+ };
125
+ matrixApprovalReactionTargetIndex.delete(key);
126
+ matrixApprovalReactionTargetIndex.set(key, {
127
+ target,
128
+ expiresAtMs: Date.now() + ttlMs
129
+ });
130
+ pruneMatrixApprovalReactionTargetIndex();
131
+ matrixApprovalReactionTargets.register(key, target, { ttlMs });
132
+ }
133
+ function unregisterMatrixApprovalReactionTarget(params) {
134
+ const key = buildReactionTargetKey(params.accountId, params.roomId, params.eventId);
135
+ if (!key) return;
136
+ matrixApprovalReactionTargetIndex.delete(key);
137
+ matrixApprovalReactionTargets.delete(key);
138
+ }
139
+ /** Retires every Matrix reaction anchor bound to one canonical approval. */
140
+ async function unregisterMatrixApprovalReactionTargetsForApproval(params) {
141
+ const accountId = normalizeAccountId(params.accountId);
142
+ const approvalId = params.approvalId.trim();
143
+ if (!approvalId) return [];
144
+ pruneMatrixApprovalReactionTargetIndex();
145
+ const matches = /* @__PURE__ */ new Map();
146
+ for (const [key, entry] of matrixApprovalReactionTargetIndex) if (entry.target.approvalId === approvalId && entry.target.accountId === accountId && entry.target.approvalKind === params.approvalKind) matches.set(key, entry.target);
147
+ let persistentStore = void 0;
148
+ try {
149
+ persistentStore = openPersistentMatrixApprovalReactionStore();
150
+ for (const entry of await persistentStore?.entries() ?? []) {
151
+ if (entry.value.version !== 1) continue;
152
+ const target = readPersistedTarget(entry.value.target);
153
+ if (target?.approvalId === approvalId && target.accountId === accountId && target.approvalKind === params.approvalKind && buildReactionTargetKey(target.accountId, target.roomId, target.eventId) === entry.key) matches.set(entry.key, target);
154
+ }
155
+ } catch (error) {
156
+ reportPersistentApprovalReactionError(error);
157
+ }
158
+ const persistentDeletes = [];
159
+ for (const [key] of matches) {
160
+ matrixApprovalReactionTargetIndex.delete(key);
161
+ matrixApprovalReactionTargets.delete(key);
162
+ if (persistentStore) persistentDeletes.push(persistentStore.delete(key));
163
+ }
164
+ await Promise.allSettled(persistentDeletes);
165
+ return Array.from(matches.values(), ({ accountId: ownerAccountId, roomId, eventId }) => ({
166
+ accountId: ownerAccountId,
167
+ roomId,
168
+ eventId
169
+ }));
170
+ }
171
+ function resolveTarget(params) {
172
+ const target = params.target;
173
+ if (!target) return null;
174
+ const decision = resolveMatrixApprovalReactionDecision(params.reactionKey, target.allowedDecisions);
175
+ if (!decision) return null;
176
+ return {
177
+ approvalId: target.approvalId,
178
+ approvalKind: target.approvalKind,
179
+ decision
180
+ };
181
+ }
182
+ async function resolveMatrixApprovalReactionTargetWithPersistence(params) {
183
+ const accountId = normalizeAccountId(params.accountId);
184
+ const key = buildReactionTargetKey(accountId, params.roomId, params.eventId);
185
+ if (!key) return null;
186
+ const target = await matrixApprovalReactionTargets.lookup(key);
187
+ if (target && (target.accountId !== accountId || buildReactionTargetKey(target.accountId, target.roomId, target.eventId) !== key)) return null;
188
+ if (target) {
189
+ matrixApprovalReactionTargetIndex.delete(key);
190
+ matrixApprovalReactionTargetIndex.set(key, {
191
+ target,
192
+ expiresAtMs: Date.now() + DEFAULT_REACTION_TARGET_TTL_MS
193
+ });
194
+ pruneMatrixApprovalReactionTargetIndex();
195
+ }
196
+ return resolveTarget({
197
+ target,
198
+ reactionKey: params.reactionKey
199
+ });
200
+ }
201
+ //#endregion
202
+ export { unregisterMatrixApprovalReactionTarget as a, resolveMatrixApprovalReactionTargetWithPersistence as i, listMatrixApprovalReactionBindings as n, unregisterMatrixApprovalReactionTargetsForApproval as o, registerMatrixApprovalReactionTarget as r, buildMatrixApprovalReactionHint as t };
@@ -1,4 +1,4 @@
1
- import { i as resolveMatrixCredentialsFilename, r as resolveMatrixCredentialsDir } from "./storage-paths-BWo_ZEMC.js";
1
+ import { i as resolveMatrixCredentialsFilename, r as resolveMatrixCredentialsDir } from "./storage-paths-B4_I9iqO.js";
2
2
  import fs from "node:fs";
3
3
  import os from "node:os";
4
4
  import path from "node:path";