@openclaw/mattermost 2026.9.6 → 2026.9.8

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.
package/assets/icon.png CHANGED
Binary file
@@ -1,3 +1,3 @@
1
- import { t as mattermostPlugin } from "./channel-plugin-runtime-yAOg5GcM.mjs";
2
- import { t as mattermostSetupPlugin } from "./channel-plugin-api-CzBhdovL.mjs";
1
+ import { t as mattermostPlugin } from "./channel-plugin-runtime-B0CAMiHe.mjs";
2
+ import { t as mattermostSetupPlugin } from "./channel-plugin-api-DXqHarCt.mjs";
3
3
  export { mattermostPlugin, mattermostSetupPlugin };
@@ -1,5 +1,5 @@
1
- import { s as isMattermostConfigured } from "./normalize-DM54w7ud.mjs";
2
- import { a as describeMattermostAccount, i as MattermostChannelConfigSchema, n as mattermostSetupWizard, o as mattermostConfigAdapter, r as mattermostSetupContract, s as mattermostMeta } from "./channel-plugin-runtime-yAOg5GcM.mjs";
1
+ import { s as isMattermostConfigured } from "./normalize-BCjtmxtp.mjs";
2
+ import { a as describeMattermostAccount, i as MattermostChannelConfigSchema, n as mattermostSetupWizard, o as mattermostConfigAdapter, r as mattermostSetupContract, s as mattermostMeta } from "./channel-plugin-runtime-B0CAMiHe.mjs";
3
3
  import { t as resolveMattermostGatewayAuthBypassPaths } from "./gateway-auth-bypass-B93t91oq.mjs";
4
4
  //#region extensions/mattermost/src/channel.setup.ts
5
5
  const mattermostSetupPlugin = {
@@ -1,8 +1,8 @@
1
- import { h as normalizeMattermostBaseUrl } from "./client-BSSVve1x.mjs";
1
+ import { h as normalizeMattermostBaseUrl } from "./client-CVeeTqCO.mjs";
2
2
  import { t as mattermostIngressIdentity } from "./ingress-identity-DNl4yQSc.mjs";
3
- import { a as resolveMattermostPresentation, c as listMattermostAccountIds, d as resolveMattermostReplyToMode, f as buildSecretInputSchema, i as requiresMattermostMediaUpload, l as resolveDefaultMattermostAccountId, n as normalizeMattermostMessagingTarget, o as inspectMattermostAccount, p as hasConfiguredSecretInput, s as isMattermostConfigured$1, t as looksLikeMattermostTargetId, u as resolveMattermostAccount } from "./normalize-DM54w7ud.mjs";
3
+ import { a as resolveMattermostPresentation, c as listMattermostAccountIds, d as resolveMattermostReplyToMode, i as requiresMattermostMediaUpload, l as resolveDefaultMattermostAccountId, n as normalizeMattermostMessagingTarget, o as inspectMattermostAccount, s as isMattermostConfigured$1, t as looksLikeMattermostTargetId, u as resolveMattermostAccount } from "./normalize-BCjtmxtp.mjs";
4
4
  import { t as resolveMattermostGatewayAuthBypassPaths } from "./gateway-auth-bypass-B93t91oq.mjs";
5
- import { n as normalizeCompatibilityConfig, t as legacyConfigRules } from "./doctor-contract-mvORF4f6.mjs";
5
+ import { n as normalizeCompatibilityConfig, t as legacyConfigRules } from "./doctor-contract-BI6SB2cd.mjs";
6
6
  import { n as collectRuntimeConfigAssignments, r as secretTargetRegistryEntries } from "./secret-contract-qg3NXRlS.mjs";
7
7
  import { normalizeLowercaseStringOrEmpty, normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
8
8
  import { buildPassiveProbedChannelStatusSummary } from "openclaw/plugin-sdk/extension-shared";
@@ -12,7 +12,8 @@ import { formatNormalizedAllowFromEntries } from "openclaw/plugin-sdk/allow-from
12
12
  import { createLoggedPairingApprovalNotifier } from "openclaw/plugin-sdk/channel-pairing";
13
13
  import { createAccountStatusSink, createChannelMessageAdapterFromOutbound } from "openclaw/plugin-sdk/channel-outbound";
14
14
  import { describeAccountSnapshot } from "openclaw/plugin-sdk/account-helpers";
15
- import { DEFAULT_ACCOUNT_ID as DEFAULT_ACCOUNT_ID$1, buildChannelOutboundSessionRoute, buildThreadAwareOutboundSessionRoute, stripChannelTargetPrefix, stripTargetKindPrefix } from "openclaw/plugin-sdk/core";
15
+ import { buildChannelOutboundSessionRoute, buildThreadAwareOutboundSessionRoute, stripChannelTargetPrefix, stripTargetKindPrefix } from "openclaw/plugin-sdk/core";
16
+ import { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "openclaw/plugin-sdk/account-id";
16
17
  import { jsonResult, readPositiveIntegerParam, readStringArrayParam, readStringParam, withNormalizedTimestamp } from "openclaw/plugin-sdk/channel-actions";
17
18
  import { createChannelConfigUiHints, createChatChannelPlugin } from "openclaw/plugin-sdk/channel-core";
18
19
  import { identityEntryAuthenticationClassifier } from "openclaw/plugin-sdk/channel-ingress-runtime";
@@ -25,9 +26,9 @@ import { resolvePayloadMediaUrls, sendTextMediaPayload } from "openclaw/plugin-s
25
26
  import { createComputedAccountStatusAdapter, createDefaultChannelRuntimeState } from "openclaw/plugin-sdk/status-helpers";
26
27
  import { chunkTextForOutbound, sanitizeAssistantVisibleText } from "openclaw/plugin-sdk/text-chunking";
27
28
  import { createChannelApprovalAuth } from "openclaw/plugin-sdk/approval-auth-runtime";
28
- import { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "openclaw/plugin-sdk/account-id";
29
+ import { buildSecretInputSchema, hasConfiguredSecretInput } from "openclaw/plugin-sdk/secret-input";
29
30
  import { adaptScopedAccountAccessor, createScopedChannelConfigAdapter } from "openclaw/plugin-sdk/channel-config-helpers";
30
- import { BlockStreamingCoalesceSchema, ChannelImplicitMentionsSchema, ContextVisibilityModeSchema, DmPolicySchema, GroupPolicySchema, MarkdownConfigSchema, buildChannelConfigSchema, buildGroupEntrySchema, buildMultiAccountChannelSchema, requireOpenAllowFrom } from "openclaw/plugin-sdk/channel-config-schema";
31
+ import { ChannelImplicitMentionsSchema, ChannelPreviewStreamingConfigSchema, ChannelStreamingPreviewSchema, ChannelStreamingProgressSchema, ContextVisibilityModeSchema, DmPolicySchema, GroupPolicySchema, MarkdownConfigSchema, buildChannelConfigSchema, buildGroupEntrySchema, buildMultiAccountChannelSchema, requireOpenAllowFrom } from "openclaw/plugin-sdk/channel-config-schema";
31
32
  import { defineChannelSetupContract } from "openclaw/plugin-sdk/channel-setup";
32
33
  import { applyAccountNameToChannelSection, applySetupAccountConfigPatch, baseUrlTextInput, createSetupTranslator, createStandardChannelSetupStatus, defineTokenCredential, formatDocsLink, migrateBaseNameToDefaultAccount, setSetupChannelEnabled } from "openclaw/plugin-sdk/setup";
33
34
  import { createSetupInputPresenceValidator } from "openclaw/plugin-sdk/setup-runtime";
@@ -121,7 +122,7 @@ function createMattermostDeliveryProgressReporter(onDeliveryResult) {
121
122
  }
122
123
  //#endregion
123
124
  //#region extensions/mattermost/src/config-schema-core.ts
124
- const MattermostGroupSchema = buildGroupEntrySchema().omit({
125
+ const MattermostGroupSchema = buildGroupEntrySchema({ requireMentionInBotThreads: z.boolean().optional() }).omit({
125
126
  tools: true,
126
127
  toolsBySender: true,
127
128
  skills: true,
@@ -129,15 +130,6 @@ const MattermostGroupSchema = buildGroupEntrySchema().omit({
129
130
  allowFrom: true,
130
131
  systemPrompt: true
131
132
  });
132
- function requireMattermostOpenAllowFrom(params) {
133
- requireOpenAllowFrom({
134
- policy: params.policy,
135
- allowFrom: params.allowFrom,
136
- ctx: params.ctx,
137
- path: ["allowFrom"],
138
- message: "channels.mattermost.dmPolicy=\"open\" requires channels.mattermost.allowFrom to include \"*\""
139
- });
140
- }
141
133
  const DmChannelRetrySchema = z.object({
142
134
  /** Maximum number of retry attempts for DM channel creation (default: 3) */
143
135
  maxRetries: z.number().int().min(0).max(10).optional(),
@@ -167,35 +159,13 @@ const MattermostSlashCommandsSchema = z.object({
167
159
  const MattermostNetworkSchema = z.object({
168
160
  /** Dangerous opt-in for self-hosted Mattermost on trusted private/internal hosts. */
169
161
  dangerouslyAllowPrivateNetwork: z.boolean().optional() }).strict().optional();
170
- const MattermostStreamingModeSchema = z.enum([
171
- "off",
172
- "partial",
173
- "block",
174
- "progress"
175
- ]);
176
- const MattermostStreamingProgressSchema = z.object({
177
- label: z.union([z.string(), z.literal(false)]).optional(),
178
- labels: z.array(z.string()).optional(),
179
- maxLines: z.number().int().positive().optional(),
180
- maxLineChars: z.number().int().positive().optional(),
181
- toolProgress: z.boolean().optional(),
182
- commandText: z.enum(["raw", "status"]).optional()
183
- }).strict();
184
- const MattermostStreamingPreviewSchema = z.object({
185
- toolProgress: z.boolean().optional(),
186
- commandText: z.enum(["raw", "status"]).optional()
187
- }).strict();
188
- const MattermostStreamingBlockSchema = z.object({
189
- enabled: z.boolean().optional(),
190
- coalesce: BlockStreamingCoalesceSchema.optional()
191
- }).strict();
192
- const MattermostStreamingSchema = z.object({
193
- mode: MattermostStreamingModeSchema.optional(),
194
- chunkMode: z.enum(["length", "newline"]).optional(),
195
- preview: MattermostStreamingPreviewSchema.optional(),
196
- progress: MattermostStreamingProgressSchema.optional(),
197
- block: MattermostStreamingBlockSchema.optional()
198
- }).strict();
162
+ const MattermostStreamingSchema = ChannelPreviewStreamingConfigSchema.extend({
163
+ preview: ChannelStreamingPreviewSchema.omit({ chunk: true }).optional(),
164
+ progress: ChannelStreamingProgressSchema.omit({
165
+ commentary: true,
166
+ narration: true
167
+ }).optional()
168
+ });
199
169
  const MattermostReplyToModeSchema = z.enum([
200
170
  "off",
201
171
  "first",
@@ -226,6 +196,7 @@ const MattermostAccountSchemaBase = z.object({
226
196
  ]).optional(),
227
197
  oncharPrefixes: z.array(z.string()).optional(),
228
198
  requireMention: z.boolean().optional(),
199
+ requireMentionInBotThreads: z.boolean().optional(),
229
200
  implicitMentions: ChannelImplicitMentionsSchema.optional(),
230
201
  dmPolicy: DmPolicySchema.optional().default("pairing"),
231
202
  allowFrom: z.array(z.union([z.string(), z.number()])).optional(),
@@ -255,10 +226,12 @@ const MattermostAccountSchemaBase = z.object({
255
226
  const MattermostConfigSchema = buildMultiAccountChannelSchema(MattermostAccountSchemaBase, {
256
227
  optionalAccount: true,
257
228
  refine: (value, ctx) => {
258
- requireMattermostOpenAllowFrom({
229
+ requireOpenAllowFrom({
259
230
  policy: value.dmPolicy,
260
231
  allowFrom: value.allowFrom,
261
- ctx
232
+ ctx,
233
+ path: ["allowFrom"],
234
+ message: "channels.mattermost.dmPolicy=\"open\" requires channels.mattermost.allowFrom to include \"*\""
262
235
  });
263
236
  }
264
237
  });
@@ -269,6 +242,14 @@ const mattermostChannelConfigUiHints = {
269
242
  label: "Mattermost",
270
243
  help: "Mattermost channel provider configuration for bot auth, access policy, slash commands, and preview streaming."
271
244
  },
245
+ requireMentionInBotThreads: {
246
+ label: "Mention in Bot Threads",
247
+ help: "Require an explicit mention or configured trigger in threads rooted in this bot's own posts. Set false to accept unmentioned follow-ups; omit to preserve existing mention and participation behavior."
248
+ },
249
+ "groups.*.requireMentionInBotThreads": {
250
+ label: "Mention in Bot Threads",
251
+ help: "Override bot-created thread mention policy for this Mattermost channel. Exact channel settings override the wildcard, then the account setting."
252
+ },
272
253
  ...createChannelConfigUiHints({
273
254
  channelLabel: "Mattermost",
274
255
  dmPolicy: { channelKey: "mattermost" },
@@ -293,7 +274,7 @@ const isMattermostMutableAllowEntry = buildMutableAllowEntryDetector({ stableIdP
293
274
  const collectMattermostMutableAllowlistWarnings = createDangerousNameMatchingMutableAllowlistWarningCollector({
294
275
  channel: "mattermost",
295
276
  detector: isMattermostMutableAllowEntry,
296
- collectLists: (scope) => collectStandardAllowlistLists(scope)
277
+ collectLists: collectStandardAllowlistLists
297
278
  });
298
279
  const mattermostDoctor = {
299
280
  legacyConfigRules,
@@ -425,12 +406,6 @@ const channel$1 = "mattermost";
425
406
  function isMattermostConfigured(account) {
426
407
  return (Boolean(account.botToken?.trim()) || hasConfiguredSecretInput(account.config.botToken)) && Boolean(account.baseUrl);
427
408
  }
428
- function resolveMattermostAccountWithSecrets(cfg, accountId) {
429
- return inspectMattermostAccount({
430
- cfg,
431
- accountId
432
- });
433
- }
434
409
  function applyMattermostSetupConfigPatch(params) {
435
410
  const namedConfig = applyAccountNameToChannelSection({
436
411
  cfg: params.cfg,
@@ -543,7 +518,10 @@ const mattermostSetupWizard = {
543
518
  unconfiguredHint: t("wizard.channels.statusNeedsSetup"),
544
519
  configuredScore: 2,
545
520
  unconfiguredScore: 1,
546
- resolveConfigured: ({ cfg, accountId }) => isMattermostConfigured(resolveMattermostAccountWithSecrets(cfg, accountId ?? DEFAULT_ACCOUNT_ID))
521
+ resolveConfigured: ({ cfg, accountId }) => isMattermostConfigured(inspectMattermostAccount({
522
+ cfg,
523
+ accountId: accountId ?? DEFAULT_ACCOUNT_ID
524
+ }))
547
525
  }),
548
526
  introNote: {
549
527
  title: t("wizard.mattermost.botTokenTitle"),
@@ -554,14 +532,20 @@ const mattermostSetupWizard = {
554
532
  t("wizard.mattermost.helpBotMember"),
555
533
  t("wizard.channels.docs", { link: formatDocsLink("/mattermost", "mattermost") })
556
534
  ],
557
- shouldShow: ({ cfg, accountId }) => !isMattermostConfigured(resolveMattermostAccountWithSecrets(cfg, accountId))
535
+ shouldShow: ({ cfg, accountId }) => !isMattermostConfigured(inspectMattermostAccount({
536
+ cfg,
537
+ accountId
538
+ }))
558
539
  },
559
540
  envShortcut: {
560
541
  prompt: t("wizard.mattermost.envPrompt"),
561
542
  preferredEnvVar: "MATTERMOST_BOT_TOKEN",
562
543
  isAvailable: ({ cfg, accountId }) => {
563
544
  if (accountId !== DEFAULT_ACCOUNT_ID) return false;
564
- const resolvedAccount = resolveMattermostAccountWithSecrets(cfg, accountId);
545
+ const resolvedAccount = inspectMattermostAccount({
546
+ cfg,
547
+ accountId
548
+ });
565
549
  const hasConfigValues = hasConfiguredSecretInput(resolvedAccount.config.botToken) || Boolean(resolvedAccount.config.baseUrl?.trim());
566
550
  return Boolean(process.env.MATTERMOST_BOT_TOKEN?.trim() && process.env.MATTERMOST_URL?.trim() && !hasConfigValues);
567
551
  },
@@ -581,7 +565,7 @@ const mattermostSetupWizard = {
581
565
  envPrompt: t("wizard.mattermost.envPrompt"),
582
566
  keepPrompt: t("wizard.mattermost.botTokenKeep"),
583
567
  inputPrompt: t("wizard.mattermost.botTokenInput"),
584
- resolveAccount: ({ cfg, accountId }) => resolveMattermostAccountWithSecrets(cfg, accountId),
568
+ resolveAccount: inspectMattermostAccount,
585
569
  accountConfigured: isMattermostConfigured,
586
570
  patchAccount: ({ cfg, accountId, patch }) => applyMattermostSetupConfigPatch({
587
571
  cfg,
@@ -595,11 +579,14 @@ const mattermostSetupWizard = {
595
579
  configKey: "baseUrl",
596
580
  message: t("wizard.mattermost.baseUrlPrompt"),
597
581
  confirmCurrentValue: false,
598
- resolveAccount: ({ cfg, accountId }) => resolveMattermostAccountWithSecrets(cfg, accountId),
582
+ resolveAccount: inspectMattermostAccount,
599
583
  currentValue: (account) => account.baseUrl ?? process.env.MATTERMOST_URL?.trim(),
600
584
  includeInitialValue: true,
601
585
  shouldPrompt: ({ cfg, accountId, credentialValues, currentValue }) => {
602
- const resolvedAccount = resolveMattermostAccountWithSecrets(cfg, accountId);
586
+ const resolvedAccount = inspectMattermostAccount({
587
+ cfg,
588
+ accountId
589
+ });
603
590
  const tokenConfigured = Boolean(resolvedAccount.botToken?.trim()) || hasConfiguredSecretInput(resolvedAccount.config.botToken);
604
591
  return Boolean(credentialValues.botToken) || !tokenConfigured || !currentValue;
605
592
  },
@@ -615,7 +602,7 @@ const mattermostSetupWizard = {
615
602
  };
616
603
  //#endregion
617
604
  //#region extensions/mattermost/src/channel.ts
618
- const loadMattermostChannelRuntime = createLazyRuntimeModule(() => import("./channel.runtime-CihvzY84.mjs"));
605
+ const loadMattermostChannelRuntime = createLazyRuntimeModule(() => import("./channel.runtime-E2B5dNrh.mjs"));
619
606
  const MATTERMOST_PRESENTATION_CAPABILITIES = {
620
607
  supported: true,
621
608
  buttons: true,
@@ -650,19 +637,25 @@ const mattermostSecurityAdapter = createRestrictSendersChannelSecurity({
650
637
  findingTitle: "Mattermost security warning",
651
638
  policyPathSuffix: "dmPolicy",
652
639
  classifyEntryAuthentication: identityEntryAuthenticationClassifier(mattermostIngressIdentity),
653
- normalizeDmEntry: (raw) => normalizeMattermostAllowEntry(raw)
640
+ normalizeDmEntry: normalizeMattermostAllowEntry
654
641
  });
655
- function describeMattermostMessageTool({ cfg, accountId }) {
656
- const enabledAccounts = (accountId ? [inspectMattermostAccount({
642
+ function listEnabledMattermostAccounts({ cfg, accountId }) {
643
+ return (accountId ? [inspectMattermostAccount({
657
644
  cfg,
658
645
  accountId
659
646
  })] : listMattermostAccountIds(cfg).map((listedAccountId) => inspectMattermostAccount({
660
647
  cfg,
661
648
  accountId: listedAccountId
662
- }))).filter((account) => account.enabled).filter((account) => Boolean(account.botToken?.trim() && account.baseUrl?.trim()));
649
+ }))).filter((account) => account.enabled && account.botToken?.trim() && account.baseUrl?.trim());
650
+ }
651
+ function describeMattermostMessageTool({ cfg, accountId }) {
652
+ const enabledAccounts = listEnabledMattermostAccounts({
653
+ cfg,
654
+ accountId
655
+ });
663
656
  const actions = [];
664
657
  if (enabledAccounts.length > 0) actions.push("send");
665
- const actionsConfig = cfg.channels?.mattermost?.actions;
658
+ const actionsConfig = (cfg.channels?.mattermost)?.actions;
666
659
  const baseMessages = actionsConfig?.messages;
667
660
  const baseReactions = actionsConfig?.reactions;
668
661
  if (enabledAccounts.some((account) => {
@@ -674,15 +667,6 @@ function describeMattermostMessageTool({ cfg, accountId }) {
674
667
  capabilities: enabledAccounts.length > 0 ? ["presentation"] : []
675
668
  };
676
669
  }
677
- function hasConfiguredMattermostDirectoryAccount({ cfg, accountId }) {
678
- return (accountId ? [inspectMattermostAccount({
679
- cfg,
680
- accountId
681
- })] : listMattermostAccountIds(cfg).map((listedAccountId) => inspectMattermostAccount({
682
- cfg,
683
- accountId: listedAccountId
684
- }))).some((account) => Boolean(account.enabled && account.botToken?.trim() && account.baseUrl?.trim()));
685
- }
686
670
  function extractMattermostToolSend(args) {
687
671
  if (normalizeOptionalString(args.action) !== "send") return null;
688
672
  const to = normalizeOptionalString(args.to) ?? normalizeOptionalString(args.target);
@@ -701,7 +685,7 @@ function resolveMattermostAutoThreadId(params) {
701
685
  const replyToId = normalizeOptionalString(params.replyToId);
702
686
  const context = params.toolContext;
703
687
  const currentThreadId = normalizeOptionalString(context?.currentThreadTs);
704
- const currentMessageId = typeof context?.currentMessageId === "number" ? String(context.currentMessageId) : normalizeOptionalString(context?.currentMessageId);
688
+ const currentMessageId = normalizeMattermostThreadId(context?.currentMessageId);
705
689
  const currentTarget = normalizeMattermostThreadTarget(context?.currentChannelId);
706
690
  if (currentThreadId && currentTarget === normalizeMattermostThreadTarget(params.to)) {
707
691
  if (replyToId === currentMessageId) return currentThreadId;
@@ -746,11 +730,11 @@ function buildMattermostThreadingToolContext(params) {
746
730
  };
747
731
  }
748
732
  async function listMattermostDirectoryGroups(params) {
749
- if (!hasConfiguredMattermostDirectoryAccount(params)) return [];
733
+ if (listEnabledMattermostAccounts(params).length === 0) return [];
750
734
  return (await loadMattermostChannelRuntime()).listMattermostDirectoryGroups(params);
751
735
  }
752
736
  async function listMattermostDirectoryPeers(params) {
753
- if (!hasConfiguredMattermostDirectoryAccount(params)) return [];
737
+ if (listEnabledMattermostAccounts(params).length === 0) return [];
754
738
  return (await loadMattermostChannelRuntime()).listMattermostDirectoryPeers(params);
755
739
  }
756
740
  const mattermostMessageActions = {
@@ -778,19 +762,18 @@ const mattermostMessageActions = {
778
762
  } } : {}
779
763
  };
780
764
  },
781
- supportsAction: ({ action }) => {
782
- return action === "react" || action === "read";
783
- },
765
+ supportsAction: ({ action }) => action === "react" || action === "read",
784
766
  handleAction: async ({ action, params, cfg, accountId, conversationReadOrigin, requesterAccountId, toolContext }) => {
767
+ if (action !== "read" && action !== "react") throw new Error(`Unsupported Mattermost action: ${action}`);
768
+ const resolvedAccountId = accountId ?? resolveDefaultMattermostAccountId(cfg);
769
+ const account = resolveMattermostAccount({
770
+ cfg,
771
+ accountId: resolvedAccountId
772
+ });
773
+ if (!account.enabled) throw new Error(`Mattermost account "${resolvedAccountId}" is disabled`);
774
+ const actionsConfig = (cfg.channels?.mattermost)?.actions;
785
775
  if (action === "read") {
786
- const resolvedAccountId = accountId ?? resolveDefaultMattermostAccountId(cfg);
787
- const mattermostConfig = cfg.channels?.mattermost;
788
- const account = resolveMattermostAccount({
789
- cfg,
790
- accountId: resolvedAccountId
791
- });
792
- if (!account.enabled) throw new Error(`Mattermost account "${resolvedAccountId}" is disabled`);
793
- if (!(account.config.actions?.messages ?? mattermostConfig?.actions?.messages ?? false)) throw new Error("Mattermost message reads are disabled in config");
776
+ if (!(account.config.actions?.messages ?? actionsConfig?.messages ?? false)) throw new Error("Mattermost message reads are disabled in config");
794
777
  const rawTarget = readStringParam(params, "to") ?? readStringParam(params, "channelId") ?? readStringParam(params, "target");
795
778
  if (!rawTarget) throw new Error("Mattermost read requires target, to, or channelId.");
796
779
  const normalizedTarget = normalizeMattermostMessagingTarget(rawTarget);
@@ -819,36 +802,26 @@ const mattermostMessageActions = {
819
802
  hasMore: result.hasMore
820
803
  });
821
804
  }
822
- if (action === "react") {
823
- const resolvedAccountId = accountId ?? resolveDefaultMattermostAccountId(cfg);
824
- const mattermostConfig = cfg.channels?.mattermost;
825
- const account = resolveMattermostAccount({
826
- cfg,
827
- accountId: resolvedAccountId
828
- });
829
- if (!account.enabled) throw new Error(`Mattermost account "${resolvedAccountId}" is disabled`);
830
- if (!(account.config.actions?.reactions ?? mattermostConfig?.actions?.reactions ?? true)) throw new Error("Mattermost reactions are disabled in config");
831
- const { postId, emojiName, remove } = parseMattermostReactActionParams(params);
832
- const authorizedTarget = normalizeOptionalString(params.to);
833
- const runtime = await loadMattermostChannelRuntime();
834
- const result = await (remove ? runtime.removeMattermostReaction : runtime.addMattermostReaction)({
835
- cfg,
836
- postId,
837
- emojiName,
838
- accountId: resolvedAccountId,
839
- authorizedTarget,
840
- conversationReadOrigin
841
- });
842
- if (!result.ok) throw new Error(result.error);
843
- return {
844
- content: [{
845
- type: "text",
846
- text: remove ? `Removed reaction :${emojiName}: from ${postId}` : `Reacted with :${emojiName}: on ${postId}`
847
- }],
848
- details: {}
849
- };
850
- }
851
- throw new Error(`Unsupported Mattermost action: ${action}`);
805
+ if (!(account.config.actions?.reactions ?? actionsConfig?.reactions ?? true)) throw new Error("Mattermost reactions are disabled in config");
806
+ const { postId, emojiName, remove } = parseMattermostReactActionParams(params);
807
+ const authorizedTarget = normalizeOptionalString(params.to);
808
+ const runtime = await loadMattermostChannelRuntime();
809
+ const result = await (remove ? runtime.removeMattermostReaction : runtime.addMattermostReaction)({
810
+ cfg,
811
+ postId,
812
+ emojiName,
813
+ accountId: resolvedAccountId,
814
+ authorizedTarget,
815
+ conversationReadOrigin
816
+ });
817
+ if (!result.ok) throw new Error(result.error);
818
+ return {
819
+ content: [{
820
+ type: "text",
821
+ text: remove ? `Removed reaction :${emojiName}: from ${postId}` : `Reacted with :${emojiName}: on ${postId}`
822
+ }],
823
+ details: {}
824
+ };
852
825
  }
853
826
  };
854
827
  function parseMattermostReactActionParams(params) {
@@ -885,6 +858,23 @@ function resolveMattermostSendAttachmentMedia(params) {
885
858
  if (mediaUrls.length > 1) throw new Error("Mattermost send supports one attachment per message; split multiple mediaUrls or attachments[] entries into separate sends.");
886
859
  return mediaUrls[0];
887
860
  }
861
+ async function sendMattermostMedia(ctx, content = ctx) {
862
+ return toMattermostOutboundResult(await (await loadMattermostChannelRuntime()).sendMessageMattermost(ctx.to, content.text, {
863
+ cfg: ctx.cfg,
864
+ accountId: ctx.accountId ?? void 0,
865
+ mediaUrl: content.mediaUrl,
866
+ mediaLocalRoots: ctx.mediaLocalRoots ?? ctx.mediaAccess?.localRoots,
867
+ mediaReadFile: ctx.mediaReadFile ?? ctx.mediaAccess?.readFile,
868
+ ...ctx.mediaAccess?.workspaceDir ? { workspaceDir: ctx.mediaAccess.workspaceDir } : {},
869
+ requireMediaUpload: requiresMattermostMediaUpload(content.mediaUrl) ? true : void 0,
870
+ replyToId: ctx.replyToId ?? (ctx.threadId != null ? String(ctx.threadId) : void 0),
871
+ ...content.buttons?.length ? { buttons: content.buttons } : {},
872
+ ...content.attachmentText !== void 0 ? { attachmentText: content.attachmentText } : {},
873
+ assertDirectAdapterHandoff: ctx.assertDirectAdapterHandoff,
874
+ onPlatformSendDispatch: ctx.onPlatformSendDispatch,
875
+ onDeliveryResult: createMattermostDeliveryProgressReporter(ctx.onDeliveryResult)
876
+ }));
877
+ }
888
878
  const mattermostOutbound = {
889
879
  deliveryMode: "direct",
890
880
  chunker: chunkTextForOutbound,
@@ -929,22 +919,13 @@ const mattermostOutbound = {
929
919
  ...ctx.payload,
930
920
  mediaUrl: ctx.payload.mediaUrl ?? ctx.mediaUrl
931
921
  }).map((url) => url.trim()).find(Boolean);
932
- const result = await (await loadMattermostChannelRuntime()).sendMessageMattermost(ctx.to, ctx.payload.text ?? ctx.text, {
933
- cfg: ctx.cfg,
934
- accountId: ctx.accountId ?? void 0,
922
+ const result = await sendMattermostMedia(ctx, {
923
+ text: ctx.payload.text ?? ctx.text,
935
924
  mediaUrl,
936
- mediaLocalRoots: ctx.mediaLocalRoots ?? ctx.mediaAccess?.localRoots,
937
- mediaReadFile: ctx.mediaReadFile ?? ctx.mediaAccess?.readFile,
938
- ...ctx.mediaAccess?.workspaceDir ? { workspaceDir: ctx.mediaAccess.workspaceDir } : {},
939
- requireMediaUpload: requiresMattermostMediaUpload(mediaUrl) ? true : void 0,
940
- replyToId: ctx.replyToId ?? (ctx.threadId != null ? String(ctx.threadId) : void 0),
941
- buttons: buttons?.length ? buttons : void 0,
942
- attachmentText,
943
- assertDirectAdapterHandoff: ctx.assertDirectAdapterHandoff,
944
- onPlatformSendDispatch: ctx.onPlatformSendDispatch,
945
- onDeliveryResult: createMattermostDeliveryProgressReporter(ctx.onDeliveryResult)
925
+ buttons,
926
+ attachmentText
946
927
  });
947
- return attachChannelToResult("mattermost", toMattermostOutboundResult(result));
928
+ return attachChannelToResult("mattermost", result);
948
929
  }
949
930
  return await sendTextMediaPayload({
950
931
  channel: "mattermost",
@@ -973,19 +954,7 @@ const mattermostOutbound = {
973
954
  onPlatformSendDispatch: ctx.onPlatformSendDispatch,
974
955
  onDeliveryResult: createMattermostDeliveryProgressReporter(ctx.onDeliveryResult)
975
956
  })),
976
- sendMedia: async ({ cfg, to, text, mediaUrl, mediaAccess, mediaLocalRoots, mediaReadFile, accountId, replyToId, threadId, assertDirectAdapterHandoff, onPlatformSendDispatch, onDeliveryResult }) => toMattermostOutboundResult(await (await loadMattermostChannelRuntime()).sendMessageMattermost(to, text, {
977
- cfg,
978
- accountId: accountId ?? void 0,
979
- mediaUrl,
980
- mediaLocalRoots: mediaLocalRoots ?? mediaAccess?.localRoots,
981
- mediaReadFile: mediaReadFile ?? mediaAccess?.readFile,
982
- ...mediaAccess?.workspaceDir ? { workspaceDir: mediaAccess.workspaceDir } : {},
983
- requireMediaUpload: requiresMattermostMediaUpload(mediaUrl) ? true : void 0,
984
- replyToId: replyToId ?? (threadId != null ? String(threadId) : void 0),
985
- assertDirectAdapterHandoff,
986
- onPlatformSendDispatch,
987
- onDeliveryResult: createMattermostDeliveryProgressReporter(onDeliveryResult)
988
- }))
957
+ sendMedia: sendMattermostMedia
989
958
  })
990
959
  };
991
960
  const mattermostMessageAdapter = createChannelMessageAdapterFromOutbound({
@@ -1075,7 +1044,7 @@ const mattermostPlugin = createChatChannelPlugin({
1075
1044
  threadId: child
1076
1045
  } : { to: normalizeMattermostMessagingTarget(`channel:${child}`) };
1077
1046
  },
1078
- resolveOutboundSessionRoute: (params) => resolveMattermostOutboundSessionRoute(params),
1047
+ resolveOutboundSessionRoute: resolveMattermostOutboundSessionRoute,
1079
1048
  targetResolver: {
1080
1049
  looksLikeId: looksLikeMattermostTargetId,
1081
1050
  hint: "<channelId|user:ID|channel:ID>",
@@ -1095,7 +1064,7 @@ const mattermostPlugin = createChatChannelPlugin({
1095
1064
  }
1096
1065
  },
1097
1066
  status: createComputedAccountStatusAdapter({
1098
- defaultRuntime: createDefaultChannelRuntimeState(DEFAULT_ACCOUNT_ID$1, {
1067
+ defaultRuntime: createDefaultChannelRuntimeState(DEFAULT_ACCOUNT_ID, {
1099
1068
  connected: false,
1100
1069
  lastConnectedAt: null,
1101
1070
  lastDisconnect: null
@@ -1143,7 +1112,7 @@ const mattermostPlugin = createChatChannelPlugin({
1143
1112
  botTokenSource: account.botTokenSource
1144
1113
  });
1145
1114
  ctx.log?.info(`[${account.accountId}] starting channel`);
1146
- return (await loadMattermostChannelRuntime()).monitorMattermostProvider({
1115
+ return (await import("./monitor-BZyzPkkb.mjs")).monitorMattermostProvider({
1147
1116
  botToken: account.botToken ?? void 0,
1148
1117
  baseUrl: account.baseUrl ?? void 0,
1149
1118
  accountId: account.accountId,
@@ -1158,11 +1127,11 @@ const mattermostPlugin = createChatChannelPlugin({
1158
1127
  pairing: { text: {
1159
1128
  idLabel: "mattermostUserId",
1160
1129
  message: "OpenClaw: your access has been approved.",
1161
- normalizeAllowEntry: (entry) => normalizeMattermostAllowEntry(entry),
1130
+ normalizeAllowEntry: normalizeMattermostAllowEntry,
1162
1131
  notify: createLoggedPairingApprovalNotifier(({ id }) => `[mattermost] User ${id} approved for pairing`)
1163
1132
  } },
1164
1133
  threading: {
1165
- buildToolContext: (params) => buildMattermostThreadingToolContext(params),
1134
+ buildToolContext: buildMattermostThreadingToolContext,
1166
1135
  scopedAccountReplyToMode: {
1167
1136
  resolveAccount: (cfg, accountId) => resolveMattermostAccount({
1168
1137
  cfg,
@@ -1170,15 +1139,8 @@ const mattermostPlugin = createChatChannelPlugin({
1170
1139
  }),
1171
1140
  resolveReplyToMode: (account, chatType) => resolveMattermostReplyToMode(account, chatType === "direct" || chatType === "group" || chatType === "channel" ? chatType : "channel")
1172
1141
  },
1173
- resolveAutoThreadId: ({ to, replyToId, toolContext }) => resolveMattermostAutoThreadId({
1174
- to,
1175
- replyToId,
1176
- toolContext
1177
- }),
1178
- matchesToolContextTarget: ({ target, toolContext }) => matchesMattermostToolContextTarget({
1179
- target,
1180
- toolContext
1181
- }),
1142
+ resolveAutoThreadId: resolveMattermostAutoThreadId,
1143
+ matchesToolContextTarget: matchesMattermostToolContextTarget,
1182
1144
  resolveReplyTransport: ({ threadId, replyToId, replyToIsExplicit, replyDelivery }) => {
1183
1145
  const ambientThreadId = threadId != null ? String(threadId) : void 0;
1184
1146
  const isFlatDirect = replyDelivery?.chatType === "direct" && replyDelivery.replyToMode === "off";