@openclaw/mattermost 2026.8.1-beta.2 → 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.
@@ -1,4 +1,4 @@
1
- import { a as MattermostChannelConfigSchema, c as mattermostConfigAdapter, l as mattermostMeta, n as mattermostSetupWizard, o as describeMattermostAccount, r as mattermostSetupContract, s as isMattermostConfigured, t as mattermostPlugin } from "./channel-plugin-runtime-Dxt8Zv1j.js";
1
+ import { a as MattermostChannelConfigSchema, c as mattermostConfigAdapter, l as mattermostMeta, n as mattermostSetupWizard, o as describeMattermostAccount, r as mattermostSetupContract, s as isMattermostConfigured, t as mattermostPlugin } from "./channel-plugin-runtime-C_mWt_83.js";
2
2
  import { t as resolveMattermostGatewayAuthBypassPaths } from "./gateway-auth-bypass-B93t91oq.js";
3
3
  //#region extensions/mattermost/src/channel.setup.ts
4
4
  const mattermostSetupPlugin = {
@@ -559,7 +559,7 @@ const mattermostSetupWizard = {
559
559
  };
560
560
  //#endregion
561
561
  //#region extensions/mattermost/src/channel.ts
562
- const loadMattermostChannelRuntime = createLazyRuntimeModule(() => import("./channel.runtime-FKnzxYBR.js"));
562
+ const loadMattermostChannelRuntime = createLazyRuntimeModule(() => import("./channel.runtime-CpQzh8-1.js"));
563
563
  function buildMattermostPresentationButtons(presentation) {
564
564
  return presentation.blocks.filter((block) => block.type === "buttons").map((block) => block.buttons.flatMap((button) => {
565
565
  if (button.action) return [];
@@ -604,6 +604,7 @@ const mattermostSecurityAdapter = createRestrictSendersChannelSecurity({
604
604
  openScope: "any member",
605
605
  groupPolicyPath: "channels.mattermost.groupPolicy",
606
606
  groupAllowFromPath: "channels.mattermost.groupAllowFrom",
607
+ findingTitle: "Mattermost security warning",
607
608
  policyPathSuffix: "dmPolicy",
608
609
  normalizeDmEntry: (raw) => normalizeMattermostAllowEntry(raw)
609
610
  });
@@ -723,6 +724,7 @@ async function listMattermostDirectoryPeers(params) {
723
724
  return (await loadMattermostChannelRuntime()).listMattermostDirectoryPeers(params);
724
725
  }
725
726
  const mattermostMessageActions = {
727
+ providerOwnedReadGates: ["read"],
726
728
  describeMessageTool: describeMattermostMessageTool,
727
729
  extractToolSend: ({ args }) => extractMattermostToolSend(args),
728
730
  extractToolSendResult: ({ result, send }) => extractMattermostToolSendResult(result, send),
@@ -952,9 +954,19 @@ function resolveMattermostSendAttachmentMedia(params) {
952
954
  if (attachmentMedia.mediaUrls.length > 1) throw new Error("Mattermost send supports one attachment per message; split multiple mediaUrls or attachments[] entries into separate sends.");
953
955
  return attachmentMedia.mediaUrls[0];
954
956
  }
957
+ function toMattermostOutboundResult(result) {
958
+ const { channelId, ...delivery } = result;
959
+ return {
960
+ ...delivery,
961
+ target: {
962
+ kind: "channel",
963
+ id: channelId
964
+ }
965
+ };
966
+ }
955
967
  function createMattermostDeliveryProgressReporter(onDeliveryResult) {
956
968
  return onDeliveryResult ? async (result) => {
957
- await onDeliveryResult(attachChannelToResult("mattermost", result));
969
+ await onDeliveryResult(attachChannelToResult("mattermost", toMattermostOutboundResult(result)));
958
970
  } : void 0;
959
971
  }
960
972
  const mattermostOutbound = {
@@ -1001,7 +1013,7 @@ const mattermostOutbound = {
1001
1013
  ...ctx.payload,
1002
1014
  mediaUrl: ctx.payload.mediaUrl ?? ctx.mediaUrl
1003
1015
  }).map((url) => url.trim()).find(Boolean);
1004
- return attachChannelToResult("mattermost", await (await loadMattermostChannelRuntime()).sendMessageMattermost(ctx.to, ctx.payload.text ?? ctx.text, {
1016
+ return attachChannelToResult("mattermost", toMattermostOutboundResult(await (await loadMattermostChannelRuntime()).sendMessageMattermost(ctx.to, ctx.payload.text ?? ctx.text, {
1005
1017
  cfg: ctx.cfg,
1006
1018
  accountId: ctx.accountId ?? void 0,
1007
1019
  mediaUrl,
@@ -1013,7 +1025,7 @@ const mattermostOutbound = {
1013
1025
  buttons: buttons?.length ? buttons : void 0,
1014
1026
  attachmentText,
1015
1027
  onDeliveryResult: createMattermostDeliveryProgressReporter(ctx.onDeliveryResult)
1016
- }));
1028
+ })));
1017
1029
  }
1018
1030
  return await sendTextMediaPayload({
1019
1031
  channel: "mattermost",
@@ -1034,13 +1046,13 @@ const mattermostOutbound = {
1034
1046
  },
1035
1047
  ...createAttachedChannelResultAdapter({
1036
1048
  channel: "mattermost",
1037
- sendText: async ({ cfg, to, text, accountId, replyToId, threadId, onDeliveryResult }) => await (await loadMattermostChannelRuntime()).sendMessageMattermost(to, text, {
1049
+ sendText: async ({ cfg, to, text, accountId, replyToId, threadId, onDeliveryResult }) => toMattermostOutboundResult(await (await loadMattermostChannelRuntime()).sendMessageMattermost(to, text, {
1038
1050
  cfg,
1039
1051
  accountId: accountId ?? void 0,
1040
1052
  replyToId: replyToId ?? (threadId != null ? String(threadId) : void 0),
1041
1053
  onDeliveryResult: createMattermostDeliveryProgressReporter(onDeliveryResult)
1042
- }),
1043
- sendMedia: async ({ cfg, to, text, mediaUrl, mediaAccess, mediaLocalRoots, mediaReadFile, accountId, replyToId, threadId, onDeliveryResult }) => await (await loadMattermostChannelRuntime()).sendMessageMattermost(to, text, {
1054
+ })),
1055
+ sendMedia: async ({ cfg, to, text, mediaUrl, mediaAccess, mediaLocalRoots, mediaReadFile, accountId, replyToId, threadId, onDeliveryResult }) => toMattermostOutboundResult(await (await loadMattermostChannelRuntime()).sendMessageMattermost(to, text, {
1044
1056
  cfg,
1045
1057
  accountId: accountId ?? void 0,
1046
1058
  mediaUrl,
@@ -1050,7 +1062,7 @@ const mattermostOutbound = {
1050
1062
  requireMediaUpload: requiresMattermostMediaUpload(mediaUrl) ? true : void 0,
1051
1063
  replyToId: replyToId ?? (threadId != null ? String(threadId) : void 0),
1052
1064
  onDeliveryResult: createMattermostDeliveryProgressReporter(onDeliveryResult)
1053
- })
1065
+ }))
1054
1066
  })
1055
1067
  };
1056
1068
  const mattermostMessageAdapter = createChannelMessageAdapterFromOutbound({
@@ -1,2 +1,2 @@
1
- import { t as mattermostPlugin } from "./channel-plugin-runtime-Dxt8Zv1j.js";
1
+ import { t as mattermostPlugin } from "./channel-plugin-runtime-C_mWt_83.js";
2
2
  export { mattermostPlugin };
@@ -3,8 +3,8 @@ import { a as createMattermostPost, d as fetchMattermostUser, g as readMattermos
3
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
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
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-Dxt8Zv1j.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-DUowGLl4.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";
8
8
  import { randomUUID } from "node:crypto";
9
9
  import { resolveGatewayPort } from "openclaw/plugin-sdk/core";
10
10
  import { resolvePinnedMainDmOwnerFromAllowlist } from "openclaw/plugin-sdk/security-runtime";
@@ -24,9 +24,9 @@ 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
28
  import { resolveHumanDelayConfig } from "openclaw/plugin-sdk/agent-runtime";
28
29
  import { finalizeInboundContext } from "openclaw/plugin-sdk/reply-runtime";
29
- import { runChannelProbe, sliceUtf16Safe, truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
30
30
  import { pruneMapToMaxSize } from "openclaw/plugin-sdk/collection-runtime";
31
31
  import { channelReadyPatch, isLoopbackHost } from "openclaw/plugin-sdk/gateway-runtime";
32
32
  import { captureWsEvent, createDebugProxyWebSocketAgent, resolveDebugProxySettings } from "openclaw/plugin-sdk/proxy-capture";
@@ -50,17 +50,10 @@ function buildClient(params) {
50
50
  allowPrivateNetwork: isPrivateNetworkOptInEnabled(account.config)
51
51
  });
52
52
  }
53
- /**
54
- * Build clients from ALL enabled accounts (deduplicated by token).
55
- *
56
- * We always scan every account because:
57
- * - Private channels are only visible to bots that are members
58
- * - The requesting agent's account may have an expired/invalid token
59
- *
60
- * This means a single healthy bot token is enough for directory discovery.
61
- */
53
+ /** Build the requested account client, or aggregate accounts for an explicitly unscoped lookup. */
62
54
  function buildClients(params) {
63
- const accountIds = listMattermostAccountIds(params.cfg);
55
+ const requestedAccountId = params.accountId?.trim();
56
+ const accountIds = requestedAccountId ? [requestedAccountId] : listMattermostAccountIds(params.cfg);
64
57
  const seen = /* @__PURE__ */ new Set();
65
58
  const clients = [];
66
59
  for (const id of accountIds) {
@@ -412,15 +405,15 @@ function createMattermostConnectOnce(opts) {
412
405
  scheduleProtocolPing();
413
406
  });
414
407
  ws.on("message", async (data) => {
408
+ const raw = rawDataToString(data);
415
409
  captureWsEvent({
416
410
  url: opts.wsUrl,
417
411
  direction: "inbound",
418
412
  kind: "ws-frame",
419
413
  flowId,
420
- payload: Buffer.from(rawDataToString(data)),
414
+ payload: Buffer.from(raw),
421
415
  meta: { subsystem: "mattermost-websocket" }
422
416
  });
423
- const raw = rawDataToString(data);
424
417
  const payload = parseMattermostEventPayload(raw);
425
418
  if (!payload) return;
426
419
  if (payload.status === "OK" && payload.seq_reply === authenticationSeq) {
@@ -531,6 +524,7 @@ function inspectMattermostIngressEvent(rawEvent) {
531
524
  const data = isRecord(envelope.data) ? envelope.data : null;
532
525
  const post = parseRawPost(data?.post);
533
526
  const eventId = requiredString(post.id, "post.id");
527
+ requiredString(post.user_id, "post.user_id");
534
528
  const broadcast = isRecord(envelope.broadcast) ? envelope.broadcast : null;
535
529
  return {
536
530
  eventId,
@@ -542,9 +536,13 @@ function parseClaimedEvent(rawEvent, eventId) {
542
536
  if (!payload || payload.event !== "posted") throw new MattermostIngressPermanentError("invalid-event", `Mattermost ingress row ${eventId} is not a posted event.`);
543
537
  const post = parseMattermostPost(payload.data?.post);
544
538
  const claimedChannelId = post?.channel_id?.trim() || payload.data?.channel_id?.trim() || payload.broadcast?.channel_id?.trim();
545
- if (!post || post.id !== eventId || !claimedChannelId) throw new MattermostIngressPermanentError("invalid-event", `Mattermost ingress row ${eventId} has invalid post identity.`);
539
+ const senderId = post?.user_id?.trim();
540
+ if (!post || post.id !== eventId || !senderId || !claimedChannelId) throw new MattermostIngressPermanentError("invalid-event", `Mattermost ingress row ${eventId} has invalid post identity.`);
546
541
  return {
547
- post,
542
+ post: {
543
+ ...post,
544
+ user_id: senderId
545
+ },
548
546
  payload
549
547
  };
550
548
  }
@@ -601,7 +599,14 @@ function createMattermostIngressMonitor(options) {
601
599
  });
602
600
  monitor.start();
603
601
  return {
604
- receive: (rawEvent) => monitor.admit(rawEvent).then(() => void 0),
602
+ receive: async (rawEvent) => {
603
+ try {
604
+ await monitor.admit(rawEvent);
605
+ } catch (error) {
606
+ if (!(error instanceof MattermostIngressPermanentError) || error.reason !== "invalid-event") throw error;
607
+ options.runtime.error?.(`mattermost ingress rejected invalid event: ${error.message}`);
608
+ }
609
+ },
605
610
  stop: monitor.stop,
606
611
  waitForIdle: monitor.waitForIdle
607
612
  };
@@ -774,6 +779,8 @@ async function buildMattermostEventPlan(monitor, params) {
774
779
  ParentSessionKey: thread.parentSessionKey,
775
780
  AccountId: route.accountId,
776
781
  ChatType: kind,
782
+ ConversationRouteContextObserved: true,
783
+ ConversationRoutePeerId: kind === "direct" ? params.senderId : params.channelId,
777
784
  GroupChannel: channelName ? `#${channelName}` : void 0,
778
785
  GroupSpace: teamId,
779
786
  SenderId: params.senderId,
@@ -781,6 +788,8 @@ async function buildMattermostEventPlan(monitor, params) {
781
788
  Surface: "mattermost",
782
789
  ReplyToId: thread.effectiveReplyToId,
783
790
  MessageThreadId: thread.effectiveReplyToId,
791
+ NativeChannelId: params.channelId,
792
+ InboundAccessAuthorized: true,
784
793
  OriginatingChannel: "mattermost",
785
794
  OriginatingTo: to
786
795
  }),
@@ -2217,11 +2226,7 @@ function createMattermostPostHandler(monitor) {
2217
2226
  return;
2218
2227
  }
2219
2228
  const allMessageIds = messageIds?.length ? messageIds : [post.id];
2220
- const senderId = post.user_id ?? payload.broadcast?.user_id;
2221
- if (!senderId) {
2222
- monitor.logVerboseMessage("mattermost: drop post (missing sender id)");
2223
- return;
2224
- }
2229
+ const senderId = post.user_id;
2225
2230
  if (senderId === botUserId) {
2226
2231
  monitor.logVerboseMessage(`mattermost: drop post (self sender=${senderId})`);
2227
2232
  return;
@@ -2903,12 +2908,12 @@ async function monitorMattermostProvider(opts = {}) {
2903
2908
  }),
2904
2909
  buildKey: (entry) => {
2905
2910
  const channelId = entry.post.channel_id ?? entry.payload.data?.channel_id ?? entry.payload.broadcast?.channel_id;
2906
- if (!channelId) return null;
2911
+ if (!channelId || !entry.post.user_id) return null;
2907
2912
  const threadId = normalizeOptionalString(entry.post.root_id);
2908
- return `mattermost:${account.accountId}:${channelId}:${threadId ? `thread:${threadId}` : "channel"}`;
2913
+ return `mattermost:${account.accountId}:${channelId}:${threadId ? `thread:${threadId}` : "channel"}:${entry.post.user_id}`;
2909
2914
  },
2910
2915
  shouldDebounce: (entry) => {
2911
- if (entry.post.file_ids?.length) return false;
2916
+ if (normalizeOptionalString(entry.post.type) !== void 0 || entry.post.file_ids?.length) return false;
2912
2917
  const text = normalizeOptionalString(entry.post.message) ?? "";
2913
2918
  return Boolean(text) && !core.channel.commands.isControlCommandMessage(text, cfg);
2914
2919
  },
@@ -1,2 +1,2 @@
1
- import { i as registerSlashCommandRoute } from "./slash-state-DUowGLl4.js";
1
+ import { i as registerSlashCommandRoute } from "./slash-state-BakgoSSL.js";
2
2
  export { registerSlashCommandRoute };
@@ -17,26 +17,14 @@ import { FormatCapabilityProfile, convertMarkdownTables } from "openclaw/plugin-
17
17
  import { getSessionEntry, resolveStorePath } from "openclaw/plugin-sdk/session-store-runtime";
18
18
  import { normalizeProviderId } from "openclaw/plugin-sdk/provider-model-shared";
19
19
  import { Readable } from "node:stream";
20
+ import { truncateUtf16Safe, truncateUtf8Prefix } from "openclaw/plugin-sdk/text-utility-runtime";
20
21
  import { resolveHumanDelayConfig } from "openclaw/plugin-sdk/agent-runtime";
21
22
  import { finalizeInboundContext } from "openclaw/plugin-sdk/reply-runtime";
22
- import { truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
23
23
  import { pruneMapToMaxSize } from "openclaw/plugin-sdk/collection-runtime";
24
24
  import { resolveMarkdownTableMode } from "openclaw/plugin-sdk/markdown-table-runtime";
25
25
  import { extensionForMime } from "openclaw/plugin-sdk/media-mime";
26
26
  import { requireRuntimeConfig } from "openclaw/plugin-sdk/plugin-config-runtime";
27
27
  const MATTERMOST_COMMAND_DESCRIPTION_MAX_BYTES = 128;
28
- function truncateMattermostCommandDescription(description) {
29
- if (Buffer.byteLength(description, "utf8") <= MATTERMOST_COMMAND_DESCRIPTION_MAX_BYTES) return description;
30
- let bytes = 0;
31
- let end = 0;
32
- for (const char of description) {
33
- const charBytes = Buffer.byteLength(char, "utf8");
34
- if (bytes + charBytes > MATTERMOST_COMMAND_DESCRIPTION_MAX_BYTES) break;
35
- bytes += charBytes;
36
- end += char.length;
37
- }
38
- return description.slice(0, end);
39
- }
40
28
  /**
41
29
  * Built-in OpenClaw commands to register as native slash commands.
42
30
  * These mirror the text-based commands already handled by the gateway.
@@ -163,7 +151,7 @@ async function registerSlashCommands(params) {
163
151
  }
164
152
  const registered = [];
165
153
  for (const spec of commands) {
166
- const description = truncateMattermostCommandDescription(spec.description);
154
+ const description = truncateUtf8Prefix(spec.description, MATTERMOST_COMMAND_DESCRIPTION_MAX_BYTES);
167
155
  const existingForTrigger = existingByTrigger.get(spec.trigger) ?? [];
168
156
  const ownedCommands = existingForTrigger.filter((cmd) => cmd.creator_id?.trim() === normalizedCreatorUserId);
169
157
  const foreignCommands = existingForTrigger.filter((cmd) => cmd.creator_id?.trim() !== normalizedCreatorUserId);
@@ -1690,7 +1678,10 @@ async function handleSlashCommandAsync(params) {
1690
1678
  SessionKey: route.sessionKey,
1691
1679
  AccountId: route.accountId,
1692
1680
  ChatType: chatType,
1681
+ ConversationRouteContextObserved: true,
1682
+ ConversationRoutePeerId: kind === "direct" ? senderId : channelId,
1693
1683
  ConversationLabel: fromLabel,
1684
+ GroupSpace: teamId,
1694
1685
  GroupSubject: kind !== "direct" ? channelDisplay || roomLabel : void 0,
1695
1686
  SenderName: senderName,
1696
1687
  SenderId: senderId,
@@ -1700,6 +1691,7 @@ async function handleSlashCommandAsync(params) {
1700
1691
  Timestamp: Date.now(),
1701
1692
  WasMentioned: true,
1702
1693
  CommandAuthorized: commandAuthorized,
1694
+ InboundAccessAuthorized: true,
1703
1695
  CommandSource: "native",
1704
1696
  OriginatingChannel: "mattermost",
1705
1697
  OriginatingTo: to
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openclaw/mattermost",
3
- "version": "2026.8.1-beta.2",
3
+ "version": "2026.8.1-beta.3",
4
4
  "description": "OpenClaw Mattermost channel plugin",
5
5
  "repository": {
6
6
  "type": "git",
@@ -12,7 +12,7 @@
12
12
  "zod": "4.4.3"
13
13
  },
14
14
  "peerDependencies": {
15
- "openclaw": ">=2026.8.1-beta.2"
15
+ "openclaw": ">=2026.8.1-beta.3"
16
16
  },
17
17
  "peerDependenciesMeta": {
18
18
  "openclaw": {
@@ -91,10 +91,10 @@
91
91
  "allowInvalidConfigRecovery": true
92
92
  },
93
93
  "compat": {
94
- "pluginApi": ">=2026.8.1-beta.2"
94
+ "pluginApi": ">=2026.8.1-beta.3"
95
95
  },
96
96
  "build": {
97
- "openclawVersion": "2026.8.1-beta.2",
97
+ "openclawVersion": "2026.8.1-beta.3",
98
98
  "bundledDist": false
99
99
  },
100
100
  "release": {