@openclaw/matrix 2026.7.2-beta.7 → 2026.8.1-beta.3

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 (92) hide show
  1. package/dist/{account-selection-kqquRzCf.js → account-selection-CWuhuFn1.js} +7 -8
  2. package/dist/{accounts-DfngqebB.js → accounts-BCzyubQt.js} +3 -3
  3. package/dist/api.js +8 -11
  4. package/dist/{approval-handler.runtime-DSeaIsGa.js → approval-handler.runtime-CSvueU9P.js} +7 -6
  5. package/dist/{approval-ids-BdJGPAJT.js → approval-ids-CEcf-EiM.js} +1 -1
  6. package/dist/{approval-reaction-auth-BjOpELxu.js → approval-reaction-auth-CziKXatm.js} +2 -2
  7. package/dist/{approval-reactions-D-BxBK_L.js → approval-reactions-tXh9KYrW.js} +2 -8
  8. package/dist/auth-presence.js +2 -2
  9. package/dist/{channel-vj788dNZ.js → channel-CzQw5OZN.js} +376 -148
  10. package/dist/channel-plugin-api.js +1 -1
  11. package/dist/{channel.runtime-CLoF2S9T.js → channel.runtime-I9pBRQb3.js} +79 -55
  12. package/dist/{config-schema-Djxw3C6b.js → channel.setup-aNaa3Uyn.js} +51 -10
  13. package/dist/{cli-DMqfDE-q.js → cli-iR6QJ5U0.js} +16 -16
  14. package/dist/{cli-metadata-C7D53SND.js → cli-metadata-BmUYWjuM.js} +1 -1
  15. package/dist/cli-metadata.js +1 -1
  16. package/dist/client-BBQdBG7t.js +799 -0
  17. package/dist/{client-6eRENr7k.js → client-D8XghqmX.js} +4 -4
  18. package/dist/{client-bootstrap-XsIkHNt0.js → client-bootstrap-Co3RlItb.js} +25 -61
  19. package/dist/client-support-DLj4vDeu.js +93 -0
  20. package/dist/config-update-Bor_Pjsv.js +150 -0
  21. package/dist/contract-api.js +2 -2
  22. package/dist/{credentials-W2EmwRhu.js → credentials-BdAaWuiR.js} +2 -1
  23. package/dist/credentials-read-B37cQknZ.js +51 -0
  24. package/dist/credentials-state-B3cuUFwZ.js +27 -0
  25. package/dist/{credentials-write.runtime-Be9zNSUw.js → credentials-write.runtime-nAV2-5uR.js} +1 -1
  26. package/dist/{crypto-runtime-D9_6J5tZ.js → crypto-runtime-Bnz3zEcS.js} +55 -32
  27. package/dist/direct-room-RinHjtqX.js +71 -0
  28. package/dist/{directory-live-C8dVBiCc.js → directory-live-DLQzel12.js} +2 -3
  29. package/dist/{doctor-CM8ijNpW.js → doctor-EWf9CDso.js} +2 -2
  30. package/dist/{doctor-contract-BMSJkkAE.js → doctor-contract-DEt4O4Zt.js} +2 -3
  31. package/dist/doctor-contract-api.js +209 -91
  32. package/dist/{draft-stream-CtvOXq0Z.js → draft-stream-DQ7QNC-l.js} +20 -23
  33. package/dist/{encryption-guidance-CbEFe38F.js → encryption-guidance-DmLY8NiO.js} +1 -1
  34. package/dist/{env-auth-CQsYbz-p.js → env-auth-MVS-Vv41.js} +4 -3
  35. package/dist/{env-vars-B0NxQnPk.js → env-vars-dGqak9dN.js} +1 -1
  36. package/dist/{errors-C47hvAF8.js → errors-DKVS3_DO.js} +2 -5
  37. package/dist/{file-sync-store-DiiFsayX.js → file-sync-store-DjskBX2o.js} +24 -3
  38. package/dist/helper-api.js +2 -2
  39. package/dist/{idb-persistence-B6x7dMsF.js → idb-persistence-BM0P27Zg.js} +3 -2
  40. package/dist/{inbound-dedupe-CaBLblef.js → inbound-dedupe-RvSLqdsz.js} +2 -2
  41. package/dist/index.js +1 -1
  42. package/dist/{logger-D0GCSDQq.js → logger-B_71hN6W.js} +1 -1
  43. package/dist/{logging-DV-p52N0.js → logging-DRjvUOIh.js} +1 -1
  44. package/dist/{media-text-BTwzADS_.js → media-text-Dh-DpTc3.js} +4 -1
  45. package/dist/{messages-DxQJkhxs.js → messages-DEqg7HVy.js} +31 -11
  46. package/dist/{monitor-VyWlSLwo.js → monitor-FNrfkuWL.js} +413 -405
  47. package/dist/plugin-entry.handlers.runtime.js +3 -3
  48. package/dist/probe.runtime-NIJZYqc2.js +2 -0
  49. package/dist/profile-D-Wubo0A.js +108 -0
  50. package/dist/{profile-update-CffmyW_4.js → profile-update-BQlE5s2J.js} +3 -2
  51. package/dist/{reaction-events-B00WSi98.js → reaction-events-BKOLlnCo.js} +10 -7
  52. package/dist/{recovery-key-store-BNnHvXdk.js → recovery-key-store-CognuDys.js} +5 -4
  53. package/dist/{resolve-targets-nm2L48sh.js → resolve-targets-e7AI0P75.js} +2 -2
  54. package/dist/{resolver.runtime-DS6uPaEe.js → resolver.runtime-V8u0pHEb.js} +1 -1
  55. package/dist/{room-info-CAFZ3Z9J.js → room-info-BXQA7y10.js} +12 -3
  56. package/dist/runtime-api.js +7 -4
  57. package/dist/{sdk-bUytQHx7.js → sdk-NxK3vzMa.js} +242 -119
  58. package/dist/{secret-contract-M3hRmGO-.js → secret-contract-CufozuyJ.js} +1 -1
  59. package/dist/secret-contract-api.js +1 -1
  60. package/dist/{send-BldGYG8g.js → send-ClHgDZLT.js} +1477 -1210
  61. package/dist/session-binding-contract-api.js +2 -3
  62. package/dist/{setup-bootstrap-Deleiibz.js → setup-bootstrap-BGPjbA5N.js} +4 -4
  63. package/dist/{setup-core-BVfBv2ai.js → setup-core-DigrLebY.js} +17 -266
  64. package/dist/setup-plugin-api.js +1 -44
  65. package/dist/{setup-surface-BBq3WeqX.js → setup-surface-Dtn8sAWs.js} +15 -16
  66. package/dist/{startup-verification-wm3_i88s.js → startup-verification-Cs08ca8u.js} +3 -3
  67. package/dist/{storage-BvAkgzvT.js → storage-BsGuHngK.js} +3 -3
  68. package/dist/subagent-hooks-CMoZaARG.js +48 -0
  69. package/dist/subagent-hooks-api.js +1 -1
  70. package/dist/{target-ids-B-5aQxwn.js → target-ids-Nwx7cMVE.js} +11 -1
  71. package/dist/{thread-binding-api-DRbBZlhS.js → thread-binding-api-CzkeLZCU.js} +1 -1
  72. package/dist/thread-binding-api.js +1 -1
  73. package/dist/{thread-bindings-DGbl3vDW.js → thread-bindings-BYEGfw3h.js} +17 -10
  74. package/dist/thread-bindings-runtime.js +1 -1
  75. package/dist/{thread-bindings-shared-CKnY4LSd.js → thread-bindings-shared-oNPiyMWY.js} +1 -6
  76. package/dist/{tool-actions.runtime-uu9blSqO.js → tool-actions.runtime-ck6IJyP0.js} +36 -19
  77. package/dist/{verification-DYMQ1QpI.js → verification-CabtBTtB.js} +2 -2
  78. package/openclaw.plugin.json +61 -1
  79. package/package.json +4 -4
  80. package/dist/active-client-DXvz2gCo.js +0 -20
  81. package/dist/client-Dbso3-0V.js +0 -30
  82. package/dist/create-client-BmSU-q-D.js +0 -61
  83. package/dist/credentials-read-DVmFCm7X.js +0 -77
  84. package/dist/exec-approval-resolver-BCgqRtZS.js +0 -16
  85. package/dist/preflight-audio.runtime-BZxxQsxY.js +0 -11
  86. package/dist/probe.runtime-BuieqmS3.js +0 -3
  87. package/dist/record-shared-CWWx6fvI.js +0 -2
  88. package/dist/route-DY6at4qJ.js +0 -161
  89. package/dist/shared-CUMWxcMz.js +0 -673
  90. package/dist/subagent-hooks-dkPAF6Et.js +0 -143
  91. package/dist/sync-state-CWbp0QSY.js +0 -12
  92. package/dist/{runtime-api-D1xI_cvh.js → runtime-api-BGO16Fu8.js} +3 -3
@@ -1,21 +1,19 @@
1
- import { n as requiresExplicitMatrixDefaultAccount } from "./account-selection-kqquRzCf.js";
1
+ import { n as requiresExplicitMatrixDefaultAccount } from "./account-selection-CWuhuFn1.js";
2
2
  import { a as resolveMatrixAccountConfig } from "./account-config-BZWN9tGS.js";
3
- import { i as resolveMatrixAccount, r as resolveDefaultMatrixAccountId, t as listMatrixAccountIds } from "./accounts-DfngqebB.js";
4
- import { a as normalizeMatrixUserId, n as DEFAULT_ACCOUNT_ID$2, r as matrixConfigAdapter, t as MatrixChannelConfigSchema } from "./config-schema-Djxw3C6b.js";
5
- import { t as normalizeMatrixApproverId } from "./approval-ids-BdJGPAJT.js";
6
- import { a as resolveMatrixTargetIdentity, i as resolveMatrixDirectUserId, n as normalizeMatrixMessagingTarget, r as normalizeMatrixResolvableTarget, t as isMatrixQualifiedUserId } from "./target-ids-B-5aQxwn.js";
7
- import { t as formatMatrixErrorMessage } from "./errors-C47hvAF8.js";
8
- import { n as normalizeCompatibilityConfig, t as legacyConfigRules } from "./doctor-contract-BMSJkkAE.js";
9
- import { d as setMatrixThreadBindingIdleTimeoutBySessionKey, p as setMatrixThreadBindingMaxAgeBySessionKey } from "./thread-bindings-shared-CKnY4LSd.js";
10
- import { n as collectRuntimeConfigAssignments, r as secretTargetRegistryEntries } from "./secret-contract-M3hRmGO-.js";
11
- import { d as namedAccountPromotionKeys, f as resolveSingleAccountPromotionTarget, n as matrixSetupAdapter, p as singleAccountKeysToMove, r as matrixSetupContract, t as createMatrixSetupWizardProxy } from "./setup-core-BVfBv2ai.js";
12
- import { n as resolveMatrixInboundConversation, t as defaultTopLevelPlacement } from "./thread-binding-api-DRbBZlhS.js";
3
+ import { i as resolveMatrixAccount, r as resolveDefaultMatrixAccountId, t as listMatrixAccountIds } from "./accounts-BCzyubQt.js";
4
+ import { a as normalizeMatrixUserId, r as DEFAULT_ACCOUNT_ID$2, t as matrixPluginBase } from "./channel.setup-aNaa3Uyn.js";
5
+ import { t as normalizeMatrixApproverId } from "./approval-ids-CEcf-EiM.js";
6
+ import { a as resolveMatrixDirectUserId, i as normalizeMatrixResolvableTarget, n as isMatrixRoomId, o as resolveMatrixTargetIdentity, r as normalizeMatrixMessagingTarget, t as isMatrixQualifiedUserId } from "./target-ids-Nwx7cMVE.js";
7
+ import { n as normalizeCompatibilityConfig, t as legacyConfigRules } from "./doctor-contract-DEt4O4Zt.js";
8
+ import { n as MATRIX_REACTION_EVENT_TYPE } from "./reaction-common-DkrQdBSZ.js";
9
+ import { f as setMatrixThreadBindingMaxAgeBySessionKey, u as setMatrixThreadBindingIdleTimeoutBySessionKey } from "./thread-bindings-shared-oNPiyMWY.js";
10
+ import { n as collectRuntimeConfigAssignments, r as secretTargetRegistryEntries } from "./secret-contract-CufozuyJ.js";
11
+ import { n as resolveMatrixInboundConversation, t as defaultTopLevelPlacement } from "./thread-binding-api-CzkeLZCU.js";
13
12
  import { createLazyRuntimeModule, createLazyRuntimeNamedExport } from "openclaw/plugin-sdk/lazy-runtime";
14
- import { describeAccountSnapshot } from "openclaw/plugin-sdk/account-helpers";
15
13
  import { adaptScopedAccountAccessor, createScopedDmSecurityResolver } from "openclaw/plugin-sdk/channel-config-helpers";
16
14
  import { buildChannelOutboundSessionRoute, buildThreadAwareOutboundSessionRoute, createChatChannelPlugin } from "openclaw/plugin-sdk/channel-core";
17
15
  import { createChannelMessageAdapterFromOutbound, createReplyPrefixOptions, createRuntimeOutboundDelegates, createTypingCallbacks, logTypingFailure } from "openclaw/plugin-sdk/channel-outbound";
18
- import { createAllowlistProviderOpenWarningCollector, projectAccountConfigWarningCollector, resolveScopeRequireMention, resolveScopeToolsPolicy } from "openclaw/plugin-sdk/channel-policy";
16
+ import { createAllowlistProviderOpenWarningCollector, createConditionalWarningCollector, resolveScopeRequireMention, resolveScopeToolsPolicy } from "openclaw/plugin-sdk/channel-policy";
19
17
  import { createScopedAccountReplyToModeResolver } from "openclaw/plugin-sdk/conversation-runtime";
20
18
  import { createChannelDirectoryAdapter, createResolvedDirectoryEntriesLister, createRuntimeDirectoryLiveAdapter } from "openclaw/plugin-sdk/directory-runtime";
21
19
  import { buildProbeChannelStatusSummary, collectStatusIssuesFromLastError, createComputedAccountStatusAdapter, createDefaultChannelRuntimeState } from "openclaw/plugin-sdk/status-helpers";
@@ -27,16 +25,19 @@ import { Type } from "typebox";
27
25
  import { normalizeAccountId } from "openclaw/plugin-sdk/account-id";
28
26
  import { createApproverRestrictedNativeApprovalCapability, createChannelApprovalCapability, splitChannelApprovalCapability } from "openclaw/plugin-sdk/approval-delivery-runtime";
29
27
  import { createLazyChannelApprovalNativeRuntimeAdapter } from "openclaw/plugin-sdk/approval-handler-adapter-runtime";
30
- import { createChannelNativeOriginTargetResolver, resolveApprovalRequestChannelAccountId, resolveApprovalRequestSessionConversation } from "openclaw/plugin-sdk/approval-native-runtime";
28
+ import { createChannelNativeOriginTargetResolver, doesApprovalRequestSelectChannelAccount, resolveApprovalRequestSessionConversation } from "openclaw/plugin-sdk/approval-native-runtime";
31
29
  import { createChannelApprovalAuth, resolveApprovalApprovers } from "openclaw/plugin-sdk/approval-auth-runtime";
32
30
  import { addAllowlistUserEntriesFromConfigEntry, buildAllowlistResolutionSummary, canonicalizeAllowlistWithResolvedIds, patchAllowlistUsersInConfigEntries, summarizeMapping } from "openclaw/plugin-sdk/allow-from";
33
31
  import { createChannelExecApprovalProfile, getExecApprovalReplyMetadata, isChannelExecApprovalClientEnabledFromConfig, isChannelExecApprovalTargetRecipient, matchesApprovalRequestFilters } from "openclaw/plugin-sdk/approval-client-runtime";
34
- import { normalizeAccountId as normalizeAccountId$1, parseThreadSessionSuffix } from "openclaw/plugin-sdk/routing";
35
32
  import { createPairingPrefixStripper } from "openclaw/plugin-sdk/channel-pairing";
36
33
  import { PAIRING_APPROVED_MESSAGE } from "openclaw/plugin-sdk/channel-status";
34
+ import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
35
+ import { buildAgentSessionKey, deriveLastRoutePolicy, parseAgentSessionKey, parseThreadSessionSuffix, resolveAgentIdFromSessionKey, resolveAgentRoute, resolveThreadSessionKeys } from "openclaw/plugin-sdk/routing";
37
36
  import { formatLocationText, logInboundDrop, toLocationContext } from "openclaw/plugin-sdk/channel-inbound";
38
37
  import { getAgentScopedMediaLocalRoots } from "openclaw/plugin-sdk/media-local-roots";
39
38
  import { buildChannelKeyCandidates } from "openclaw/plugin-sdk/channel-targets";
39
+ import { resolveConfiguredAcpBindingRecord } from "openclaw/plugin-sdk/acp-binding-resolve-runtime";
40
+ import { inspectSessionBindingByConversation } from "openclaw/plugin-sdk/session-binding-runtime";
40
41
  import { deliveryContextFromSession, getSessionEntry, resolveStorePath, sessionDeliveryOrigin } from "openclaw/plugin-sdk/session-store-runtime";
41
42
  //#region extensions/matrix/src/actions.ts
42
43
  const MATRIX_PLUGIN_HANDLED_ACTIONS = /* @__PURE__ */ new Set([
@@ -82,7 +83,7 @@ function createMatrixExposedActions(params) {
82
83
  if (params.gate("profile") && params.senderIsOwner === true) actions.add("set-profile");
83
84
  if (params.gate("memberInfo")) actions.add("member-info");
84
85
  if (params.gate("channelInfo")) actions.add("channel-info");
85
- if (params.encryptionEnabled && params.gate("verification")) actions.add("permissions");
86
+ if (params.encryptionEnabled && params.gate("verification") && params.senderIsOwner === true) actions.add("permissions");
86
87
  return actions;
87
88
  }
88
89
  function buildMatrixProfileToolSchema() {
@@ -95,18 +96,22 @@ function buildMatrixProfileToolSchema() {
95
96
  }
96
97
  };
97
98
  }
99
+ function resolveMatrixActionAccount(params) {
100
+ if (!params.accountId && requiresExplicitMatrixDefaultAccount(params.cfg)) return null;
101
+ const account = resolveMatrixAccount({
102
+ cfg: params.cfg,
103
+ accountId: params.accountId ?? resolveDefaultMatrixAccountId(params.cfg)
104
+ });
105
+ return account.enabled && account.configured ? account : null;
106
+ }
98
107
  const matrixMessageActions = {
108
+ providerOwnedReadGates: true,
99
109
  describeMessageTool: ({ cfg, accountId, senderIsOwner }) => {
100
- const resolvedCfg = cfg;
101
- if (!accountId && requiresExplicitMatrixDefaultAccount(resolvedCfg)) return {
102
- actions: [],
103
- capabilities: []
104
- };
105
- const account = resolveMatrixAccount({
106
- cfg: resolvedCfg,
107
- accountId: accountId ?? resolveDefaultMatrixAccountId(resolvedCfg)
110
+ const account = resolveMatrixActionAccount({
111
+ cfg,
112
+ accountId
108
113
  });
109
- if (!account.enabled || !account.configured) return {
114
+ if (!account) return {
110
115
  actions: [],
111
116
  capabilities: []
112
117
  };
@@ -127,13 +132,22 @@ const matrixMessageActions = {
127
132
  extractToolSend: ({ args }) => {
128
133
  return extractToolSend(args, "sendMessage");
129
134
  },
135
+ prepareSendPayload: ({ ctx, payload }) => {
136
+ if (ctx.action !== "send") return null;
137
+ const account = resolveMatrixActionAccount({
138
+ cfg: ctx.cfg,
139
+ accountId: ctx.accountId
140
+ });
141
+ return account && createActionGate(account.config.actions)("messages") ? payload : null;
142
+ },
130
143
  handleAction: async (ctx) => {
131
- const { handleMatrixAction } = await import("./tool-actions.runtime-uu9blSqO.js");
144
+ const { handleMatrixAction } = await import("./tool-actions.runtime-ck6IJyP0.js");
132
145
  const { action, params, cfg, accountId, mediaLocalRoots } = ctx;
133
146
  const dispatch = async (actionParams) => await handleMatrixAction({
134
147
  ...actionParams,
135
148
  ...accountId ? { accountId } : {}
136
149
  }, cfg, {
150
+ ...action === "send" && ctx.mediaAccess ? { mediaAccess: ctx.mediaAccess } : {},
137
151
  mediaLocalRoots,
138
152
  readContext: {
139
153
  accountId,
@@ -150,7 +164,8 @@ const matrixMessageActions = {
150
164
  const mediaUrl = readStringParam(params, "media", { trim: false }) ?? readStringParam(params, "mediaUrl", { trim: false }) ?? readStringParam(params, "filePath", { trim: false }) ?? readStringParam(params, "path", { trim: false });
151
165
  const content = readStringParam(params, "message", {
152
166
  required: !mediaUrl,
153
- allowEmpty: true
167
+ allowEmpty: true,
168
+ trim: false
154
169
  });
155
170
  const replyTo = readStringParam(params, "replyTo");
156
171
  const threadId = readStringParam(params, "threadId");
@@ -204,7 +219,10 @@ const matrixMessageActions = {
204
219
  }
205
220
  if (action === "edit") {
206
221
  const messageId = readStringParam(params, "messageId", { required: true });
207
- const content = readStringParam(params, "message", { required: true });
222
+ const content = readStringParam(params, "message", {
223
+ required: true,
224
+ trim: false
225
+ });
208
226
  return await dispatch({
209
227
  action: "editMessage",
210
228
  roomId: resolveRoomId(),
@@ -248,6 +266,7 @@ const matrixMessageActions = {
248
266
  roomId: resolveRoomId()
249
267
  });
250
268
  if (action === "permissions") {
269
+ if (ctx.senderIsOwner !== true) throw new ToolAuthorizationError("Matrix verification actions require owner access.");
251
270
  const operation = normalizeLowercaseStringOrEmpty(readStringParam(params, "operation") ?? readStringParam(params, "mode") ?? "verification-list");
252
271
  const operationToAction = {
253
272
  "encryption-status": "encryptionStatus",
@@ -307,51 +326,37 @@ function resolveMatrixExecApprovalConfig(params) {
307
326
  enabled: account.enabled && account.configured ? config.enabled : false
308
327
  };
309
328
  }
310
- function countMatrixExecApprovalEligibleAccounts(params) {
311
- return listMatrixAccountIds(params.cfg).filter((accountId) => {
312
- const account = resolveMatrixAccount({
313
- cfg: params.cfg,
314
- accountId
315
- });
316
- if (!account.enabled || !account.configured) return false;
317
- const config = resolveMatrixExecApprovalConfig({
318
- cfg: params.cfg,
319
- accountId
320
- });
321
- const filters = config?.enabled ? {
322
- agentFilter: config.agentFilter,
323
- sessionFilter: config.sessionFilter
324
- } : {
325
- agentFilter: void 0,
326
- sessionFilter: void 0
327
- };
328
- return isChannelExecApprovalClientEnabledFromConfig({
329
- enabled: config?.enabled,
330
- approverCount: getMatrixApprovalApprovers({
331
- cfg: params.cfg,
332
- accountId,
333
- approvalKind: params.approvalKind
334
- }).length
335
- }) && matchesApprovalRequestFilters({
336
- request: params.request.request,
337
- agentFilter: filters.agentFilter,
338
- sessionFilter: filters.sessionFilter
339
- });
340
- }).length;
329
+ function isMatrixExecApprovalAccountEligible(params) {
330
+ const account = resolveMatrixAccount(params);
331
+ if (!account.enabled || !account.configured) return false;
332
+ const config = resolveMatrixExecApprovalConfig(params);
333
+ const filters = config?.enabled ? {
334
+ agentFilter: config.agentFilter,
335
+ sessionFilter: config.sessionFilter
336
+ } : {
337
+ agentFilter: void 0,
338
+ sessionFilter: void 0
339
+ };
340
+ return isChannelExecApprovalClientEnabledFromConfig({
341
+ enabled: config?.enabled,
342
+ approverCount: getMatrixApprovalApprovers(params).length
343
+ }) && matchesApprovalRequestFilters({
344
+ request: params.request.request,
345
+ agentFilter: filters.agentFilter,
346
+ sessionFilter: filters.sessionFilter
347
+ });
341
348
  }
342
349
  function matchesMatrixRequestAccount(params) {
343
- const turnSourceChannel = normalizeLowercaseStringOrEmpty(params.request.request.turnSourceChannel);
344
- const boundAccountId = resolveApprovalRequestChannelAccountId({
345
- cfg: params.cfg,
346
- request: params.request,
347
- channel: "matrix"
350
+ const accountId = params.accountId ?? resolveDefaultMatrixAccountId(params.cfg);
351
+ return doesApprovalRequestSelectChannelAccount({
352
+ ...params,
353
+ channel: "matrix",
354
+ defaultAccountId: resolveDefaultMatrixAccountId(params.cfg),
355
+ eligibleAccountIds: isMatrixExecApprovalAccountEligible({
356
+ ...params,
357
+ accountId
358
+ }) ? [accountId] : []
348
359
  });
349
- if (turnSourceChannel && turnSourceChannel !== "matrix" && !boundAccountId) return countMatrixExecApprovalEligibleAccounts({
350
- cfg: params.cfg,
351
- request: params.request,
352
- approvalKind: params.approvalKind
353
- }) <= 1;
354
- return !boundAccountId || !params.accountId || normalizeAccountId$1(boundAccountId) === normalizeAccountId$1(params.accountId);
355
360
  }
356
361
  function getMatrixExecApprovalApprovers(params) {
357
362
  const account = resolveMatrixAccount(params).config;
@@ -427,6 +432,7 @@ function shouldHandleMatrixApprovalRequest(params) {
427
432
  }
428
433
  function buildFilterCheckRequest(params) {
429
434
  if (params.metadata.approvalKind === "plugin") return {
435
+ approvalKind: "plugin",
430
436
  id: params.metadata.approvalId,
431
437
  request: {
432
438
  title: "Plugin Approval Required",
@@ -438,6 +444,7 @@ function buildFilterCheckRequest(params) {
438
444
  expiresAtMs: 0
439
445
  };
440
446
  return {
447
+ approvalKind: "exec",
441
448
  id: params.metadata.approvalId,
442
449
  request: {
443
450
  command: "",
@@ -602,7 +609,7 @@ const matrixNativeApprovalCapability = createApproverRestrictedNativeApprovalCap
602
609
  approvalKind,
603
610
  request
604
611
  }),
605
- load: async () => (await import("./approval-handler.runtime-DSeaIsGa.js")).matrixApprovalNativeRuntime
612
+ load: async () => (await import("./approval-handler.runtime-CSvueU9P.js")).matrixApprovalNativeRuntime
606
613
  })
607
614
  });
608
615
  const splitMatrixApprovalCapability = splitChannelApprovalCapability(matrixNativeApprovalCapability);
@@ -700,7 +707,7 @@ function createMatrixProbeAccount(params) {
700
707
  } catch (err) {
701
708
  return {
702
709
  ok: false,
703
- error: formatMatrixErrorMessage(err),
710
+ error: formatErrorMessage(err),
704
711
  elapsedMs: 0
705
712
  };
706
713
  }
@@ -720,6 +727,53 @@ function createMatrixPairingText(sendMessageMatrix) {
720
727
  };
721
728
  }
722
729
  //#endregion
730
+ //#region extensions/matrix/src/channel-message-adapter.ts
731
+ function createMatrixMessageAdapter(params) {
732
+ const base = createChannelMessageAdapterFromOutbound({
733
+ id: "matrix",
734
+ outbound: params.outbound,
735
+ live: {
736
+ capabilities: {
737
+ draftPreview: true,
738
+ previewFinalization: true,
739
+ progressUpdates: true,
740
+ quietFinalization: true
741
+ },
742
+ finalizer: { capabilities: {
743
+ finalEdit: true,
744
+ normalFallback: true,
745
+ discardPending: true,
746
+ previewReceipt: true
747
+ } }
748
+ }
749
+ });
750
+ return {
751
+ ...base,
752
+ durableFinal: {
753
+ ...base.durableFinal,
754
+ automaticUnknownSendReconciliation: true,
755
+ capabilities: {
756
+ ...base.durableFinal?.capabilities,
757
+ afterCommit: true,
758
+ reconcileUnknownSend: true
759
+ },
760
+ reconcileUnknownSendKinds: {
761
+ text: true,
762
+ media: true
763
+ },
764
+ reconcileUnknownSend: async (ctx) => await (await params.getRuntime()).reconcileMatrixUnknownSend(ctx),
765
+ afterUnknownSendTerminal: async (ctx) => await (await params.getRuntime()).cleanupMatrixDeliveryPlans({ queueId: ctx.queueId })
766
+ },
767
+ send: {
768
+ ...base.send,
769
+ lifecycle: { afterCommit: async (ctx) => {
770
+ if (!ctx.deliveryQueueId) return;
771
+ await (await params.getRuntime()).cleanupMatrixDeliveryPlans({ queueId: ctx.deliveryQueueId });
772
+ } }
773
+ }
774
+ };
775
+ }
776
+ //#endregion
723
777
  //#region extensions/matrix/src/matrix/monitor/rooms.ts
724
778
  function readLegacyRoomAllowAlias(room) {
725
779
  const rawRoom = room;
@@ -780,8 +834,195 @@ function resolveMatrixGroupToolPolicy(params) {
780
834
  return resolveScopeToolsPolicy(resolveMatrixGroupScope(params));
781
835
  }
782
836
  //#endregion
837
+ //#region extensions/matrix/src/matrix/monitor/types.ts
838
+ const EventType = {
839
+ RoomMessage: "m.room.message",
840
+ RoomMessageEncrypted: "m.room.encrypted",
841
+ RoomMember: "m.room.member",
842
+ Location: "m.location",
843
+ Reaction: MATRIX_REACTION_EVENT_TYPE
844
+ };
845
+ const RelationType = {
846
+ Replace: "m.replace",
847
+ Thread: "m.thread"
848
+ };
849
+ //#endregion
850
+ //#region extensions/matrix/src/matrix/monitor/threads.ts
851
+ function resolveMatrixThreadSessionKeys(params) {
852
+ return resolveThreadSessionKeys({
853
+ ...params,
854
+ normalizeThreadId: (threadId) => threadId
855
+ });
856
+ }
857
+ function resolveMatrixRelatedReplyToEventId(relates) {
858
+ if (!relates || typeof relates !== "object") return;
859
+ if ("m.in_reply_to" in relates && typeof relates["m.in_reply_to"] === "object" && relates["m.in_reply_to"] && "event_id" in relates["m.in_reply_to"] && typeof relates["m.in_reply_to"].event_id === "string") return relates["m.in_reply_to"].event_id;
860
+ }
861
+ function resolveMatrixThreadRouting(params) {
862
+ const effectiveThreadReplies = params.isDirectMessage && params.dmThreadReplies !== void 0 ? params.dmThreadReplies : params.threadReplies;
863
+ const messageId = params.messageId.trim();
864
+ const threadRootId = params.threadRootId?.trim();
865
+ const inboundThreadId = threadRootId && threadRootId !== messageId ? threadRootId : void 0;
866
+ return { threadId: effectiveThreadReplies === "off" ? void 0 : effectiveThreadReplies === "inbound" ? inboundThreadId : inboundThreadId ?? (messageId || void 0) };
867
+ }
868
+ function resolveMatrixThreadRootId(params) {
869
+ const relates = params.content["m.relates_to"];
870
+ if (!relates || typeof relates !== "object") return;
871
+ if ("rel_type" in relates && relates.rel_type === RelationType.Thread) {
872
+ if ("event_id" in relates && typeof relates.event_id === "string") return relates.event_id;
873
+ return resolveMatrixRelatedReplyToEventId(relates);
874
+ }
875
+ }
876
+ function resolveMatrixReplyToEventId(content) {
877
+ return resolveMatrixRelatedReplyToEventId(content["m.relates_to"]);
878
+ }
879
+ //#endregion
880
+ //#region extensions/matrix/src/matrix/monitor/route.ts
881
+ function resolveMatrixDmSessionKey(params) {
882
+ if (params.dmSessionScope !== "per-room") return params.fallbackSessionKey;
883
+ return buildAgentSessionKey({
884
+ agentId: params.agentId,
885
+ channel: "matrix",
886
+ accountId: params.accountId,
887
+ peer: {
888
+ kind: "channel",
889
+ id: params.roomId
890
+ }
891
+ });
892
+ }
893
+ function shouldApplyMatrixPerRoomDmSessionScope(params) {
894
+ return params.isDirectMessage && !params.configuredSessionKey;
895
+ }
896
+ function resolveMatrixInboundRoute(params) {
897
+ const baseRoute = params.resolveAgentRoute({
898
+ cfg: params.cfg,
899
+ channel: "matrix",
900
+ accountId: params.accountId,
901
+ peer: {
902
+ kind: params.isDirectMessage ? "direct" : "channel",
903
+ id: params.isDirectMessage ? params.senderId : params.roomId
904
+ },
905
+ parentPeer: params.isDirectMessage ? {
906
+ kind: "channel",
907
+ id: params.roomId
908
+ } : void 0
909
+ });
910
+ const bindingConversationId = params.threadId ?? params.roomId;
911
+ const bindingParentConversationId = params.threadId ? params.roomId : void 0;
912
+ const bindingInspection = inspectSessionBindingByConversation({
913
+ channel: "matrix",
914
+ accountId: params.accountId,
915
+ conversationId: bindingConversationId,
916
+ parentConversationId: bindingParentConversationId
917
+ });
918
+ const runtimeBinding = bindingInspection.status === "available" ? bindingInspection.binding : null;
919
+ const boundSessionKey = runtimeBinding?.targetSessionKey?.trim();
920
+ if (runtimeBinding && boundSessionKey) return {
921
+ route: {
922
+ ...baseRoute,
923
+ sessionKey: boundSessionKey,
924
+ agentId: resolveAgentIdFromSessionKey(boundSessionKey) || baseRoute.agentId,
925
+ lastRoutePolicy: deriveLastRoutePolicy({
926
+ sessionKey: boundSessionKey,
927
+ mainSessionKey: baseRoute.mainSessionKey
928
+ }),
929
+ matchedBy: "binding.channel"
930
+ },
931
+ configuredBinding: null,
932
+ bindingOwnerAvailable: true,
933
+ runtimeBindingId: runtimeBinding.bindingId
934
+ };
935
+ const configuredBinding = runtimeBinding == null ? resolveConfiguredAcpBindingRecord({
936
+ cfg: params.cfg,
937
+ channel: "matrix",
938
+ accountId: params.accountId,
939
+ conversationId: bindingConversationId,
940
+ parentConversationId: bindingParentConversationId
941
+ }) : null;
942
+ const configuredSessionKey = configuredBinding?.record.targetSessionKey?.trim();
943
+ const effectiveRoute = configuredBinding && configuredSessionKey ? {
944
+ ...baseRoute,
945
+ sessionKey: configuredSessionKey,
946
+ agentId: resolveAgentIdFromSessionKey(configuredSessionKey) || configuredBinding.spec.agentId || baseRoute.agentId,
947
+ lastRoutePolicy: deriveLastRoutePolicy({
948
+ sessionKey: configuredSessionKey,
949
+ mainSessionKey: baseRoute.mainSessionKey
950
+ }),
951
+ matchedBy: "binding.channel"
952
+ } : baseRoute;
953
+ const dmSessionKey = shouldApplyMatrixPerRoomDmSessionScope({
954
+ isDirectMessage: params.isDirectMessage,
955
+ configuredSessionKey
956
+ }) ? resolveMatrixDmSessionKey({
957
+ accountId: params.accountId,
958
+ agentId: effectiveRoute.agentId,
959
+ roomId: params.roomId,
960
+ dmSessionScope: params.dmSessionScope,
961
+ fallbackSessionKey: effectiveRoute.sessionKey
962
+ }) : effectiveRoute.sessionKey;
963
+ const routeWithDmScope = dmSessionKey === effectiveRoute.sessionKey ? effectiveRoute : {
964
+ ...effectiveRoute,
965
+ sessionKey: dmSessionKey,
966
+ lastRoutePolicy: "session"
967
+ };
968
+ if (!configuredBinding && !configuredSessionKey && params.threadId) {
969
+ const threadKeys = resolveMatrixThreadSessionKeys({
970
+ baseSessionKey: routeWithDmScope.sessionKey,
971
+ threadId: params.threadId,
972
+ parentSessionKey: routeWithDmScope.sessionKey
973
+ });
974
+ return {
975
+ route: {
976
+ ...routeWithDmScope,
977
+ sessionKey: threadKeys.sessionKey,
978
+ mainSessionKey: threadKeys.parentSessionKey ?? routeWithDmScope.sessionKey,
979
+ lastRoutePolicy: deriveLastRoutePolicy({
980
+ sessionKey: threadKeys.sessionKey,
981
+ mainSessionKey: threadKeys.parentSessionKey ?? routeWithDmScope.sessionKey
982
+ })
983
+ },
984
+ configuredBinding,
985
+ bindingOwnerAvailable: bindingInspection.status === "available",
986
+ runtimeBindingId: runtimeBinding?.bindingId ?? null
987
+ };
988
+ }
989
+ return {
990
+ route: routeWithDmScope,
991
+ configuredBinding,
992
+ bindingOwnerAvailable: bindingInspection.status === "available",
993
+ runtimeBindingId: runtimeBinding?.bindingId ?? null
994
+ };
995
+ }
996
+ //#endregion
997
+ //#region extensions/matrix/src/matrix/conversation-route-owner.ts
998
+ function resolveMatrixConversationRouteOwner(params) {
999
+ const { cfg, accountId, conversation } = params;
1000
+ const roomId = conversation.nativeChannelId?.trim() || (conversation.kind === "direct" ? "" : conversation.peerId.trim());
1001
+ if (!roomId) return null;
1002
+ const isDirectMessage = conversation.kind === "direct";
1003
+ const result = resolveMatrixInboundRoute({
1004
+ cfg,
1005
+ accountId,
1006
+ roomId,
1007
+ senderId: conversation.peerId,
1008
+ isDirectMessage,
1009
+ dmSessionScope: resolveMatrixAccount({
1010
+ cfg,
1011
+ accountId
1012
+ }).config.dm?.sessionScope,
1013
+ threadId: conversation.threadId,
1014
+ resolveAgentRoute
1015
+ });
1016
+ if (!result.bindingOwnerAvailable) return { kind: "unavailable" };
1017
+ if (result.runtimeBindingId && !parseAgentSessionKey(result.route.sessionKey)?.agentId) return null;
1018
+ return {
1019
+ kind: "agent",
1020
+ agentId: result.route.agentId
1021
+ };
1022
+ }
1023
+ //#endregion
783
1024
  //#region extensions/matrix/src/resolver.ts
784
- const loadMatrixChannelRuntime$1 = createLazyRuntimeNamedExport(() => import("./resolver.runtime-DS6uPaEe.js"), "matrixResolverRuntime");
1025
+ const loadMatrixChannelRuntime$1 = createLazyRuntimeNamedExport(() => import("./resolver.runtime-V8u0pHEb.js"), "matrixResolverRuntime");
785
1026
  const matrixResolverAdapter = { resolveTargets: async ({ cfg, accountId, inputs, kind, runtime }) => (await loadMatrixChannelRuntime$1()).resolveMatrixTargets({
786
1027
  cfg,
787
1028
  accountId,
@@ -887,7 +1128,7 @@ function resolveMatrixOutboundSessionRoute(params) {
887
1128
  agentId: params.agentId,
888
1129
  channel: "matrix",
889
1130
  accountId: effectiveAccountId,
890
- recipientSessionExact: target.kind === "room" ? dmSessionScope === "per-room" && target.id.startsWith("!") && target.id.includes(":") : dmSessionScope === "per-user" ? isMatrixQualifiedUserId(target.id) : roomScopedDmId !== void 0,
1131
+ recipientSessionExact: target.kind === "room" ? dmSessionScope === "per-room" && isMatrixRoomId(target.id) : dmSessionScope === "per-user" ? isMatrixQualifiedUserId(target.id) : roomScopedDmId !== void 0,
891
1132
  peer,
892
1133
  chatType,
893
1134
  from,
@@ -896,6 +1137,11 @@ function resolveMatrixOutboundSessionRoute(params) {
896
1137
  replyToId: params.replyToId,
897
1138
  threadId: params.threadId,
898
1139
  currentSessionKey: params.currentSessionKey,
1140
+ precedence: [
1141
+ "threadId",
1142
+ "replyToId",
1143
+ "currentSession"
1144
+ ],
899
1145
  normalizeThreadId: (threadId) => threadId,
900
1146
  canRecoverCurrentThread: ({ route }) => route.peer.kind !== "direct" || (params.cfg.session?.dmScope ?? "main") !== "main"
901
1147
  });
@@ -903,20 +1149,8 @@ function resolveMatrixOutboundSessionRoute(params) {
903
1149
  //#endregion
904
1150
  //#region extensions/matrix/src/channel.ts
905
1151
  let matrixStartupLock = Promise.resolve();
906
- const loadMatrixSetupWizard = createLazyRuntimeNamedExport(() => import("./setup-surface-BBq3WeqX.js").then((n) => n.t), "matrixSetupWizard");
907
- const loadMatrixChannelRuntime = createLazyRuntimeNamedExport(() => import("./channel.runtime-CLoF2S9T.js"), "matrixChannelRuntime");
908
- const loadMatrixDoctorModule = createLazyRuntimeModule(() => import("./doctor-CM8ijNpW.js"));
909
- const meta = {
910
- id: "matrix",
911
- label: "Matrix",
912
- selectionLabel: "Matrix (plugin)",
913
- docsPath: "/channels/matrix",
914
- docsLabel: "matrix",
915
- blurb: "open protocol; configure a homeserver + access token.",
916
- order: 70,
917
- markdownCapable: true,
918
- quickstartAllowFrom: true
919
- };
1152
+ const loadMatrixChannelRuntime = createLazyRuntimeNamedExport(() => import("./channel.runtime-I9pBRQb3.js"), "matrixChannelRuntime");
1153
+ const loadMatrixDoctorModule = createLazyRuntimeModule(() => import("./doctor-EWf9CDso.js"));
920
1154
  function buildMatrixTrafficStatusSummary(snapshot) {
921
1155
  return {
922
1156
  lastInboundAt: snapshot?.lastInboundAt ?? null,
@@ -979,7 +1213,7 @@ const resolveMatrixDmPolicy = createScopedDmSecurityResolver({
979
1213
  allowFromPathSuffix: "dm.",
980
1214
  normalizeEntry: (raw) => normalizeMatrixUserId(raw)
981
1215
  });
982
- const collectMatrixSecurityWarnings = createAllowlistProviderOpenWarningCollector({
1216
+ const collectMatrixGroupPolicyWarnings = createAllowlistProviderOpenWarningCollector({
983
1217
  providerConfigPresent: (cfg) => cfg.channels?.matrix !== void 0,
984
1218
  resolveGroupPolicy: (account) => account.config.groupPolicy,
985
1219
  buildOpenWarning: {
@@ -991,18 +1225,28 @@ const collectMatrixSecurityWarnings = createAllowlistProviderOpenWarningCollecto
991
1225
  function resolveMatrixAccountConfigPath(accountId, field) {
992
1226
  return accountId === DEFAULT_ACCOUNT_ID$2 ? `channels.matrix.${field}` : `channels.matrix.accounts.${accountId}.${field}`;
993
1227
  }
994
- function collectMatrixSecurityWarningsForAccount(params) {
995
- const warnings = collectMatrixSecurityWarnings(params);
1228
+ function collectMatrixGroupPolicyWarningsForAccount(params) {
1229
+ const warnings = collectMatrixGroupPolicyWarnings(params);
996
1230
  if (params.account.accountId !== DEFAULT_ACCOUNT_ID$2) {
997
1231
  const groupPolicyPath = resolveMatrixAccountConfigPath(params.account.accountId, "groupPolicy");
998
1232
  const groupsPath = resolveMatrixAccountConfigPath(params.account.accountId, "groups");
999
1233
  const groupAllowFromPath = resolveMatrixAccountConfigPath(params.account.accountId, "groupAllowFrom");
1000
1234
  return warnings.map((warning) => warning.replace("channels.matrix.groupPolicy", groupPolicyPath).replace("channels.matrix.groups", groupsPath).replace("channels.matrix.groupAllowFrom", groupAllowFromPath));
1001
1235
  }
1002
- if (params.account.config.autoJoin !== "always") return warnings;
1236
+ return warnings;
1237
+ }
1238
+ const collectMatrixOpenGroupFindings = createConditionalWarningCollector.findings({
1239
+ collectWarnings: collectMatrixGroupPolicyWarningsForAccount,
1240
+ checkId: "channels.matrix.groups.open",
1241
+ severity: "critical",
1242
+ title: "Matrix security warning"
1243
+ });
1244
+ function collectMatrixSecurityWarningsForAccount(params) {
1245
+ const findings = collectMatrixOpenGroupFindings(params);
1246
+ if (params.account.accountId !== DEFAULT_ACCOUNT_ID$2 || params.account.config.autoJoin !== "always") return findings;
1003
1247
  const autoJoinPath = resolveMatrixAccountConfigPath(params.account.accountId, "autoJoin");
1004
1248
  const autoJoinAllowlistPath = resolveMatrixAccountConfigPath(params.account.accountId, "autoJoinAllowlist");
1005
- return [...warnings, `- Matrix invites: autoJoin="always" joins any invited room before message policy applies. Set ${autoJoinPath}="allowlist" + ${autoJoinAllowlistPath} (or ${autoJoinPath}="off") to restrict joins.`];
1249
+ return [...findings, `- Matrix invites: autoJoin="always" joins any invited room before message policy applies. Set ${autoJoinPath}="allowlist" + ${autoJoinAllowlistPath} (or ${autoJoinPath}="off") to restrict joins.`];
1006
1250
  }
1007
1251
  function normalizeMatrixAcpConversationId(conversationId) {
1008
1252
  const target = resolveMatrixTargetIdentity(conversationId);
@@ -1052,6 +1296,13 @@ function resolveMatrixDeliveryTarget(params) {
1052
1296
  if (conversationTarget?.kind === "room") return { to: `room:${conversationTarget.id}` };
1053
1297
  return null;
1054
1298
  }
1299
+ function matchesMatrixToolContextRoom(params) {
1300
+ const { toolContext } = params;
1301
+ if (toolContext.currentChannelProvider && toolContext.currentChannelProvider !== "matrix") return false;
1302
+ const currentTarget = toolContext.currentChannelId ? resolveMatrixTargetIdentity(toolContext.currentChannelId) : null;
1303
+ const target = resolveMatrixTargetIdentity(params.target);
1304
+ return currentTarget?.kind === "room" && target?.kind === "room" && currentTarget.id === target.id;
1305
+ }
1055
1306
  const matrixChannelOutbound = {
1056
1307
  deliveryMode: "direct",
1057
1308
  chunker: chunkTextForOutbound,
@@ -1063,7 +1314,9 @@ const matrixChannelOutbound = {
1063
1314
  media: true,
1064
1315
  replyTo: true,
1065
1316
  thread: true,
1066
- messageSendingHooks: true
1317
+ messageSendingHooks: true,
1318
+ afterCommit: true,
1319
+ reconcileUnknownSend: true
1067
1320
  } },
1068
1321
  presentationCapabilities: {
1069
1322
  supported: true,
@@ -1105,52 +1358,21 @@ const matrixChannelOutbound = {
1105
1358
  }
1106
1359
  })
1107
1360
  };
1108
- const matrixMessageAdapter = createChannelMessageAdapterFromOutbound({
1109
- id: "matrix",
1361
+ const matrixMessageAdapter = createMatrixMessageAdapter({
1110
1362
  outbound: matrixChannelOutbound,
1111
- live: {
1112
- capabilities: {
1113
- draftPreview: true,
1114
- previewFinalization: true,
1115
- progressUpdates: true,
1116
- quietFinalization: true
1117
- },
1118
- finalizer: { capabilities: {
1119
- finalEdit: true,
1120
- normalFallback: true,
1121
- discardPending: true,
1122
- previewReceipt: true
1123
- } }
1124
- }
1363
+ getRuntime: loadMatrixChannelRuntime
1125
1364
  });
1126
1365
  const matrixPlugin = createChatChannelPlugin({
1127
1366
  base: {
1128
- id: "matrix",
1129
- meta,
1130
- setupWizard: createMatrixSetupWizardProxy(async () => ({ matrixSetupWizard: await loadMatrixSetupWizard() })),
1367
+ ...matrixPluginBase,
1368
+ meta: {
1369
+ ...matrixPluginBase.meta,
1370
+ markdownCapable: true
1371
+ },
1131
1372
  capabilities: {
1132
- chatTypes: [
1133
- "direct",
1134
- "group",
1135
- "thread"
1136
- ],
1137
- polls: true,
1138
- reactions: true,
1139
- threads: true,
1140
- media: true,
1373
+ ...matrixPluginBase.capabilities,
1141
1374
  tts: { voice: { synthesisTarget: "voice-note" } }
1142
1375
  },
1143
- reload: { configPrefixes: ["channels.matrix"] },
1144
- configSchema: MatrixChannelConfigSchema,
1145
- config: {
1146
- ...matrixConfigAdapter,
1147
- isConfigured: (account) => account.configured,
1148
- describeAccount: (account) => describeAccountSnapshot({
1149
- account,
1150
- configured: account.configured,
1151
- extra: { baseUrl: account.homeserver }
1152
- })
1153
- },
1154
1376
  approvalCapability: matrixApprovalCapability,
1155
1377
  groups: {
1156
1378
  resolveRequireMention: resolveMatrixGroupRequireMention,
@@ -1158,6 +1380,7 @@ const matrixPlugin = createChatChannelPlugin({
1158
1380
  },
1159
1381
  conversationBindings: {
1160
1382
  supportsCurrentConversationBinding: true,
1383
+ bindingStore: "adapter",
1161
1384
  defaultTopLevelPlacement,
1162
1385
  setIdleTimeoutBySessionKey: ({ targetSessionKey, accountId, idleTimeoutMs }) => setMatrixThreadBindingIdleTimeoutBySessionKey({
1163
1386
  targetSessionKey,
@@ -1175,6 +1398,10 @@ const matrixPlugin = createChatChannelPlugin({
1175
1398
  targetPrefixes: ["matrix"],
1176
1399
  targetIdComparison: "case-sensitive",
1177
1400
  normalizeTarget: normalizeMatrixMessagingTarget,
1401
+ inferTargetChatType: ({ to }) => {
1402
+ const target = resolveMatrixTargetIdentity(to);
1403
+ return target ? target.kind === "user" ? "direct" : "channel" : void 0;
1404
+ },
1178
1405
  resolveInboundConversation: ({ to, conversationId, threadId }) => resolveMatrixInboundConversation({
1179
1406
  to,
1180
1407
  conversationId,
@@ -1185,6 +1412,7 @@ const matrixPlugin = createChatChannelPlugin({
1185
1412
  parentConversationId
1186
1413
  }),
1187
1414
  resolveOutboundSessionRoute: (params) => resolveMatrixOutboundSessionRoute(params),
1415
+ resolveConversationRouteOwner: resolveMatrixConversationRouteOwner,
1188
1416
  targetResolver: {
1189
1417
  looksLikeId: (raw) => {
1190
1418
  const trimmed = raw.trim();
@@ -1216,18 +1444,6 @@ const matrixPlugin = createChatChannelPlugin({
1216
1444
  secretTargetRegistryEntries,
1217
1445
  collectRuntimeConfigAssignments
1218
1446
  },
1219
- setup: {
1220
- ...matrixSetupAdapter,
1221
- singleAccountKeysToMove,
1222
- namedAccountPromotionKeys,
1223
- resolveSingleAccountPromotionTarget
1224
- },
1225
- setupContract: {
1226
- ...matrixSetupContract,
1227
- singleAccountKeysToMove,
1228
- namedAccountPromotionKeys,
1229
- resolveSingleAccountPromotionTarget
1230
- },
1231
1447
  bindings: {
1232
1448
  compileConfiguredBinding: ({ conversationId }) => normalizeMatrixAcpConversationId(conversationId),
1233
1449
  matchInboundConversation: ({ compiledBinding, conversationId, parentConversationId }) => matchMatrixAcpConversation({
@@ -1284,7 +1500,7 @@ const matrixPlugin = createChatChannelPlugin({
1284
1500
  await previousLock;
1285
1501
  let monitorMatrixProvider;
1286
1502
  try {
1287
- monitorMatrixProvider = (await import("./monitor-VyWlSLwo.js")).monitorMatrixProvider;
1503
+ monitorMatrixProvider = (await import("./monitor-FNrfkuWL.js")).monitorMatrixProvider;
1288
1504
  } finally {
1289
1505
  releaseLock();
1290
1506
  }
@@ -1317,10 +1533,22 @@ const matrixPlugin = createChatChannelPlugin({
1317
1533
  },
1318
1534
  security: {
1319
1535
  resolveDmPolicy: resolveMatrixDmPolicy,
1320
- collectWarnings: projectAccountConfigWarningCollector((cfg) => cfg, collectMatrixSecurityWarningsForAccount)
1536
+ collectWarnings: ({ account, cfg }) => collectMatrixSecurityWarningsForAccount({
1537
+ account,
1538
+ cfg
1539
+ })
1321
1540
  },
1322
1541
  pairing: { text: createMatrixPairingText(async (to, message, options) => await (await loadMatrixChannelRuntime()).sendMessageMatrix(to, message, options)) },
1323
1542
  threading: {
1543
+ matchesToolContextTarget: matchesMatrixToolContextRoom,
1544
+ resolveAutoThreadId: ({ to, toolContext }) => {
1545
+ const threadId = normalizeOptionalString(toolContext?.currentThreadTs);
1546
+ if (!threadId || !toolContext) return;
1547
+ return matchesMatrixToolContextRoom({
1548
+ target: to,
1549
+ toolContext
1550
+ }) ? threadId : void 0;
1551
+ },
1324
1552
  resolveReplyToMode: createScopedAccountReplyToModeResolver({
1325
1553
  resolveAccount: adaptScopedAccountAccessor(resolveMatrixAccountConfig),
1326
1554
  resolveReplyToMode: (account) => account.replyToMode
@@ -1342,4 +1570,4 @@ const matrixPlugin = createChatChannelPlugin({
1342
1570
  outbound: matrixChannelOutbound
1343
1571
  });
1344
1572
  //#endregion
1345
- export { shouldHandleMatrixApprovalRequest as _, buildAllowlistResolutionSummary as a, createTypingCallbacks as c, logInboundDrop as d, logTypingFailure as f, isMatrixAnyApprovalClientEnabled as g, toLocationContext as h, addAllowlistUserEntriesFromConfigEntry as i, formatLocationText as l, summarizeMapping as m, resolveMatrixStoredSessionMeta as n, canonicalizeAllowlistWithResolvedIds as o, patchAllowlistUsersInConfigEntries as p, resolveMatrixRoomConfig as r, createReplyPrefixOptions as s, matrixPlugin as t, getAgentScopedMediaLocalRoots as u };
1573
+ export { shouldHandleMatrixApprovalRequest as C, isMatrixAnyApprovalClientEnabled as S, logInboundDrop as _, resolveMatrixThreadRootId as a, summarizeMapping as b, RelationType as c, buildAllowlistResolutionSummary as d, canonicalizeAllowlistWithResolvedIds as f, getAgentScopedMediaLocalRoots as g, formatLocationText as h, resolveMatrixReplyToEventId as i, resolveMatrixRoomConfig as l, createTypingCallbacks as m, resolveMatrixStoredSessionMeta as n, resolveMatrixThreadRouting as o, createReplyPrefixOptions as p, resolveMatrixInboundRoute as r, EventType as s, matrixPlugin as t, addAllowlistUserEntriesFromConfigEntry as u, logTypingFailure as v, toLocationContext as x, patchAllowlistUsersInConfigEntries as y };