@openclaw/mattermost 2026.7.2-beta.4 → 2026.7.2-beta.7

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.
@@ -27,6 +27,12 @@ const MattermostPostSchema = z.object({
27
27
  create_at: z.number().nullable().optional(),
28
28
  props: z.record(z.string(), z.unknown()).nullable().optional()
29
29
  }).passthrough();
30
+ const MattermostPostListSchema = z.object({
31
+ order: z.array(z.string()),
32
+ posts: z.record(z.string(), MattermostPostSchema),
33
+ next_post_id: z.string().nullable().optional(),
34
+ prev_post_id: z.string().nullable().optional()
35
+ }).passthrough();
30
36
  function normalizeMattermostBaseUrl(raw) {
31
37
  const trimmed = raw?.trim();
32
38
  if (!trimmed) return;
@@ -181,7 +187,24 @@ async function fetchMattermostUserByUsername(client, username) {
181
187
  return await client.request(`/users/username/${encodeURIComponent(username)}`);
182
188
  }
183
189
  async function fetchMattermostChannel(client, channelId) {
184
- return await client.request(`/channels/${channelId}`);
190
+ return await client.request(`/channels/${encodeURIComponent(channelId)}`);
191
+ }
192
+ async function fetchMattermostChannelPosts(client, channelId, options = {}) {
193
+ const before = normalizeOptionalString(options.before);
194
+ const after = normalizeOptionalString(options.after);
195
+ if (before && after) throw new Error("Mattermost read accepts either before or after, not both.");
196
+ if (options.limit !== void 0 && (!Number.isSafeInteger(options.limit) || options.limit <= 0)) throw new Error("Mattermost read limit must be a positive integer.");
197
+ const perPage = Math.min(options.limit ?? 60, 200);
198
+ const query = new URLSearchParams({ per_page: String(perPage) });
199
+ if (before) query.set("before", before);
200
+ if (after) query.set("after", after);
201
+ const response = await client.request(`/channels/${encodeURIComponent(channelId)}/posts?${query.toString()}`);
202
+ const parsed = MattermostPostListSchema.safeParse(response);
203
+ if (!parsed.success || parsed.data.order.some((postId) => !parsed.data.posts[postId])) throw new Error("Unexpected Mattermost channel posts response.");
204
+ return {
205
+ messages: parsed.data.order.map((postId) => parsed.data.posts[postId]),
206
+ hasMore: Boolean(after ? parsed.data.next_post_id : parsed.data.prev_post_id)
207
+ };
185
208
  }
186
209
  async function fetchMattermostChannelByName(client, teamId, channelName) {
187
210
  return await client.request(`/teams/${teamId}/channels/name/${encodeURIComponent(channelName)}`);
@@ -393,4 +416,4 @@ async function uploadMattermostFile(client, params) {
393
416
  return info;
394
417
  }
395
418
  //#endregion
396
- export { updateMattermostPost as _, createMattermostPost as a, fetchMattermostChannelByName as c, fetchMattermostUserByUsername as d, fetchMattermostUserTeams as f, sendMattermostTyping as g, resolveMattermostReplyDeliveryBarrierTimeoutMs as h, createMattermostDirectChannelWithRetry as i, fetchMattermostMe as l, readMattermostError as m, buildMattermostApiUrl as n, deleteMattermostPost as o, normalizeMattermostBaseUrl as p, createMattermostClient as r, fetchMattermostChannel as s, MattermostPostSchema as t, fetchMattermostUser as u, uploadMattermostFile as v };
419
+ export { sendMattermostTyping as _, createMattermostPost as a, fetchMattermostChannelByName as c, fetchMattermostUser as d, fetchMattermostUserByUsername as f, resolveMattermostReplyDeliveryBarrierTimeoutMs as g, readMattermostError 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 };
@@ -1,6 +1,6 @@
1
1
  import { t as getMattermostRuntime } from "./runtime-CNB4YGqJ.js";
2
- import { _ as updateMattermostPost } from "./client-w0lkxuKh.js";
3
- import { T as resolveClientIp, h as isTrustedProxyAddress, x as readRequestBodyWithLimit } from "./monitor-auth-4zjr5tXP.js";
2
+ import { v as updateMattermostPost } from "./client-CqqzTcno.js";
3
+ import { b as readRequestBodyWithLimit, m as isTrustedProxyAddress, w as resolveClientIp } from "./monitor-auth-rctDliGZ.js";
4
4
  import { createHmac } from "node:crypto";
5
5
  import { safeEqualSecret } from "openclaw/plugin-sdk/security-runtime";
6
6
  import { normalizeOptionalString, normalizeStringifiedOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
@@ -8,7 +8,7 @@ import { logTypingFailure } from "openclaw/plugin-sdk/channel-feedback";
8
8
  import { listSkillCommandsForAgents } from "openclaw/plugin-sdk/command-auth-native";
9
9
  import { buildModelsProviderData } from "openclaw/plugin-sdk/models-provider-runtime";
10
10
  import { isDangerousNameMatchingEnabled } from "openclaw/plugin-sdk/dangerous-name-runtime";
11
- import { resolveAllowlistProviderRuntimeGroupPolicy, resolveDefaultGroupPolicy, warnMissingProviderGroupPolicyFallbackOnce } from "openclaw/plugin-sdk/runtime-group-policy";
11
+ import { resolveAllowlistProviderRuntimeGroupPolicy as resolveAllowlistProviderRuntimeGroupPolicy$1, resolveDefaultGroupPolicy, warnMissingProviderGroupPolicyFallbackOnce } from "openclaw/plugin-sdk/runtime-group-policy";
12
12
  import { resolveChannelMediaMaxBytes } from "openclaw/plugin-sdk/media-runtime";
13
13
  import { loadOutboundMediaFromUrl } from "openclaw/plugin-sdk/outbound-media";
14
14
  import { DEFAULT_GROUP_HISTORY_LIMIT, createChannelHistoryWindow } from "openclaw/plugin-sdk/reply-history";
@@ -182,4 +182,4 @@ async function authorizeMattermostCommandInvocation(params) {
182
182
  };
183
183
  }
184
184
  //#endregion
185
- export { resolveAllowlistProviderRuntimeGroupPolicy as C, warnMissingProviderGroupPolicyFallbackOnce as D, resolveDefaultGroupPolicy as E, registerPluginHttpRoute as S, resolveClientIp as T, loadOutboundMediaFromUrl as _, normalizeMattermostAllowEntry as a, parseTcpPort as b, resolveMattermostTrustedChatKind as c, createChannelHistoryWindow as d, createChannelMessageReplyPipeline as f, listSkillCommandsForAgents as g, isTrustedProxyAddress as h, mapMattermostChannelTypeToChatType as i, DEFAULT_GROUP_HISTORY_LIMIT as l, isRequestBodyLimitError as m, formatMattermostDirectMessageDropLog as n, normalizeMattermostAllowList as o, createChannelPairingController as p, isMattermostSenderAllowed as r, resolveMattermostMonitorInboundAccess as s, authorizeMattermostCommandInvocation as t, buildModelsProviderData as u, logInboundDrop as v, resolveChannelMediaMaxBytes as w, readRequestBodyWithLimit as x, logTypingFailure as y };
185
+ export { resolveChannelMediaMaxBytes as C, warnMissingProviderGroupPolicyFallbackOnce as E, resolveAllowlistProviderRuntimeGroupPolicy$1 as S, resolveDefaultGroupPolicy as T, logInboundDrop as _, normalizeMattermostAllowList as a, readRequestBodyWithLimit 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, resolveClientIp as w, registerPluginHttpRoute as x, parseTcpPort as y };
@@ -1,2 +1,2 @@
1
- import { r as isMattermostSenderAllowed } from "./monitor-auth-4zjr5tXP.js";
1
+ import { r as isMattermostSenderAllowed } from "./monitor-auth-rctDliGZ.js";
2
2
  export { isMattermostSenderAllowed };
@@ -17,8 +17,7 @@ import { DEFAULT_ACCOUNT_ID, buildChannelConfigSchema, createDedupeCache, isTrus
17
17
  import { chunkTextForOutbound } from "openclaw/plugin-sdk/text-chunking";
18
18
  import { applyAccountNameToChannelSection, applySetupAccountConfigPatch, migrateBaseNameToDefaultAccount } from "openclaw/plugin-sdk/setup";
19
19
  import { buildComputedAccountStatusSnapshot } from "openclaw/plugin-sdk/channel-status";
20
- import { buildAgentMediaPayload } from "openclaw/plugin-sdk/agent-media-payload";
21
20
  import { resolveStorePath } from "openclaw/plugin-sdk/session-store-runtime";
22
21
  import { normalizeAccountId, resolveThreadSessionKeys } from "openclaw/plugin-sdk/routing";
23
22
  import { normalizeProviderId } from "openclaw/plugin-sdk/provider-model-shared";
24
- export { DEFAULT_ACCOUNT_ID, DEFAULT_GROUP_HISTORY_LIMIT, GROUP_POLICY_BLOCKED_LABEL, applyAccountNameToChannelSection, applySetupAccountConfigPatch, buildAgentMediaPayload, buildChannelConfigSchema, buildComputedAccountStatusSnapshot, buildModelsProviderData, buildPendingHistoryContextFromMap, chunkTextForOutbound, clearHistoryEntriesIfEnabled, createAccountStatusSink, createChannelHistoryWindow, createChannelMessageReplyPipeline, createChannelPairingController, createDedupeCache, formatInboundFromLabel, getAgentScopedMediaLocalRoots, isDangerousNameMatchingEnabled, isRequestBodyLimitError, isTrustedProxyAddress, listSkillCommandsForAgents, loadOutboundMediaFromUrl, logInboundDrop, logTypingFailure, migrateBaseNameToDefaultAccount, normalizeAccountId, normalizeProviderId, parseStrictPositiveInteger, rawDataToString, readRequestBodyWithLimit, recordPendingHistoryEntryIfEnabled, registerPluginHttpRoute, resolveAllowlistMatchSimple, resolveAllowlistProviderRuntimeGroupPolicy, resolveChannelMediaMaxBytes, resolveClientIp, resolveControlCommandGate, resolveDefaultGroupPolicy, resolveStorePath, resolveStoredModelOverride, resolveThreadSessionKeys, setMattermostRuntime, warnMissingProviderGroupPolicyFallbackOnce };
23
+ export { DEFAULT_ACCOUNT_ID, DEFAULT_GROUP_HISTORY_LIMIT, GROUP_POLICY_BLOCKED_LABEL, applyAccountNameToChannelSection, applySetupAccountConfigPatch, buildChannelConfigSchema, buildComputedAccountStatusSnapshot, buildModelsProviderData, buildPendingHistoryContextFromMap, chunkTextForOutbound, clearHistoryEntriesIfEnabled, createAccountStatusSink, createChannelHistoryWindow, createChannelMessageReplyPipeline, createChannelPairingController, createDedupeCache, formatInboundFromLabel, getAgentScopedMediaLocalRoots, isDangerousNameMatchingEnabled, isRequestBodyLimitError, isTrustedProxyAddress, listSkillCommandsForAgents, loadOutboundMediaFromUrl, logInboundDrop, logTypingFailure, migrateBaseNameToDefaultAccount, normalizeAccountId, normalizeProviderId, parseStrictPositiveInteger, rawDataToString, readRequestBodyWithLimit, recordPendingHistoryEntryIfEnabled, registerPluginHttpRoute, resolveAllowlistMatchSimple, resolveAllowlistProviderRuntimeGroupPolicy, resolveChannelMediaMaxBytes, resolveClientIp, resolveControlCommandGate, resolveDefaultGroupPolicy, resolveStorePath, resolveStoredModelOverride, resolveThreadSessionKeys, setMattermostRuntime, warnMissingProviderGroupPolicyFallbackOnce };
@@ -1,2 +1,2 @@
1
- import { i as registerSlashCommandRoute } from "./slash-state-CFEaCLnp.js";
1
+ import { i as registerSlashCommandRoute } from "./slash-state-DM8qmFJR.js";
2
2
  export { registerSlashCommandRoute };
@@ -1,18 +1,19 @@
1
1
  import { t as getMattermostRuntime } from "./runtime-CNB4YGqJ.js";
2
- import { a as createMattermostPost, c as fetchMattermostChannelByName, d as fetchMattermostUserByUsername, f as fetchMattermostUserTeams, g as sendMattermostTyping, h as resolveMattermostReplyDeliveryBarrierTimeoutMs, i as createMattermostDirectChannelWithRetry, l as fetchMattermostMe, p as normalizeMattermostBaseUrl, r as createMattermostClient, s as fetchMattermostChannel, u as fetchMattermostUser, v as uploadMattermostFile } from "./client-w0lkxuKh.js";
3
- import { _ as loadOutboundMediaFromUrl, f as createChannelMessageReplyPipeline, m as isRequestBodyLimitError, o as normalizeMattermostAllowList, t as authorizeMattermostCommandInvocation, u as buildModelsProviderData, x as readRequestBodyWithLimit, y as logTypingFailure } from "./monitor-auth-4zjr5tXP.js";
4
- import { c as setInteractionSecret, n as buildButtonProps, o as resolveInteractionCallbackUrl } from "./interactions-DODXaHdE.js";
5
- import { r as resolveMattermostAccount } from "./accounts-B-GrNVwP.js";
2
+ import { _ as sendMattermostTyping, a as createMattermostPost, c as fetchMattermostChannelByName, d as fetchMattermostUser, f as fetchMattermostUserByUsername, g as resolveMattermostReplyDeliveryBarrierTimeoutMs, i as createMattermostDirectChannelWithRetry, m as normalizeMattermostBaseUrl, p as fetchMattermostUserTeams, r as createMattermostClient, s as fetchMattermostChannel, u as fetchMattermostMe, y as uploadMattermostFile } from "./client-CqqzTcno.js";
3
+ import { a as normalizeMattermostAllowList, b as readRequestBodyWithLimit, g as loadOutboundMediaFromUrl, l as buildModelsProviderData, p as isRequestBodyLimitError, s as resolveMattermostTrustedChatKind, t as authorizeMattermostCommandInvocation, v as logTypingFailure } from "./monitor-auth-rctDliGZ.js";
4
+ import { c as setInteractionSecret, n as buildButtonProps, o as resolveInteractionCallbackUrl } from "./interactions-BQXY_48h.js";
5
+ import { i as resolveMattermostAccount } from "./accounts-NaMdx9yF.js";
6
6
  import { createHash } from "node:crypto";
7
7
  import { safeEqualSecret } from "openclaw/plugin-sdk/security-runtime";
8
8
  import { normalizeLowercaseStringOrEmpty, normalizeOptionalString, normalizeStringifiedOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
9
9
  import { asDateTimestampMs, parseStrictInteger, resolveExpiresAtMsFromDurationMs } from "openclaw/plugin-sdk/number-runtime";
10
10
  import { isPrivateNetworkOptInEnabled } from "openclaw/plugin-sdk/ssrf-runtime";
11
- import { createMessageReceiptFromOutboundResults } from "openclaw/plugin-sdk/channel-outbound";
11
+ import { createChannelPartialDeliveryError, isChannelPartialDeliveryError } from "openclaw/plugin-sdk/channel-inbound";
12
+ import { createMessageReceiptFromOutboundResults, listMessageReceiptPlatformIds } from "openclaw/plugin-sdk/channel-outbound";
12
13
  import { resolveStoredModelOverride } from "openclaw/plugin-sdk/command-auth-native";
13
14
  import { getAgentScopedMediaLocalRoots } from "openclaw/plugin-sdk/media-runtime";
14
15
  import { deliverTextOrMediaReply, isReasoningReplyPayload, resolveSendableOutboundReplyParts } from "openclaw/plugin-sdk/reply-payload";
15
- import { convertMarkdownTables } from "openclaw/plugin-sdk/text-chunking";
16
+ import { FormatCapabilityProfile, convertMarkdownTables } from "openclaw/plugin-sdk/text-chunking";
16
17
  import { getSessionEntry, resolveStorePath } from "openclaw/plugin-sdk/session-store-runtime";
17
18
  import { normalizeProviderId } from "openclaw/plugin-sdk/provider-model-shared";
18
19
  import { Readable } from "node:stream";
@@ -661,43 +662,104 @@ function createMattermostReplyDeliveryBarrier(params) {
661
662
  resolveTimeoutPolicy
662
663
  };
663
664
  }
665
+ /** Represents distinct provider posts without collapsing their visible boundary. */
666
+ function joinMattermostVisibleContent(contents) {
667
+ return contents.filter((content) => Boolean(content)).join("\n");
668
+ }
664
669
  async function deliverMattermostReplyPayload(params) {
665
- if (isReasoningReplyPayload(params.payload)) return "reasoning_skipped";
670
+ if (isReasoningReplyPayload(params.payload)) return {
671
+ outcome: "reasoning_skipped",
672
+ visibleReplySent: false,
673
+ suppression: { reason: "no_visible_result" }
674
+ };
666
675
  const reply = resolveSendableOutboundReplyParts(params.payload, { text: params.core.channel.text.convertMarkdownTables(params.payload.text ?? "", params.tableMode) });
667
676
  const mediaLocalRoots = getAgentScopedMediaLocalRoots(params.cfg, params.agentId);
668
677
  const chunkMode = params.core.channel.text.resolveChunkMode(params.cfg, "mattermost", params.accountId);
669
- return await deliverTextOrMediaReply({
670
- payload: params.payload,
671
- text: reply.text,
672
- chunkText: (value) => params.core.channel.text.chunkMarkdownTextWithMode(value, params.textLimit, chunkMode),
673
- sendText: async (chunk) => {
674
- await params.sendMessage(params.to, chunk, {
675
- cfg: params.cfg,
676
- accountId: params.accountId,
677
- replyToId: params.replyToId,
678
- ...params.onDmChannelResolution ? { onDmChannelResolution: params.onDmChannelResolution } : {}
679
- });
680
- },
681
- sendMedia: async ({ mediaUrl, caption }) => {
682
- await params.sendMessage(params.to, caption ?? "", {
683
- cfg: params.cfg,
684
- accountId: params.accountId,
685
- mediaUrl,
686
- mediaLocalRoots,
687
- replyToId: params.replyToId,
688
- ...params.onDmChannelResolution ? { onDmChannelResolution: params.onDmChannelResolution } : {}
689
- });
690
- }
678
+ const results = [];
679
+ const acceptedContents = [];
680
+ let outcome;
681
+ try {
682
+ outcome = await deliverTextOrMediaReply({
683
+ payload: params.payload,
684
+ text: reply.text,
685
+ chunkText: (value) => params.core.channel.text.chunkMarkdownTextWithMode(value, params.textLimit, chunkMode),
686
+ sendText: async (chunk) => {
687
+ const result = await params.sendMessage(params.to, chunk, {
688
+ cfg: params.cfg,
689
+ accountId: params.accountId,
690
+ replyToId: params.replyToId,
691
+ ...params.onDmChannelResolution ? { onDmChannelResolution: params.onDmChannelResolution } : {}
692
+ });
693
+ results.push(result);
694
+ acceptedContents.push(result.content);
695
+ },
696
+ sendMedia: async ({ mediaUrl, caption }) => {
697
+ const result = await params.sendMessage(params.to, caption ?? "", {
698
+ cfg: params.cfg,
699
+ accountId: params.accountId,
700
+ mediaUrl,
701
+ mediaLocalRoots,
702
+ replyToId: params.replyToId,
703
+ ...params.onDmChannelResolution ? { onDmChannelResolution: params.onDmChannelResolution } : {}
704
+ });
705
+ results.push(result);
706
+ acceptedContents.push(result.content);
707
+ }
708
+ });
709
+ } catch (error) {
710
+ const failedPartial = isChannelPartialDeliveryError(error) ? error.deliveryResult : void 0;
711
+ if (results.length === 0 && failedPartial?.visibleReplySent !== true) throw error;
712
+ const receipt = createMessageReceiptFromOutboundResults({
713
+ results: [...results.map((result) => ({ receipt: result.receipt })), ...failedPartial?.receipt ? [{ receipt: failedPartial.receipt }] : (failedPartial?.messageIds ?? []).map((messageId) => ({ messageId }))],
714
+ kind: reply.mediaUrls.length > 0 ? "media" : "text",
715
+ ...params.replyToId ? { replyToId: params.replyToId } : {}
716
+ });
717
+ throw createChannelPartialDeliveryError(error, {
718
+ messageIds: listMessageReceiptPlatformIds(receipt),
719
+ receipt,
720
+ visibleReplySent: true,
721
+ content: joinMattermostVisibleContent([...acceptedContents, failedPartial?.content])
722
+ });
723
+ }
724
+ if (outcome === "empty") return {
725
+ outcome,
726
+ visibleReplySent: false,
727
+ suppression: { reason: "no_visible_result" }
728
+ };
729
+ const receipt = createMessageReceiptFromOutboundResults({
730
+ results: results.map((result) => ({ receipt: result.receipt })),
731
+ kind: outcome,
732
+ ...params.replyToId ? { replyToId: params.replyToId } : {}
691
733
  });
734
+ return {
735
+ outcome,
736
+ messageIds: listMessageReceiptPlatformIds(receipt),
737
+ receipt,
738
+ visibleReplySent: true,
739
+ content: joinMattermostVisibleContent(acceptedContents)
740
+ };
692
741
  }
693
742
  //#endregion
694
743
  //#region extensions/mattermost/src/mattermost/target-resolution.ts
695
744
  const MATTERMOST_OPAQUE_TARGET_CACHE_MAX_ENTRIES = 1024;
745
+ const MATTERMOST_OPAQUE_TARGET_CACHE_TTL_MS = 300 * 1e3;
696
746
  const mattermostOpaqueTargetCache = /* @__PURE__ */ new Map();
697
747
  function cacheMattermostOpaqueTarget(key, kind) {
698
- mattermostOpaqueTargetCache.set(key, kind);
748
+ mattermostOpaqueTargetCache.set(key, {
749
+ kind,
750
+ expiresAt: Date.now() + MATTERMOST_OPAQUE_TARGET_CACHE_TTL_MS
751
+ });
699
752
  pruneMapToMaxSize(mattermostOpaqueTargetCache, MATTERMOST_OPAQUE_TARGET_CACHE_MAX_ENTRIES);
700
753
  }
754
+ function getCachedMattermostOpaqueTargetKind(key) {
755
+ const cached = mattermostOpaqueTargetCache.get(key);
756
+ if (!cached) return;
757
+ if (cached.expiresAt <= Date.now()) {
758
+ mattermostOpaqueTargetCache.delete(key);
759
+ return;
760
+ }
761
+ return cached.kind;
762
+ }
701
763
  function cacheKey$1(baseUrl, token, id) {
702
764
  return `${baseUrl}::${token}::${id}`;
703
765
  }
@@ -795,11 +857,11 @@ async function resolveMattermostOpaqueTarget(params) {
795
857
  const baseUrl = normalizeMattermostBaseUrl(params.baseUrl ?? account?.baseUrl);
796
858
  if (!token || !baseUrl) return null;
797
859
  const key = cacheKey$1(baseUrl, token, input);
798
- const cachedKind = mattermostOpaqueTargetCache.get(key);
860
+ const cachedKind = getCachedMattermostOpaqueTargetKind(key);
799
861
  if (cachedKind) return {
800
862
  kind: cachedKind,
801
863
  id: input,
802
- to: `${cachedKind}:${input}`
864
+ to: cachedKind === "user" ? `user:${input}` : `channel:${input}`
803
865
  };
804
866
  const client = createMattermostClient({
805
867
  baseUrl,
@@ -815,7 +877,21 @@ async function resolveMattermostOpaqueTarget(params) {
815
877
  to: `user:${input}`
816
878
  };
817
879
  } catch (err) {
818
- if (parseMattermostApiStatus(err) === 404) cacheMattermostOpaqueTarget(key, "channel");
880
+ if (parseMattermostApiStatus(err) !== 404) return {
881
+ kind: "channel",
882
+ id: input,
883
+ to: `channel:${input}`
884
+ };
885
+ }
886
+ try {
887
+ const channelKind = resolveMattermostTrustedChatKind({ channelType: (await fetchMattermostChannel(client, input)).type }) === "group" ? "group" : "channel";
888
+ cacheMattermostOpaqueTarget(key, channelKind);
889
+ return {
890
+ kind: channelKind,
891
+ id: input,
892
+ to: `channel:${input}`
893
+ };
894
+ } catch {
819
895
  return {
820
896
  kind: "channel",
821
897
  id: input,
@@ -827,32 +903,13 @@ async function resolveMattermostOpaqueTarget(params) {
827
903
  //#region extensions/mattermost/src/mattermost/send.ts
828
904
  const MATTERMOST_BOT_USER_CACHE_MAX_ENTRIES = 64;
829
905
  const MATTERMOST_TARGET_CACHE_MAX_ENTRIES = 1024;
830
- const MATTERMOST_FORMAT_PROFILE = {
906
+ const MATTERMOST_FORMAT_PROFILE = FormatCapabilityProfile.define({
831
907
  mechanism: "markdown",
832
- constructs: {
833
- bold: "native",
834
- italic: "native",
835
- underline: "native",
836
- strikethrough: "native",
837
- spoiler: "native",
838
- codeInline: "native",
839
- codeBlock: "native",
840
- codeLanguage: "native",
841
- linkLabel: "native",
842
- heading: "native",
843
- bulletList: "native",
844
- orderedList: "native",
845
- taskList: "native",
846
- table: "native",
847
- blockquote: "native",
848
- image: "native",
849
- mention: "native"
850
- },
851
908
  chunk: {
852
909
  limit: 16383,
853
910
  unit: "chars"
854
911
  }
855
- };
912
+ });
856
913
  function renderMattermostMarkdown(markdown, tableMode) {
857
914
  return tableMode === "off" && MATTERMOST_FORMAT_PROFILE.constructs.table === "native" ? markdown : convertMarkdownTables(markdown, tableMode);
858
915
  }
@@ -1111,22 +1168,35 @@ async function sendMessageMattermost(to, text, opts) {
1111
1168
  fileIds,
1112
1169
  props
1113
1170
  });
1114
- recordMattermostOutboundActivity(accountId);
1115
1171
  const messageId = post.id ?? "unknown";
1116
- return {
1172
+ const receipt = createMattermostSendReceipt({
1117
1173
  messageId,
1118
1174
  channelId,
1119
- receipt: createMattermostSendReceipt({
1120
- messageId,
1121
- channelId,
1122
- kind: resolveMattermostReceiptKind({
1123
- fileIds,
1124
- buttons: opts.buttons,
1125
- props
1126
- }),
1127
- replyToId: opts.replyToId
1128
- })
1175
+ kind: resolveMattermostReceiptKind({
1176
+ fileIds,
1177
+ buttons: opts.buttons,
1178
+ props
1179
+ }),
1180
+ replyToId: opts.replyToId
1181
+ });
1182
+ const result = {
1183
+ messageId,
1184
+ channelId,
1185
+ receipt,
1186
+ content: post.message ?? message
1129
1187
  };
1188
+ try {
1189
+ await opts.onDeliveryResult?.(result);
1190
+ recordMattermostOutboundActivity(accountId);
1191
+ } catch (error) {
1192
+ throw createChannelPartialDeliveryError(error, {
1193
+ messageIds: listMessageReceiptPlatformIds(receipt),
1194
+ receipt,
1195
+ visibleReplySent: true,
1196
+ content: result.content
1197
+ });
1198
+ }
1199
+ return result;
1130
1200
  }
1131
1201
  //#endregion
1132
1202
  //#region extensions/mattermost/src/mattermost/slash-http.ts
@@ -1648,38 +1718,25 @@ async function handleSlashCommandAsync(params) {
1648
1718
  channel: "mattermost",
1649
1719
  accountId: account.accountId
1650
1720
  });
1651
- const { onModelSelected, typingCallbacks, ...replyPipeline } = createChannelMessageReplyPipeline({
1652
- cfg,
1653
- agentId: route.agentId,
1654
- channel: "mattermost",
1655
- accountId: account.accountId,
1656
- typing: {
1657
- start: () => sendMattermostTyping(client, { channelId }),
1658
- onStartError: (err) => {
1659
- logTypingFailure({
1660
- log: (message) => log?.(message),
1661
- channel: "mattermost",
1662
- target: channelId,
1663
- error: err
1664
- });
1665
- }
1666
- }
1667
- });
1668
1721
  const humanDelay = resolveHumanDelayConfig(cfg, route.agentId);
1669
1722
  const deliveryBarrier = createMattermostReplyDeliveryBarrier({
1670
1723
  isDirect: kind === "direct",
1671
1724
  dmRetryOptions: account.config.dmChannelRetry
1672
1725
  });
1673
- await core.channel.reply.dispatchReplyWithBufferedBlockDispatcher({
1674
- ctx: ctxPayload,
1726
+ await core.channel.inbound.dispatch({
1675
1727
  cfg,
1676
- dispatcherOptions: {
1677
- ...replyPipeline,
1678
- resolveFollowupAdmissionBarrierTimeoutPolicy: deliveryBarrier.resolveTimeoutPolicy,
1679
- onDeliverySettled: deliveryBarrier.markDeliverySettled,
1680
- humanDelay,
1728
+ channel: "mattermost",
1729
+ accountId: account.accountId,
1730
+ route: {
1731
+ agentId: route.agentId,
1732
+ dmScope: route.dmScope,
1733
+ sessionKey: route.sessionKey
1734
+ },
1735
+ ctxPayload,
1736
+ delivery: {
1737
+ observeMessageSent: true,
1681
1738
  deliver: async (payload) => {
1682
- await deliverMattermostReplyPayload({
1739
+ const result = await deliverMattermostReplyPayload({
1683
1740
  core,
1684
1741
  cfg,
1685
1742
  payload,
@@ -1691,17 +1748,30 @@ async function handleSlashCommandAsync(params) {
1691
1748
  sendMessage: sendMessageMattermost,
1692
1749
  onDmChannelResolution: deliveryBarrier.trackDmChannelResolution
1693
1750
  });
1694
- runtime.log?.(`delivered slash reply to ${to}`);
1751
+ if (result.visibleReplySent) runtime.log?.(`delivered slash reply to ${to}`);
1752
+ return result;
1695
1753
  },
1696
1754
  onError: (err, info) => {
1697
1755
  runtime.error?.(`mattermost slash ${info.kind} reply failed: ${sanitizeCommandLookupError(err)}`);
1698
- },
1699
- typingCallbacks
1756
+ }
1700
1757
  },
1701
- replyOptions: {
1702
- disableBlockStreaming: typeof account.blockStreaming === "boolean" ? !account.blockStreaming : void 0,
1703
- onModelSelected
1704
- }
1758
+ replyPipeline: { typing: {
1759
+ start: () => sendMattermostTyping(client, { channelId }),
1760
+ onStartError: (err) => {
1761
+ logTypingFailure({
1762
+ log: (message) => log?.(message),
1763
+ channel: "mattermost",
1764
+ target: channelId,
1765
+ error: err
1766
+ });
1767
+ }
1768
+ } },
1769
+ dispatcherOptions: {
1770
+ resolveFollowupAdmissionBarrierTimeoutPolicy: deliveryBarrier.resolveTimeoutPolicy,
1771
+ onDeliverySettled: deliveryBarrier.markDeliverySettled,
1772
+ humanDelay
1773
+ },
1774
+ replyOptions: { disableBlockStreaming: typeof account.blockStreaming === "boolean" ? !account.blockStreaming : void 0 }
1705
1775
  });
1706
1776
  }
1707
1777
  //#endregion
@@ -1947,4 +2017,4 @@ function registerSlashCommandRoute(api) {
1947
2017
  });
1948
2018
  }
1949
2019
  //#endregion
1950
- export { registerSlashCommands as _, sendMessageMattermost as a, deliverMattermostReplyPayload as c, renderMattermostModelsPickerView as d, renderMattermostProviderPickerView as f, isSlashCommandsEnabled as g, cleanupSlashCommands as h, registerSlashCommandRoute as i, buildMattermostAllowedModelRefs as l, DEFAULT_COMMAND_SPECS as m, deactivateSlashCommands as n, resolveMattermostOpaqueTarget as o, resolveMattermostModelPickerCurrentModel as p, getSlashCommandState as r, createMattermostReplyDeliveryBarrier as s, activateSlashCommands as t, parseMattermostModelPickerContext as u, resolveCallbackUrl as v, resolveSlashCommandConfig as y };
2020
+ export { isSlashCommandsEnabled as _, sendMessageMattermost as a, resolveSlashCommandConfig as b, deliverMattermostReplyPayload as c, parseMattermostModelPickerContext as d, renderMattermostModelsPickerView as f, cleanupSlashCommands as g, DEFAULT_COMMAND_SPECS as h, registerSlashCommandRoute as i, joinMattermostVisibleContent as l, resolveMattermostModelPickerCurrentModel as m, deactivateSlashCommands as n, resolveMattermostOpaqueTarget as o, renderMattermostProviderPickerView as p, getSlashCommandState as r, createMattermostReplyDeliveryBarrier as s, activateSlashCommands as t, buildMattermostAllowedModelRefs as u, registerSlashCommands as v, resolveCallbackUrl as y };
@@ -373,6 +373,9 @@
373
373
  "actions": {
374
374
  "type": "object",
375
375
  "properties": {
376
+ "messages": {
377
+ "type": "boolean"
378
+ },
376
379
  "reactions": {
377
380
  "type": "boolean"
378
381
  }
@@ -841,6 +844,9 @@
841
844
  "actions": {
842
845
  "type": "object",
843
846
  "properties": {
847
+ "messages": {
848
+ "type": "boolean"
849
+ },
844
850
  "reactions": {
845
851
  "type": "boolean"
846
852
  }
@@ -999,6 +1005,22 @@
999
1005
  "label": "Mattermost Streaming Mode",
1000
1006
  "help": "Canonical Mattermost preview mode: \"off\" | \"partial\" | \"block\" | \"progress\"."
1001
1007
  },
1008
+ "streaming.block.enabled": {
1009
+ "label": "Mattermost Block Streaming Enabled",
1010
+ "help": "Enable chunked block-style Mattermost preview delivery when channels.mattermost.streaming.mode=\"block\"."
1011
+ },
1012
+ "streaming.block.coalesce": {
1013
+ "label": "Mattermost Block Streaming Coalesce",
1014
+ "help": "Merge streamed Mattermost block replies before final delivery."
1015
+ },
1016
+ "streaming.preview.toolProgress": {
1017
+ "label": "Mattermost Draft Tool Progress",
1018
+ "help": "Show tool/progress activity in the live draft preview post (default: true). Set false to hide interim tool updates while the draft preview stays active."
1019
+ },
1020
+ "streaming.preview.commandText": {
1021
+ "label": "Mattermost Draft Command Text",
1022
+ "help": "Command/exec detail in preview tool-progress lines: \"raw\" preserves released behavior; \"status\" shows only the tool label."
1023
+ },
1002
1024
  "streaming.progress.label": {
1003
1025
  "label": "Mattermost Progress Label",
1004
1026
  "help": "Initial progress draft title. Use \"auto\" for built-in single-word labels, a custom string, or false to hide the title."
@@ -1022,22 +1044,6 @@
1022
1044
  "streaming.progress.commandText": {
1023
1045
  "label": "Mattermost Progress Command Text",
1024
1046
  "help": "Command/exec detail in progress draft lines: \"raw\" preserves released behavior; \"status\" shows only the tool label."
1025
- },
1026
- "streaming.preview.toolProgress": {
1027
- "label": "Mattermost Draft Tool Progress",
1028
- "help": "Show tool/progress activity in the live draft preview post (default: true). Set false to hide interim tool updates while the draft preview stays active."
1029
- },
1030
- "streaming.preview.commandText": {
1031
- "label": "Mattermost Draft Command Text",
1032
- "help": "Command/exec detail in preview tool-progress lines: \"raw\" preserves released behavior; \"status\" shows only the tool label."
1033
- },
1034
- "streaming.block.enabled": {
1035
- "label": "Mattermost Block Streaming Enabled",
1036
- "help": "Enable chunked block-style Mattermost preview delivery when channels.mattermost.streaming.mode=\"block\"."
1037
- },
1038
- "streaming.block.coalesce": {
1039
- "label": "Mattermost Block Streaming Coalesce",
1040
- "help": "Merge streamed Mattermost block replies before final delivery."
1041
1047
  }
1042
1048
  }
1043
1049
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openclaw/mattermost",
3
- "version": "2026.7.2-beta.4",
3
+ "version": "2026.7.2-beta.7",
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.7.2-beta.4"
15
+ "openclaw": ">=2026.7.2-beta.7"
16
16
  },
17
17
  "peerDependenciesMeta": {
18
18
  "openclaw": {
@@ -87,10 +87,10 @@
87
87
  "allowInvalidConfigRecovery": true
88
88
  },
89
89
  "compat": {
90
- "pluginApi": ">=2026.7.2-beta.4"
90
+ "pluginApi": ">=2026.7.2-beta.7"
91
91
  },
92
92
  "build": {
93
- "openclawVersion": "2026.7.2-beta.4",
93
+ "openclawVersion": "2026.7.2-beta.7",
94
94
  "bundledDist": false
95
95
  },
96
96
  "release": {
@@ -105,7 +105,6 @@
105
105
  "files": [
106
106
  "dist/**",
107
107
  "openclaw.plugin.json",
108
- "npm-shrinkwrap.json",
109
108
  "README.md"
110
109
  ],
111
110
  "bundledDependencies": [
@@ -1,54 +0,0 @@
1
- {
2
- "name": "@openclaw/mattermost",
3
- "version": "2026.7.2-beta.4",
4
- "lockfileVersion": 3,
5
- "requires": true,
6
- "packages": {
7
- "": {
8
- "name": "@openclaw/mattermost",
9
- "version": "2026.7.2-beta.4",
10
- "dependencies": {
11
- "ws": "8.21.1",
12
- "zod": "4.4.3"
13
- },
14
- "peerDependencies": {
15
- "openclaw": ">=2026.7.2-beta.4"
16
- },
17
- "peerDependenciesMeta": {
18
- "openclaw": {
19
- "optional": true
20
- }
21
- }
22
- },
23
- "node_modules/ws": {
24
- "version": "8.21.1",
25
- "resolved": "https://registry.npmjs.org/ws/-/ws-8.21.1.tgz",
26
- "integrity": "sha512-+0NTnW77fFN/DjQi6k/Sq/Yvk4Sgajw7urW8V+asjXnRgDs9gyGkdb7EzgfhA4goXsRIZKE28fzIXBHEzhuiWw==",
27
- "license": "MIT",
28
- "engines": {
29
- "node": ">=10.0.0"
30
- },
31
- "peerDependencies": {
32
- "bufferutil": "^4.0.1",
33
- "utf-8-validate": ">=5.0.2"
34
- },
35
- "peerDependenciesMeta": {
36
- "bufferutil": {
37
- "optional": true
38
- },
39
- "utf-8-validate": {
40
- "optional": true
41
- }
42
- }
43
- },
44
- "node_modules/zod": {
45
- "version": "4.4.3",
46
- "resolved": "https://registry.npmjs.org/zod/-/zod-4.4.3.tgz",
47
- "integrity": "sha512-ytENFjIJFl2UwYglde2jchW2Hwm4GJFLDiSXWdTrJQBIN9Fcyp7n4DhxJEiWNAJMV1/BqWfW/kkg71UDcHJyTQ==",
48
- "license": "MIT",
49
- "funding": {
50
- "url": "https://github.com/sponsors/colinhacks"
51
- }
52
- }
53
- }
54
- }