@openclaw/mattermost 2026.8.1-beta.3 → 2026.8.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.
@@ -1,13 +1,13 @@
1
1
  import { n as getOptionalMattermostRuntime, t as getMattermostRuntime } from "./runtime-CNB4YGqJ.js";
2
- import { a as createMattermostPost, d as fetchMattermostUser, g as readMattermostError, l as fetchMattermostChannelPosts, m as normalizeMattermostBaseUrl, n as buildMattermostApiUrl, o as deleteMattermostPost, p as fetchMattermostUserTeams, r as createMattermostClient, s as fetchMattermostChannel, t as MattermostPostSchema, u as fetchMattermostMe, v as sendMattermostTyping, y as updateMattermostPost } from "./client-B_hd-kwM.js";
3
- import { S as resolveChannelMediaMaxBytes, T as warnMissingProviderGroupPolicyFallbackOnce, _ as logInboundDrop, b as registerPluginHttpRoute, c as DEFAULT_GROUP_HISTORY_LIMIT, d as createChannelMessageReplyPipeline, f as createChannelPairingController, h as listSkillCommandsForAgents, i as normalizeMattermostAllowEntry, l as buildModelsProviderData, n as formatMattermostDirectMessageDropLog, o as resolveMattermostMonitorInboundAccess, s as resolveMattermostTrustedChatKind, t as authorizeMattermostCommandInvocation, u as createChannelHistoryWindow, v as logTypingFailure, w as resolveDefaultGroupPolicy, x as resolveAllowlistProviderRuntimeGroupPolicy$1 } from "./monitor-auth-CVd_4FPD.js";
4
- import { a as resolveInteractionCallbackPath, c as setInteractionSecret, i as createMattermostInteractionHandler, n as buildButtonProps, r as computeInteractionCallbackUrl, s as setInteractionCallbackUrl } from "./interactions-Du_EJMeN.js";
5
- import { a as resolveMattermostReplyToMode, i as resolveMattermostAccount, n as listMattermostAccountIds, t as inspectMattermostAccount } from "./accounts-DspH-NMT.js";
6
- import { i as normalizeMattermostMessagingTarget } from "./channel-plugin-runtime-C_mWt_83.js";
7
- import { _ as isSlashCommandsEnabled, a as sendMessageMattermost, b as resolveSlashCommandConfig, c as deliverMattermostReplyPayload, d as parseMattermostModelPickerContext, f as renderMattermostModelsPickerView, g as cleanupSlashCommands, h as DEFAULT_COMMAND_SPECS, l as joinMattermostVisibleContent, m as resolveMattermostModelPickerCurrentModel, n as deactivateSlashCommands, o as resolveMattermostOpaqueTarget, p as renderMattermostProviderPickerView, r as getSlashCommandState, s as createMattermostReplyDeliveryBarrier, t as activateSlashCommands, u as buildMattermostAllowedModelRefs, v as registerSlashCommands, y as resolveCallbackUrl } from "./slash-state-BakgoSSL.js";
2
+ import { _ as sendMattermostTyping, a as createMattermostPost, d as fetchMattermostUser, g as readMattermostError, l as fetchMattermostChannelPosts, m as normalizeMattermostBaseUrl, n as buildMattermostApiUrl, o as deleteMattermostPost, p as fetchMattermostUserTeams, r as createMattermostClient, s as fetchMattermostChannel, t as MattermostPostSchema, u as fetchMattermostMe, v as updateMattermostPost } from "./client-DAIry9-2.js";
3
+ import { C as resolveDefaultGroupPolicy, _ as logTypingFailure, a as resolveMattermostMonitorInboundAccess, b as resolveAllowlistProviderRuntimeGroupPolicy$1, c as buildPreparedModelsProviderData, d as createChannelPairingController, g as logInboundDrop, l as createChannelHistoryWindow, m as listSkillCommandsForAgents, n as formatMattermostDirectMessageDropLog, o as resolveMattermostTrustedChatKind, s as DEFAULT_GROUP_HISTORY_LIMIT, t as authorizeMattermostCommandInvocation, u as createChannelMessageReplyPipeline, w as warnMissingProviderGroupPolicyFallbackOnce, x as resolveChannelMediaMaxBytes, y as registerPluginHttpRoute } from "./monitor-auth-CACk1Hos.js";
4
+ import { a as resolveInteractionCallbackPath, c as setInteractionSecret, i as createMattermostInteractionHandler, n as buildButtonProps, r as computeInteractionCallbackUrl, s as setInteractionCallbackUrl } from "./interactions-LnudXdqD.js";
5
+ import { n as normalizeMattermostAllowEntry } from "./ingress-identity-DNl4yQSc.js";
6
+ import { a as inspectMattermostAccount, c as resolveMattermostAccount, l as resolveMattermostReplyToMode, n as normalizeMattermostMessagingTarget, o as listMattermostAccountIds } from "./normalize-DoleH0bY.js";
7
+ import { _ as registerSlashCommands, a as sendMessageMattermost, c as joinMattermostVisibleContent, d as renderMattermostModelsPickerView, f as renderMattermostProviderPickerView, g as isSlashCommandsEnabled, h as cleanupSlashCommands, l as buildMattermostAllowedModelRefs, m as DEFAULT_COMMAND_SPECS, n as deactivateSlashCommands, o as resolveMattermostOpaqueTarget, p as resolveMattermostModelPickerCurrentModel, r as getSlashCommandState, s as deliverMattermostReplyPayload, t as activateSlashCommands, u as parseMattermostModelPickerContext, v as resolveCallbackUrl, y as resolveSlashCommandConfig } from "./slash-state-CPIuJQj2.js";
8
8
  import { randomUUID } from "node:crypto";
9
- import { resolveGatewayPort } from "openclaw/plugin-sdk/core";
10
- import { resolvePinnedMainDmOwnerFromAllowlist } from "openclaw/plugin-sdk/security-runtime";
9
+ import { resolveGatewayPort } from "openclaw/plugin-sdk/gateway-config-runtime";
10
+ import { resolvePinnedMainDmOwnerFromAllowlist, sanitizeUntrustedFileName } from "openclaw/plugin-sdk/security-runtime";
11
11
  import { normalizeLowercaseStringOrEmpty, normalizeOptionalString, normalizeStringEntries, normalizeTrimmedStringList, uniqueStrings } from "openclaw/plugin-sdk/string-coerce-runtime";
12
12
  import { buildChannelInboundMediaPayload, createChannelPartialDeliveryError, formatInboundEnvelope, formatInboundFromLabel, formatInboundMediaUnavailableText, formatMediaPlaceholderText, implicitMentionKindWhen, isChannelPartialDeliveryError, resolveInboundMentionDecision, resolveInboundSessionEnvelopeContext, toInboundMediaFactsWithMetadata } from "openclaw/plugin-sdk/channel-inbound";
13
13
  import { formatErrorMessage, toErrorObject } from "openclaw/plugin-sdk/error-runtime";
@@ -24,7 +24,7 @@ import { buildTtsSupplementMediaPayload, countOutboundMedia, getReplyPayloadTtsS
24
24
  import { normalizeAccountId } from "openclaw/plugin-sdk/account-id";
25
25
  import { isRecord } from "openclaw/plugin-sdk/channel-secret-basic-runtime";
26
26
  import { resolveInboundLastRouteSessionKey, resolveThreadSessionKeys } from "openclaw/plugin-sdk/routing";
27
- import { runChannelProbe, sliceUtf16Safe, truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
27
+ import { escapeRegExp, runChannelProbe, sliceUtf16Safe, truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
28
28
  import { resolveHumanDelayConfig } from "openclaw/plugin-sdk/agent-runtime";
29
29
  import { finalizeInboundContext } from "openclaw/plugin-sdk/reply-runtime";
30
30
  import { pruneMapToMaxSize } from "openclaw/plugin-sdk/collection-runtime";
@@ -175,22 +175,32 @@ function resolveThreadSessionKeys$1(params) {
175
175
  normalizeThreadId: (threadId) => threadId
176
176
  });
177
177
  }
178
+ function buildMattermostBotMentionPattern(username) {
179
+ return `(?<![a-z0-9_])@${escapeRegExp(username)}(?![a-z0-9_]|[.:-]+[a-z0-9_])`;
180
+ }
181
+ function matchesMattermostBotMention(text, botUsername) {
182
+ if (!botUsername) return false;
183
+ return new RegExp(buildMattermostBotMentionPattern(botUsername), "i").test(text);
184
+ }
178
185
  /**
179
186
  * Strip bot mention from message text while preserving newlines and
180
187
  * block-level Markdown formatting (headings, lists, blockquotes).
181
188
  */
182
189
  function normalizeMention(text, mention) {
183
190
  if (!mention) return text.trim();
184
- const escaped = mention.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
185
- const hasMentionRe = new RegExp(`@${escaped}\\b`, "i");
186
- const leadingMentionRe = new RegExp(`^([\\t ]*)@${escaped}\\b[\\t ]*`, "i");
187
- const trailingMentionRe = new RegExp(`[\\t ]*@${escaped}\\b[\\t ]*$`, "i");
191
+ const pattern = buildMattermostBotMentionPattern(mention);
192
+ const hasMentionRe = new RegExp(pattern, "i");
193
+ const leadingMentionRe = new RegExp(`^([\\t ]*)${pattern}[\\t ]*`, "i");
194
+ const trailingMentionRe = new RegExp(`[\\t ]*${pattern}[\\t ]*$`, "i");
188
195
  const normalizedLines = text.split("\n").map((line) => {
189
- const hadMention = hasMentionRe.test(line);
190
- const normalizedLine = line.replace(leadingMentionRe, "$1").replace(trailingMentionRe, "").replace(new RegExp(`@${escaped}\\b`, "gi"), "").replace(/(\S)[ \t]{2,}/g, "$1 ");
196
+ if (!hasMentionRe.test(line)) return {
197
+ text: line,
198
+ mentionOnlyBlank: false
199
+ };
200
+ const normalizedLine = line.replace(leadingMentionRe, "$1").replace(trailingMentionRe, "").replace(new RegExp(pattern, "gi"), "").replace(/(\S)[ \t]{2,}/g, "$1 ");
191
201
  return {
192
202
  text: normalizedLine,
193
- mentionOnlyBlank: hadMention && normalizedLine.trim() === ""
203
+ mentionOnlyBlank: normalizedLine.trim() === ""
194
204
  };
195
205
  });
196
206
  while (normalizedLines[0]?.mentionOnlyBlank) normalizedLines.shift();
@@ -207,6 +217,7 @@ function shouldDropEmptyMattermostBody(params) {
207
217
  //#region extensions/mattermost/src/mattermost/monitor-websocket.ts
208
218
  const MATTERMOST_WEBSOCKET_MAX_PAYLOAD_BYTES = 16 * 1024 * 1024;
209
219
  const MATTERMOST_WEBSOCKET_HANDSHAKE_TIMEOUT_MS = 3e4;
220
+ const MATTERMOST_WEBSOCKET_AUTH_TIMEOUT_MS = 3e4;
210
221
  const MattermostEventPayloadSchema = z.object({
211
222
  event: z.string().optional(),
212
223
  status: z.string().optional(),
@@ -242,6 +253,14 @@ var WebSocketClosedBeforeOpenError = class extends Error {
242
253
  this.name = "WebSocketClosedBeforeOpenError";
243
254
  }
244
255
  };
256
+ var WebSocketClosedBeforeAuthenticationError = class extends Error {
257
+ constructor(code, reason) {
258
+ super(`websocket closed before authentication completed (code ${code}) — either the bot token was rejected or the connection dropped (server restart, proxy reset); check the Mattermost bot token if this repeats`);
259
+ this.code = code;
260
+ this.reason = reason;
261
+ this.name = "WebSocketClosedBeforeAuthenticationError";
262
+ }
263
+ };
245
264
  const defaultMattermostWebSocketFactory = (url, options) => {
246
265
  const agent = createDebugProxyWebSocketAgent(resolveDebugProxySettings());
247
266
  return new WebSocket(url, {
@@ -266,6 +285,7 @@ function createMattermostConnectOnce(opts) {
266
285
  try {
267
286
  return await new Promise((resolve, reject) => {
268
287
  let opened = false;
288
+ let authenticated = false;
269
289
  let settled = false;
270
290
  let healthCheckEnabled = getBotUpdateAt != null;
271
291
  let healthCheckInFlight = false;
@@ -275,11 +295,16 @@ function createMattermostConnectOnce(opts) {
275
295
  let protocolPongTimer;
276
296
  let initialUpdateAt;
277
297
  let authenticationSeq;
298
+ let authTimer;
278
299
  const clearTimers = () => {
279
300
  if (healthCheckTimer !== void 0) {
280
301
  clearTimeout(healthCheckTimer);
281
302
  healthCheckTimer = void 0;
282
303
  }
304
+ if (authTimer !== void 0) {
305
+ clearTimeout(authTimer);
306
+ authTimer = void 0;
307
+ }
283
308
  if (protocolPingTimer !== void 0) {
284
309
  clearTimeout(protocolPingTimer);
285
310
  protocolPingTimer = void 0;
@@ -394,6 +419,13 @@ function createMattermostConnectOnce(opts) {
394
419
  }
395
420
  });
396
421
  ws.send(authPayload);
422
+ authTimer = setTimeout(() => {
423
+ authTimer = void 0;
424
+ if (settled) return;
425
+ opts.runtime.error?.("mattermost websocket authentication timed out — reconnecting");
426
+ stopHealthChecks();
427
+ ws.terminate();
428
+ }, MATTERMOST_WEBSOCKET_AUTH_TIMEOUT_MS);
397
429
  scheduleProtocolPing();
398
430
  if (getBotUpdateAt) runHealthCheck();
399
431
  });
@@ -417,6 +449,11 @@ function createMattermostConnectOnce(opts) {
417
449
  const payload = parseMattermostEventPayload(raw);
418
450
  if (!payload) return;
419
451
  if (payload.status === "OK" && payload.seq_reply === authenticationSeq) {
452
+ authenticated = true;
453
+ if (authTimer !== void 0) {
454
+ clearTimeout(authTimer);
455
+ authTimer = void 0;
456
+ }
420
457
  opts.statusSink?.(channelReadyPatch());
421
458
  return;
422
459
  }
@@ -458,10 +495,14 @@ function createMattermostConnectOnce(opts) {
458
495
  error: message || void 0
459
496
  }
460
497
  });
461
- if (opened) {
498
+ if (opened && authenticated) {
462
499
  resolveOnce();
463
500
  return;
464
501
  }
502
+ if (opened) {
503
+ rejectOnce(new WebSocketClosedBeforeAuthenticationError(code, message || void 0));
504
+ return;
505
+ }
465
506
  rejectOnce(new WebSocketClosedBeforeOpenError(code, message || void 0));
466
507
  });
467
508
  ws.on("error", (err) => {
@@ -793,33 +834,26 @@ async function buildMattermostEventPlan(monitor, params) {
793
834
  OriginatingChannel: "mattermost",
794
835
  OriginatingTo: to
795
836
  }),
796
- createReplyPlan: () => {
797
- const deliveryBarrier = createMattermostReplyDeliveryBarrier({
798
- isDirect: kind === "direct",
799
- dmRetryOptions: monitor.account.config.dmChannelRetry
800
- });
801
- return {
802
- textLimit: monitor.core.channel.text.resolveTextChunkLimit(monitor.cfg, "mattermost", monitor.account.accountId, { fallbackLimit: monitor.account.textChunkLimit ?? 4e3 }),
803
- tableMode: monitor.core.channel.text.resolveMarkdownTableMode({
804
- cfg: monitor.cfg,
805
- channel: "mattermost",
806
- accountId: monitor.account.accountId
807
- }),
808
- deliveryBarrier,
809
- replyPipeline: { typing: {
810
- start: () => monitor.resources.sendTypingIndicator(params.channelId, thread.effectiveReplyToId),
811
- onStartError: (error) => {
812
- logTypingFailure({
813
- log: monitor.logDebugMessage,
814
- channel: "mattermost",
815
- target: params.channelId,
816
- error
817
- });
818
- }
819
- } },
820
- replyOptions: { disableBlockStreaming: typeof monitor.account.blockStreaming === "boolean" ? !monitor.account.blockStreaming : void 0 }
821
- };
822
- }
837
+ createReplyPlan: () => ({
838
+ textLimit: monitor.core.channel.text.resolveTextChunkLimit(monitor.cfg, "mattermost", monitor.account.accountId, { fallbackLimit: monitor.account.textChunkLimit ?? 4e3 }),
839
+ tableMode: monitor.core.channel.text.resolveMarkdownTableMode({
840
+ cfg: monitor.cfg,
841
+ channel: "mattermost",
842
+ accountId: monitor.account.accountId
843
+ }),
844
+ replyPipeline: { typing: {
845
+ start: () => monitor.resources.sendTypingIndicator(params.channelId, thread.effectiveReplyToId),
846
+ onStartError: (error) => {
847
+ logTypingFailure({
848
+ log: monitor.logDebugMessage,
849
+ channel: "mattermost",
850
+ target: params.channelId,
851
+ error
852
+ });
853
+ }
854
+ } },
855
+ replyOptions: { disableBlockStreaming: typeof monitor.account.blockStreaming === "boolean" ? !monitor.account.blockStreaming : void 0 }
856
+ })
823
857
  };
824
858
  }
825
859
  //#endregion
@@ -894,7 +928,7 @@ function registerMattermostInteractions(params) {
894
928
  dropLabel: "interaction dispatch"
895
929
  });
896
930
  if (!eventPlan) return;
897
- const { channelDisplay, kind, route, thread, to } = eventPlan;
931
+ const { channelDisplay, channelId, kind, route, thread, to } = eventPlan;
898
932
  const bodyText = `[Button click: user @${button.userName} selected "${button.actionName}"]`;
899
933
  const ctxPayload = eventPlan.finalizeContext({
900
934
  Body: bodyText,
@@ -908,7 +942,7 @@ function registerMattermostInteractions(params) {
908
942
  WasMentioned: true,
909
943
  CommandAuthorized: false
910
944
  });
911
- const { deliveryBarrier, replyOptions, replyPipeline, tableMode, textLimit } = eventPlan.createReplyPlan();
945
+ const { replyOptions, replyPipeline, tableMode, textLimit } = eventPlan.createReplyPlan();
912
946
  await core.channel.inbound.dispatch({
913
947
  cfg,
914
948
  channel: "mattermost",
@@ -926,7 +960,7 @@ function registerMattermostInteractions(params) {
926
960
  core,
927
961
  cfg,
928
962
  payload,
929
- to,
963
+ channelId,
930
964
  accountId: account.accountId,
931
965
  agentId: route.agentId,
932
966
  replyToId: resolveMattermostInteractionReplyRootId({
@@ -938,8 +972,7 @@ function registerMattermostInteractions(params) {
938
972
  }),
939
973
  textLimit,
940
974
  tableMode,
941
- sendMessage: sendMessageMattermost,
942
- onDmChannelResolution: deliveryBarrier.trackDmChannelResolution
975
+ sendMessage: sendMessageMattermost
943
976
  });
944
977
  if (result.visibleReplySent) runtime.log?.(`delivered button-click reply to ${to}`);
945
978
  return result;
@@ -949,11 +982,7 @@ function registerMattermostInteractions(params) {
949
982
  }
950
983
  },
951
984
  replyPipeline,
952
- dispatcherOptions: {
953
- resolveFollowupAdmissionBarrierTimeoutPolicy: deliveryBarrier.resolveTimeoutPolicy,
954
- onDeliverySettled: deliveryBarrier.markDeliverySettled,
955
- humanDelay: resolveHumanDelayConfig(cfg, route.agentId)
956
- },
985
+ dispatcherOptions: { humanDelay: resolveHumanDelayConfig(cfg, route.agentId) },
957
986
  replyOptions
958
987
  });
959
988
  },
@@ -963,7 +992,6 @@ function registerMattermostInteractions(params) {
963
992
  source: "mattermost-interactions",
964
993
  accountId: account.accountId,
965
994
  log: (message) => runtime.log?.(message),
966
- replaceExisting: true,
967
995
  throwOnFailure: true
968
996
  });
969
997
  }
@@ -973,7 +1001,7 @@ function createMattermostModelPickerInteractionHandler(monitor) {
973
1001
  const { account, cfg, core, pairing, resources, runtime } = monitor;
974
1002
  const { resolveChannelInfo, updateModelPickerPost } = resources;
975
1003
  const runModelPickerCommand = async (params) => {
976
- const { channelDisplay, kind, roomLabel, route, thread, to } = params.eventPlan;
1004
+ const { channelDisplay, channelId, kind, roomLabel, route, thread } = params.eventPlan;
977
1005
  const fromLabel = kind === "direct" ? `Mattermost DM from ${params.senderName}` : `Mattermost message in ${roomLabel} from ${params.senderName}`;
978
1006
  const ctxPayload = params.eventPlan.finalizeContext({
979
1007
  Body: params.commandText,
@@ -989,7 +1017,7 @@ function createMattermostModelPickerInteractionHandler(monitor) {
989
1017
  CommandAuthorized: params.commandAuthorized,
990
1018
  CommandSource: "native"
991
1019
  });
992
- const { deliveryBarrier, replyOptions, replyPipeline, tableMode, textLimit } = params.eventPlan.createReplyPlan();
1020
+ const { replyOptions, replyPipeline, tableMode, textLimit } = params.eventPlan.createReplyPlan();
993
1021
  await core.channel.inbound.dispatch({
994
1022
  cfg,
995
1023
  channel: "mattermost",
@@ -1011,7 +1039,7 @@ function createMattermostModelPickerInteractionHandler(monitor) {
1011
1039
  core,
1012
1040
  cfg,
1013
1041
  payload: trimmedPayload,
1014
- to,
1042
+ channelId,
1015
1043
  accountId: account.accountId,
1016
1044
  agentId: route.agentId,
1017
1045
  replyToId: resolveMattermostInteractionReplyRootId({
@@ -1023,8 +1051,7 @@ function createMattermostModelPickerInteractionHandler(monitor) {
1023
1051
  }),
1024
1052
  textLimit,
1025
1053
  tableMode: "off",
1026
- sendMessage: sendMessageMattermost,
1027
- onDmChannelResolution: deliveryBarrier.trackDmChannelResolution
1054
+ sendMessage: sendMessageMattermost
1028
1055
  });
1029
1056
  },
1030
1057
  onError: (err, info) => {
@@ -1032,10 +1059,6 @@ function createMattermostModelPickerInteractionHandler(monitor) {
1032
1059
  }
1033
1060
  },
1034
1061
  replyPipeline,
1035
- dispatcherOptions: {
1036
- resolveFollowupAdmissionBarrierTimeoutPolicy: deliveryBarrier.resolveTimeoutPolicy,
1037
- onDeliverySettled: deliveryBarrier.markDeliverySettled
1038
- },
1039
1062
  replyOptions
1040
1063
  });
1041
1064
  };
@@ -1097,7 +1120,7 @@ function createMattermostModelPickerInteractionHandler(monitor) {
1097
1120
  agentId: eventPlan.route.agentId,
1098
1121
  sessionKey: eventPlan.thread.sessionKey
1099
1122
  };
1100
- const data = await buildModelsProviderData(cfg, eventPlan.route.agentId);
1123
+ const data = await buildPreparedModelsProviderData(cfg, eventPlan.route.agentId);
1101
1124
  if (data.providers.length === 0) return await updatePickerPost("No models available.");
1102
1125
  if (pickerState.action === "providers" || pickerState.action === "back") {
1103
1126
  const currentModel = resolveMattermostModelPickerCurrentModel({
@@ -1224,9 +1247,11 @@ function formatMattermostInboundMediaText(params) {
1224
1247
  const materializedCount = params.materializedMedia.filter((media) => Boolean(media.path) || Boolean(media.url)).length;
1225
1248
  const unavailableCount = Math.max(0, params.nativeMedia.length - materializedCount);
1226
1249
  if (unavailableCount === 0) return params.body;
1250
+ const unavailableFileNames = params.materializedMedia.filter((media) => !media.path && !media.url && media.fileName).map((media) => sanitizeUntrustedFileName(media.fileName ?? "", "")).filter(Boolean).join(", ");
1251
+ const fileNameNotice = unavailableFileNames ? ` ${JSON.stringify(truncateUtf16Safe(unavailableFileNames, 512))}` : "";
1227
1252
  return formatInboundMediaUnavailableText({
1228
1253
  body: params.body,
1229
- notice: `[mattermost ${unavailableCount > 1 ? `${unavailableCount} attachments` : "attachment"} unavailable]`
1254
+ notice: `[mattermost ${unavailableCount > 1 ? `${unavailableCount} attachments` : "attachment"} unavailable]${fileNameNotice}`
1230
1255
  });
1231
1256
  }
1232
1257
  const CHANNEL_CACHE_TTL_MS = 5 * 6e4;
@@ -1282,18 +1307,22 @@ function createMattermostMonitorResources(params) {
1282
1307
  out.push({
1283
1308
  path: saved.path,
1284
1309
  contentType,
1310
+ ...saved.fileName ? { fileName: saved.fileName } : {},
1285
1311
  kind: mediaKindFromMime(contentType) ?? "unknown"
1286
1312
  });
1287
1313
  } catch (err) {
1288
1314
  logger.debug?.(`mattermost: failed to download file ${fileId}: ${String(err)}`);
1289
- let contentType;
1315
+ let info;
1290
1316
  try {
1291
- contentType = (await client.request(`/files/${fileId}/info`)).mime_type?.trim() || void 0;
1317
+ info = await client.request(`/files/${fileId}/info`);
1292
1318
  } catch (infoErr) {
1293
1319
  logger.debug?.(`mattermost: failed to resolve metadata for file ${fileId}: ${String(infoErr)}`);
1294
1320
  }
1321
+ const contentType = info?.mime_type?.trim() || void 0;
1322
+ const fileName = info?.name?.trim();
1295
1323
  out.push({
1296
1324
  contentType,
1325
+ ...fileName ? { fileName } : {},
1297
1326
  kind: mediaKindFromMime(contentType) ?? "unknown"
1298
1327
  });
1299
1328
  }
@@ -1719,9 +1748,9 @@ async function deliverMattermostReplyWithDraftPreview(params) {
1719
1748
  confirmedPreviewDelivery = previewFinalResolution?.confirmedDelivery;
1720
1749
  previewFinalDeliveryText = previewFinalResolution?.deliveryText;
1721
1750
  previewFinalTextAlreadyDelivered = previewFinalResolution?.alreadyDelivered === true && payload.isError !== true;
1722
- useConfirmedPreviewAsWholeFinal = previewFinalTextAlreadyDelivered && !resolveSendableOutboundReplyParts(payload).hasMedia;
1751
+ useConfirmedPreviewAsWholeFinal = previewFinalTextAlreadyDelivered && !resolveSendableOutboundReplyParts(payload).hasMedia && !payload.presentation;
1723
1752
  const previewFinalText = previewFinalResolution?.editText;
1724
- if (hasMedia && !ttsSupplement || typeof previewFinalText !== "string" || payload.isError || !canFinalizeMattermostPreviewInPlace({
1753
+ if (hasMedia && !ttsSupplement || typeof previewFinalText !== "string" || payload.isError || payload.presentation || !canFinalizeMattermostPreviewInPlace({
1725
1754
  kind: params.kind,
1726
1755
  previewRootId: params.effectiveReplyToId,
1727
1756
  threadRootId: params.effectiveReplyToId,
@@ -1867,7 +1896,7 @@ async function dispatchMattermostInboundTurn(monitor, params) {
1867
1896
  const { channelHistories, ctxPayload, eventPlan, historyKey, historyLimit, pinnedMainDmOwner, post, rawText, turnAdoptionLifecycle } = params;
1868
1897
  const { channelId, kind, route, senderId, thread, to } = eventPlan;
1869
1898
  const { effectiveReplyToId } = thread;
1870
- const { deliveryBarrier, replyOptions, replyPipeline: baseReplyPipeline, tableMode, textLimit } = eventPlan.createReplyPlan();
1899
+ const { replyOptions, replyPipeline: baseReplyPipeline, tableMode, textLimit } = eventPlan.createReplyPlan();
1871
1900
  const chunkMode = core.channel.text.resolveChunkMode(cfg, "mattermost", account.accountId);
1872
1901
  const { onModelSelected, typingCallbacks, resolveResponsePrefix, ...dispatcherPipeline } = createChannelMessageReplyPipeline({
1873
1902
  cfg,
@@ -1989,8 +2018,6 @@ async function dispatchMattermostInboundTurn(monitor, params) {
1989
2018
  };
1990
2019
  const dispatcherOptions = {
1991
2020
  ...dispatcherPipeline,
1992
- resolveFollowupAdmissionBarrierTimeoutPolicy: deliveryBarrier.resolveTimeoutPolicy,
1993
- onDeliverySettled: deliveryBarrier.markDeliverySettled,
1994
2021
  humanDelay: resolveHumanDelayConfig(cfg, route.agentId),
1995
2022
  typingCallbacks
1996
2023
  };
@@ -2030,7 +2057,7 @@ async function dispatchMattermostInboundTurn(monitor, params) {
2030
2057
  core,
2031
2058
  cfg,
2032
2059
  payload: resolvedPayload,
2033
- to,
2060
+ channelId,
2034
2061
  accountId: account.accountId,
2035
2062
  agentId: route.agentId,
2036
2063
  replyToId: resolveMattermostReplyRootId({
@@ -2040,8 +2067,7 @@ async function dispatchMattermostInboundTurn(monitor, params) {
2040
2067
  }),
2041
2068
  textLimit,
2042
2069
  tableMode,
2043
- sendMessage: sendMessageMattermost,
2044
- onDmChannelResolution: deliveryBarrier.trackDmChannelResolution
2070
+ sendMessage: sendMessageMattermost
2045
2071
  }).catch((error) => {
2046
2072
  if (isChannelPartialDeliveryError(error)) markThreadParticipation();
2047
2073
  throw error;
@@ -2214,7 +2240,7 @@ function createMattermostPostHandler(monitor) {
2214
2240
  const { account, botUserId, botUsername, cfg, core, groupPolicy, pairing, resources } = monitor;
2215
2241
  const { resolveMattermostMedia, resolveUserInfo } = resources;
2216
2242
  const channelHistories = /* @__PURE__ */ new Map();
2217
- const historyLimit = Math.max(0, cfg.messages?.groupChat?.historyLimit ?? DEFAULT_GROUP_HISTORY_LIMIT);
2243
+ const historyLimit = Math.max(0, account.config.historyLimit ?? cfg.messages?.groupChat?.historyLimit ?? DEFAULT_GROUP_HISTORY_LIMIT);
2218
2244
  return async (post, payload, turnAdoptionLifecycle, messageIds) => {
2219
2245
  const channelId = post.channel_id ?? payload.data?.channel_id ?? payload.broadcast?.channel_id;
2220
2246
  if (!channelId) {
@@ -2313,7 +2339,7 @@ function createMattermostPostHandler(monitor) {
2313
2339
  });
2314
2340
  monitor.logVerboseMessage(`mattermost: pairing request sender=${senderId} created=${created}`);
2315
2341
  if (created) try {
2316
- await sendMessageMattermost(`user:${senderId}`, core.channel.pairing.buildPairingReply({
2342
+ await sendMessageMattermost(`channel:${channelId}`, core.channel.pairing.buildPairingReply({
2317
2343
  channel: "mattermost",
2318
2344
  idLine: `Your Mattermost user id: ${senderId}`,
2319
2345
  code
@@ -2368,7 +2394,7 @@ function createMattermostPostHandler(monitor) {
2368
2394
  return;
2369
2395
  }
2370
2396
  const mentionRegexes = core.channel.mentions.buildMentionRegexes(cfg, route.agentId);
2371
- const wasMentioned = kind !== "direct" && ((botUsername ? normalizeLowercaseStringOrEmpty(rawText).includes(`@${normalizeLowercaseStringOrEmpty(botUsername)}`) : false) || core.channel.mentions.matchesMentionPatterns(rawText, mentionRegexes));
2397
+ const wasMentioned = kind !== "direct" && (matchesMattermostBotMention(rawText, botUsername) || core.channel.mentions.matchesMentionPatterns(rawText, mentionRegexes));
2372
2398
  const oncharEnabled = account.chatmode === "onchar" && kind !== "direct";
2373
2399
  const oncharPrefixes = oncharEnabled ? resolveOncharPrefixes(account.oncharPrefixes) : [];
2374
2400
  const oncharResult = oncharEnabled ? stripOncharPrefix(rawText, oncharPrefixes) : {
@@ -2842,7 +2868,7 @@ async function monitorMattermostProvider(opts = {}) {
2842
2868
  };
2843
2869
  const mediaMaxBytes = resolveChannelMediaMaxBytes({
2844
2870
  cfg,
2845
- resolveChannelLimitMb: () => void 0,
2871
+ resolveChannelLimitMb: () => account.config.mediaMaxMb,
2846
2872
  accountId: account.accountId
2847
2873
  }) ?? 8 * 1024 * 1024;
2848
2874
  const { groupPolicy, providerMissingFallbackApplied } = resolveAllowlistProviderRuntimeGroupPolicy$1({
@@ -197,19 +197,6 @@ async function createMattermostDirectChannel(client, userIds, signal, timeoutMs)
197
197
  timeoutMs
198
198
  });
199
199
  }
200
- const DM_REPLY_DELIVERY_BARRIER_SLACK_MS = 6e4;
201
- /** Covers DM creation retries without extending channel-delivery stalls. */
202
- function resolveMattermostReplyDeliveryBarrierTimeoutMs(params) {
203
- if (!params.isDirect) return;
204
- const deliveryCount = Object.values(params.queuedCounts).reduce((sum, count) => sum + count, 0);
205
- if (deliveryCount === 0) return;
206
- const maxRetries = params.dmRetryOptions?.maxRetries ?? 3;
207
- const maxDelayMs = params.dmRetryOptions?.maxDelayMs ?? 1e4;
208
- const timeoutMs = params.dmRetryOptions?.timeoutMs ?? 3e4;
209
- const perDeliveryTimeoutMs = (maxRetries + 1) * timeoutMs + maxRetries * maxDelayMs + DM_REPLY_DELIVERY_BARRIER_SLACK_MS;
210
- const totalTimeoutMs = perDeliveryTimeoutMs * deliveryCount + Math.max(0, params.humanDelayBudgetMs ?? 0);
211
- return resolveTimerTimeoutMs(Number.isFinite(totalTimeoutMs) ? totalTimeoutMs : Number.MAX_SAFE_INTEGER, perDeliveryTimeoutMs);
212
- }
213
200
  const RETRYABLE_NETWORK_ERROR_CODES = /* @__PURE__ */ new Set([
214
201
  "ECONNRESET",
215
202
  "ECONNREFUSED",
@@ -382,4 +369,4 @@ async function uploadMattermostFile(client, params) {
382
369
  return info;
383
370
  }
384
371
  //#endregion
385
- export { resolveMattermostReplyDeliveryBarrierTimeoutMs as _, createMattermostPost as a, uploadMattermostFile as b, fetchMattermostChannelByName as c, fetchMattermostUser as d, fetchMattermostUserByUsername as f, readMattermostError as g, parseMattermostApiStatus as h, createMattermostDirectChannelWithRetry as i, fetchMattermostChannelPosts as l, normalizeMattermostBaseUrl as m, buildMattermostApiUrl as n, deleteMattermostPost as o, fetchMattermostUserTeams as p, createMattermostClient as r, fetchMattermostChannel as s, MattermostPostSchema as t, fetchMattermostMe as u, sendMattermostTyping as v, updateMattermostPost as y };
372
+ export { sendMattermostTyping as _, createMattermostPost as a, fetchMattermostChannelByName as c, fetchMattermostUser as d, fetchMattermostUserByUsername as f, readMattermostError as g, parseMattermostApiStatus as h, createMattermostDirectChannelWithRetry as i, fetchMattermostChannelPosts as l, normalizeMattermostBaseUrl as m, buildMattermostApiUrl as n, deleteMattermostPost as o, fetchMattermostUserTeams as p, createMattermostClient as r, fetchMattermostChannel as s, MattermostPostSchema as t, fetchMattermostMe as u, updateMattermostPost as v, uploadMattermostFile as y };
@@ -0,0 +1,27 @@
1
+ import { normalizeLowercaseStringOrEmpty } from "openclaw/plugin-sdk/string-coerce-runtime";
2
+ import { parseAccessGroupAllowFromEntry } from "openclaw/plugin-sdk/access-groups";
3
+ const mattermostIngressIdentity = {
4
+ key: "sender-id",
5
+ authentication: "verified",
6
+ normalize: normalizeMattermostAllowEntry,
7
+ aliases: [{
8
+ key: "sender-name",
9
+ kind: "plugin:mattermost-user-name",
10
+ normalizeEntry: normalizeMattermostAllowEntry,
11
+ normalizeSubject: normalizeMattermostAllowEntry,
12
+ authentication: "mutable"
13
+ }],
14
+ isWildcardEntry: (entry) => normalizeMattermostAllowEntry(entry) === "*",
15
+ resolveEntryId: ({ entryIndex, fieldKey }) => `mattermost-entry-${entryIndex + 1}:${fieldKey === "sender-name" ? "name" : "user"}`
16
+ };
17
+ function normalizeMattermostAllowEntry(entry) {
18
+ const trimmed = entry.trim();
19
+ if (!trimmed) return "";
20
+ if (trimmed === "*") return "*";
21
+ const accessGroupName = parseAccessGroupAllowFromEntry(trimmed);
22
+ if (accessGroupName) return `accessGroup:${accessGroupName}`;
23
+ const normalized = trimmed.replace(/^(mattermost|user):/i, "").replace(/^@/, "").trim();
24
+ return normalized ? normalizeLowercaseStringOrEmpty(normalized) : "";
25
+ }
26
+ //#endregion
27
+ export { normalizeMattermostAllowEntry as n, mattermostIngressIdentity as t };
@@ -1,8 +1,8 @@
1
1
  import { t as getMattermostRuntime } from "./runtime-CNB4YGqJ.js";
2
- import { y as updateMattermostPost } from "./client-B_hd-kwM.js";
3
- import { C as resolveClientIp, m as isTrustedProxyAddress, y as readRequestBodyWithLimit } from "./monitor-auth-CVd_4FPD.js";
2
+ import { v as updateMattermostPost } from "./client-DAIry9-2.js";
3
+ import { S as resolveClientIp, p as isTrustedProxyAddress, v as readRequestBodyWithLimit } from "./monitor-auth-CACk1Hos.js";
4
4
  import { createHmac } from "node:crypto";
5
- import { resolveGatewayPort } from "openclaw/plugin-sdk/core";
5
+ import { resolveGatewayPort } from "openclaw/plugin-sdk/gateway-config-runtime";
6
6
  import { safeEqualSecret } from "openclaw/plugin-sdk/security-runtime";
7
7
  import { normalizeOptionalString, normalizeStringifiedOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
8
8
  //#region extensions/mattermost/src/mattermost/interactions.ts
@@ -1,44 +1,22 @@
1
- import { isTrustedProxyAddress, resolveClientIp } from "openclaw/plugin-sdk/core";
2
- import { normalizeLowercaseStringOrEmpty, uniqueStrings } from "openclaw/plugin-sdk/string-coerce-runtime";
1
+ import { n as normalizeMattermostAllowEntry, t as mattermostIngressIdentity } from "./ingress-identity-DNl4yQSc.js";
2
+ import { uniqueStrings } from "openclaw/plugin-sdk/string-coerce-runtime";
3
3
  import { logInboundDrop } from "openclaw/plugin-sdk/channel-inbound";
4
4
  import { resolveAllowlistMatchSimple } from "openclaw/plugin-sdk/allow-from";
5
5
  import { createChannelPairingController } from "openclaw/plugin-sdk/channel-pairing";
6
6
  import { createChannelMessageReplyPipeline } from "openclaw/plugin-sdk/channel-outbound";
7
7
  import { logTypingFailure } from "openclaw/plugin-sdk/channel-feedback";
8
8
  import { listSkillCommandsForAgents } from "openclaw/plugin-sdk/command-auth-native";
9
- import { buildModelsProviderData } from "openclaw/plugin-sdk/models-provider-runtime";
9
+ import { buildPreparedModelsProviderData } from "openclaw/plugin-sdk/models-provider-runtime";
10
10
  import { isDangerousNameMatchingEnabled } from "openclaw/plugin-sdk/dangerous-name-runtime";
11
11
  import { resolveAllowlistProviderRuntimeGroupPolicy as resolveAllowlistProviderRuntimeGroupPolicy$1, resolveDefaultGroupPolicy, warnMissingProviderGroupPolicyFallbackOnce } from "openclaw/plugin-sdk/runtime-group-policy";
12
- import { resolveChannelMediaMaxBytes } from "openclaw/plugin-sdk/media-runtime";
12
+ import { resolveChannelMediaMaxBytes as resolveChannelMediaMaxBytes$1 } from "openclaw/plugin-sdk/account-helpers";
13
13
  import { loadOutboundMediaFromUrl } from "openclaw/plugin-sdk/outbound-media";
14
14
  import { DEFAULT_GROUP_HISTORY_LIMIT, createChannelHistoryWindow } from "openclaw/plugin-sdk/reply-history";
15
15
  import { registerPluginHttpRoute } from "openclaw/plugin-sdk/webhook-targets";
16
16
  import { isRequestBodyLimitError, readRequestBodyWithLimit } from "openclaw/plugin-sdk/webhook-ingress";
17
- import { parseAccessGroupAllowFromEntry } from "openclaw/plugin-sdk/access-groups";
17
+ import { isTrustedProxyAddress, resolveClientIp } from "openclaw/plugin-sdk/core";
18
18
  import { resolveStableChannelMessageIngress } from "openclaw/plugin-sdk/channel-ingress-runtime";
19
19
  //#region extensions/mattermost/src/mattermost/monitor-auth.ts
20
- const mattermostIngressIdentity = {
21
- key: "sender-id",
22
- normalize: normalizeMattermostAllowEntry,
23
- aliases: [{
24
- key: "sender-name",
25
- kind: "plugin:mattermost-user-name",
26
- normalizeEntry: normalizeMattermostAllowEntry,
27
- normalizeSubject: normalizeMattermostAllowEntry,
28
- dangerous: true
29
- }],
30
- isWildcardEntry: (entry) => normalizeMattermostAllowEntry(entry) === "*",
31
- resolveEntryId: ({ entryIndex, fieldKey }) => `mattermost-entry-${entryIndex + 1}:${fieldKey === "sender-name" ? "name" : "user"}`
32
- };
33
- function normalizeMattermostAllowEntry(entry) {
34
- const trimmed = entry.trim();
35
- if (!trimmed) return "";
36
- if (trimmed === "*") return "*";
37
- const accessGroupName = parseAccessGroupAllowFromEntry(trimmed);
38
- if (accessGroupName) return `accessGroup:${accessGroupName}`;
39
- const normalized = trimmed.replace(/^(mattermost|user):/i, "").replace(/^@/, "").trim();
40
- return normalized ? normalizeLowercaseStringOrEmpty(normalized) : "";
41
- }
42
20
  function normalizeMattermostAllowList(entries) {
43
21
  return uniqueStrings(entries.map((entry) => normalizeMattermostAllowEntry(String(entry))).filter(Boolean));
44
22
  }
@@ -181,4 +159,4 @@ async function authorizeMattermostCommandInvocation(params) {
181
159
  };
182
160
  }
183
161
  //#endregion
184
- export { resolveClientIp as C, resolveChannelMediaMaxBytes as S, warnMissingProviderGroupPolicyFallbackOnce as T, logInboundDrop as _, normalizeMattermostAllowList as a, registerPluginHttpRoute as b, DEFAULT_GROUP_HISTORY_LIMIT as c, createChannelMessageReplyPipeline as d, createChannelPairingController as f, loadOutboundMediaFromUrl as g, listSkillCommandsForAgents as h, normalizeMattermostAllowEntry as i, buildModelsProviderData as l, isTrustedProxyAddress as m, formatMattermostDirectMessageDropLog as n, resolveMattermostMonitorInboundAccess as o, isRequestBodyLimitError as p, isMattermostSenderAllowed as r, resolveMattermostTrustedChatKind as s, authorizeMattermostCommandInvocation as t, createChannelHistoryWindow as u, logTypingFailure as v, resolveDefaultGroupPolicy as w, resolveAllowlistProviderRuntimeGroupPolicy$1 as x, readRequestBodyWithLimit as y };
162
+ export { resolveDefaultGroupPolicy as C, resolveClientIp as S, logTypingFailure as _, resolveMattermostMonitorInboundAccess as a, resolveAllowlistProviderRuntimeGroupPolicy$1 as b, buildPreparedModelsProviderData as c, createChannelPairingController as d, isRequestBodyLimitError as f, logInboundDrop as g, loadOutboundMediaFromUrl as h, normalizeMattermostAllowList as i, createChannelHistoryWindow as l, listSkillCommandsForAgents as m, formatMattermostDirectMessageDropLog as n, resolveMattermostTrustedChatKind as o, isTrustedProxyAddress as p, isMattermostSenderAllowed as r, DEFAULT_GROUP_HISTORY_LIMIT as s, authorizeMattermostCommandInvocation as t, createChannelMessageReplyPipeline as u, readRequestBodyWithLimit as v, warnMissingProviderGroupPolicyFallbackOnce as w, resolveChannelMediaMaxBytes$1 as x, registerPluginHttpRoute as y };