@openclaw/mattermost 2026.9.1-beta.1 → 2026.9.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.
package/dist/api.js CHANGED
@@ -1,3 +1,3 @@
1
- import { r as isMattermostSenderAllowed } from "./monitor-auth-CVd_4FPD.js";
2
- import { t as buildButtonAttachments } from "./interactions-k47k-7SP.js";
1
+ import { t as buildButtonAttachments } from "./interactions-DF1FH27_.js";
2
+ import { r as isMattermostSenderAllowed } from "./monitor-auth-C6RGYyn-.js";
3
3
  export { buildButtonAttachments, isMattermostSenderAllowed };
@@ -1,4 +1,5 @@
1
- import { a as describeMattermostAccount, c as mattermostMeta, i as MattermostChannelConfigSchema, n as mattermostSetupWizard, o as isMattermostConfigured, r as mattermostSetupContract, s as mattermostConfigAdapter, t as mattermostPlugin } from "./channel-plugin-runtime-Bh8hcegp.js";
1
+ import { o as isMattermostConfigured } from "./normalize-R-ATEEHC.js";
2
+ import { a as describeMattermostAccount, i as MattermostChannelConfigSchema, n as mattermostSetupWizard, o as mattermostConfigAdapter, r as mattermostSetupContract, s as mattermostMeta, t as mattermostPlugin } from "./channel-plugin-runtime-C6tfh14W.js";
2
3
  import { t as resolveMattermostGatewayAuthBypassPaths } from "./gateway-auth-bypass-B93t91oq.js";
3
4
  //#region extensions/mattermost/src/channel.setup.ts
4
5
  const mattermostSetupPlugin = {
@@ -1,9 +1,9 @@
1
- import { m as normalizeMattermostBaseUrl } from "./client-DAIry9-2.js";
2
- import { a as inspectMattermostAccount, c as resolveMattermostAccount, d as hasConfiguredSecretInput, i as resolveMattermostPresentation, l as resolveMattermostReplyToMode, n as normalizeMattermostMessagingTarget, o as listMattermostAccountIds, r as requiresMattermostMediaUpload, s as resolveDefaultMattermostAccountId, t as looksLikeMattermostTargetId, u as buildSecretInputSchema } from "./normalize-bBDFEiyJ.js";
1
+ import { m as normalizeMattermostBaseUrl } from "./client-Dt7Q-j5B.js";
2
+ import { t as mattermostIngressIdentity } from "./ingress-identity-DNl4yQSc.js";
3
+ import { a as inspectMattermostAccount, c as resolveDefaultMattermostAccountId, d as buildSecretInputSchema, f as hasConfiguredSecretInput, i as resolveMattermostPresentation, l as resolveMattermostAccount, n as normalizeMattermostMessagingTarget, o as isMattermostConfigured$1, r as requiresMattermostMediaUpload, s as listMattermostAccountIds, t as looksLikeMattermostTargetId, u as resolveMattermostReplyToMode } from "./normalize-R-ATEEHC.js";
3
4
  import { t as resolveMattermostGatewayAuthBypassPaths } from "./gateway-auth-bypass-B93t91oq.js";
4
5
  import { n as normalizeCompatibilityConfig, t as legacyConfigRules } from "./doctor-contract-mvORF4f6.js";
5
6
  import { n as collectRuntimeConfigAssignments, r as secretTargetRegistryEntries } from "./secret-contract-qg3NXRlS.js";
6
- import { DEFAULT_ACCOUNT_ID as DEFAULT_ACCOUNT_ID$1, buildChannelOutboundSessionRoute, buildThreadAwareOutboundSessionRoute, stripChannelTargetPrefix, stripTargetKindPrefix } from "openclaw/plugin-sdk/core";
7
7
  import { normalizeLowercaseStringOrEmpty, normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
8
8
  import { buildPassiveProbedChannelStatusSummary } from "openclaw/plugin-sdk/extension-shared";
9
9
  import { isPrivateNetworkOptInEnabled } from "openclaw/plugin-sdk/ssrf-runtime";
@@ -11,6 +11,9 @@ import { z } from "zod";
11
11
  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
+ 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";
16
+ import { identityEntryAuthenticationClassifier } from "openclaw/plugin-sdk/channel-ingress-runtime";
14
17
  import { jsonResult, readPositiveIntegerParam, readStringArrayParam, readStringParam, withNormalizedTimestamp } from "openclaw/plugin-sdk/channel-actions";
15
18
  import { adaptScopedAccountAccessor, createScopedChannelConfigAdapter } from "openclaw/plugin-sdk/channel-config-helpers";
16
19
  import { createChannelConfigUiHints, createChatChannelPlugin } from "openclaw/plugin-sdk/channel-core";
@@ -23,16 +26,16 @@ import { resolvePayloadMediaUrls, sendTextMediaPayload } from "openclaw/plugin-s
23
26
  import { createComputedAccountStatusAdapter, createDefaultChannelRuntimeState } from "openclaw/plugin-sdk/status-helpers";
24
27
  import { chunkTextForOutbound, sanitizeAssistantVisibleText } from "openclaw/plugin-sdk/text-chunking";
25
28
  import { createChannelApprovalAuth } from "openclaw/plugin-sdk/approval-auth-runtime";
26
- import { describeAccountSnapshot } from "openclaw/plugin-sdk/account-helpers";
27
29
  import { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "openclaw/plugin-sdk/account-id";
28
- import { BlockStreamingCoalesceSchema, ChannelImplicitMentionsSchema, DmPolicySchema, GroupPolicySchema, MarkdownConfigSchema, buildChannelConfigSchema, buildGroupEntrySchema, buildMultiAccountChannelSchema, requireOpenAllowFrom } from "openclaw/plugin-sdk/channel-config-schema";
30
+ import { BlockStreamingCoalesceSchema, ChannelImplicitMentionsSchema, ContextVisibilityModeSchema, DmPolicySchema, GroupPolicySchema, MarkdownConfigSchema, buildChannelConfigSchema, buildGroupEntrySchema, buildMultiAccountChannelSchema, requireOpenAllowFrom } from "openclaw/plugin-sdk/channel-config-schema";
29
31
  import { defineChannelSetupContract } from "openclaw/plugin-sdk/channel-setup";
30
32
  import { applyAccountNameToChannelSection, applySetupAccountConfigPatch, baseUrlTextInput, createSetupTranslator, createStandardChannelSetupStatus, defineTokenCredential, formatDocsLink, migrateBaseNameToDefaultAccount, setSetupChannelEnabled } from "openclaw/plugin-sdk/setup";
31
33
  import { createSetupInputPresenceValidator } from "openclaw/plugin-sdk/setup-runtime";
32
34
  //#region extensions/mattermost/src/approval-auth.ts
33
35
  const MATTERMOST_USER_ID_RE = /^[a-z0-9]{26}$/;
34
36
  function normalizeMattermostApproverId(value) {
35
- const lowered = normalizeLowercaseStringOrEmpty(String(value).trim().replace(/^(mattermost|user):/i, "").replace(/^@/, "").trim());
37
+ const normalized = String(value).trim().replace(/^(mattermost|user):/i, "").replace(/^@/, "").trim();
38
+ const lowered = normalizeLowercaseStringOrEmpty(normalized);
36
39
  return MATTERMOST_USER_ID_RE.test(lowered) ? lowered : void 0;
37
40
  }
38
41
  const mattermostApprovalAuth = createChannelApprovalAuth({
@@ -87,9 +90,6 @@ const mattermostConfigAdapter = createScopedChannelConfigAdapter({
87
90
  normalizeEntry: formatMattermostAllowEntry
88
91
  })
89
92
  });
90
- function isMattermostConfigured$1(account) {
91
- return (account.botTokenStatus ? account.botTokenStatus !== "missing" : Boolean(account.botToken)) && Boolean(account.baseUrl);
92
- }
93
93
  function describeMattermostAccount(account) {
94
94
  return describeAccountSnapshot({
95
95
  account,
@@ -189,16 +189,16 @@ const MattermostReplyToModeByChatTypeSchema = z.object({
189
189
  group: MattermostReplyToModeSchema.optional(),
190
190
  channel: MattermostReplyToModeSchema.optional()
191
191
  }).strict();
192
- //#endregion
193
- //#region extensions/mattermost/src/config-surface.ts
194
- const MattermostChannelConfigSchema = buildChannelConfigSchema(buildMultiAccountChannelSchema(z.object({
192
+ const MattermostAccountSchemaBase = z.object({
195
193
  name: z.string().optional(),
196
194
  capabilities: z.array(z.string()).optional(),
197
195
  dangerouslyAllowNameMatching: z.boolean().optional(),
198
196
  markdown: MarkdownConfigSchema,
199
197
  enabled: z.boolean().optional(),
200
198
  configWrites: z.boolean().optional(),
199
+ contextVisibility: ContextVisibilityModeSchema.optional(),
201
200
  historyLimit: z.number().int().min(0).optional(),
201
+ mediaMaxMb: z.number().positive().optional(),
202
202
  botToken: buildSecretInputSchema().optional(),
203
203
  baseUrl: z.string().optional(),
204
204
  chatmode: z.enum([
@@ -233,7 +233,8 @@ const MattermostChannelConfigSchema = buildChannelConfigSchema(buildMultiAccount
233
233
  network: MattermostNetworkSchema,
234
234
  /** Retry configuration for DM channel creation */
235
235
  dmChannelRetry: DmChannelRetrySchema
236
- }).strict(), {
236
+ }).strict();
237
+ const MattermostConfigSchema = buildMultiAccountChannelSchema(MattermostAccountSchemaBase, {
237
238
  optionalAccount: true,
238
239
  refine: (value, ctx) => {
239
240
  requireMattermostOpenAllowFrom({
@@ -242,7 +243,10 @@ const MattermostChannelConfigSchema = buildChannelConfigSchema(buildMultiAccount
242
243
  ctx
243
244
  });
244
245
  }
245
- }), { uiHints: {
246
+ });
247
+ //#endregion
248
+ //#region extensions/mattermost/src/config-ui-hints.ts
249
+ const mattermostChannelConfigUiHints = {
246
250
  "": {
247
251
  label: "Mattermost",
248
252
  help: "Mattermost channel provider configuration for bot auth, access policy, slash commands, and preview streaming."
@@ -261,15 +265,22 @@ const MattermostChannelConfigSchema = buildChannelConfigSchema(buildMultiAccount
261
265
  },
262
266
  progress: {}
263
267
  })
264
- } });
268
+ };
269
+ //#endregion
270
+ //#region extensions/mattermost/src/config-surface.ts
271
+ const MattermostChannelConfigSchema = buildChannelConfigSchema(MattermostConfigSchema, { uiHints: mattermostChannelConfigUiHints });
272
+ //#endregion
273
+ //#region extensions/mattermost/src/doctor.ts
274
+ const isMattermostMutableAllowEntry = buildMutableAllowEntryDetector({ stableIdPattern: /^(?:(?:mattermost|user):)?@?[a-z0-9]{26}$/i });
275
+ const collectMattermostMutableAllowlistWarnings = createDangerousNameMatchingMutableAllowlistWarningCollector({
276
+ channel: "mattermost",
277
+ detector: isMattermostMutableAllowEntry,
278
+ collectLists: (scope) => collectStandardAllowlistLists(scope)
279
+ });
265
280
  const mattermostDoctor = {
266
281
  legacyConfigRules,
267
282
  normalizeCompatibilityConfig,
268
- collectMutableAllowlistWarnings: createDangerousNameMatchingMutableAllowlistWarningCollector({
269
- channel: "mattermost",
270
- detector: buildMutableAllowEntryDetector({ stableIdPattern: /^(?:(?:mattermost|user):)?@?[a-z0-9]{26}$/i }),
271
- collectLists: (scope) => collectStandardAllowlistLists(scope)
272
- })
283
+ collectMutableAllowlistWarnings: collectMattermostMutableAllowlistWarnings
273
284
  };
274
285
  //#endregion
275
286
  //#region extensions/mattermost/src/group-mentions.ts
@@ -368,21 +379,22 @@ function resolveMattermostOutboundSessionRoute(params) {
368
379
  const recipientSessionExact = isUser && hasExplicitUserKind && /^[a-z0-9]{26}$/.test(rawId);
369
380
  const isGroup = !isUser && (resolvedKind === "group" || resolvedKind !== "channel" && (lower.startsWith("group:") || mattermostSessionKeyPeerKind(params.currentSessionKey, rawId) === "group"));
370
381
  const kind = isUser ? "direct" : isGroup ? "group" : "channel";
382
+ const baseRoute = buildChannelOutboundSessionRoute({
383
+ cfg: params.cfg,
384
+ agentId: params.agentId,
385
+ channel: "mattermost",
386
+ accountId: params.accountId,
387
+ recipientSessionExact,
388
+ peer: {
389
+ kind,
390
+ id: rawId
391
+ },
392
+ chatType: kind,
393
+ from: isUser ? `mattermost:${rawId}` : `mattermost:${kind}:${rawId}`,
394
+ to: isUser ? `user:${rawId}` : `channel:${rawId}`
395
+ });
371
396
  return buildThreadAwareOutboundSessionRoute({
372
- route: buildChannelOutboundSessionRoute({
373
- cfg: params.cfg,
374
- agentId: params.agentId,
375
- channel: "mattermost",
376
- accountId: params.accountId,
377
- recipientSessionExact,
378
- peer: {
379
- kind,
380
- id: rawId
381
- },
382
- chatType: kind,
383
- from: isUser ? `mattermost:${rawId}` : `mattermost:${kind}:${rawId}`,
384
- to: isUser ? `user:${rawId}` : `channel:${rawId}`
385
- }),
397
+ route: baseRoute,
386
398
  replyToId: params.replyToId,
387
399
  threadId: params.threadId,
388
400
  currentSessionKey: params.currentSessionKey,
@@ -408,16 +420,58 @@ function applyMattermostSetupConfigPatch(params) {
408
420
  accountId: params.accountId,
409
421
  name: params.name
410
422
  });
423
+ const next = params.accountId !== DEFAULT_ACCOUNT_ID ? migrateBaseNameToDefaultAccount({
424
+ cfg: namedConfig,
425
+ channelKey: channel$1
426
+ }) : namedConfig;
411
427
  return applySetupAccountConfigPatch({
412
- cfg: params.accountId !== DEFAULT_ACCOUNT_ID ? migrateBaseNameToDefaultAccount({
413
- cfg: namedConfig,
414
- channelKey: channel$1
415
- }) : namedConfig,
428
+ cfg: next,
416
429
  channelKey: channel$1,
417
430
  accountId: params.accountId,
418
431
  patch: params.patch
419
432
  });
420
433
  }
434
+ const mattermostSetupAdapter = {
435
+ resolveAccountId: ({ accountId }) => normalizeAccountId(accountId),
436
+ applyAccountName: ({ cfg, accountId, name }) => applyAccountNameToChannelSection({
437
+ cfg,
438
+ channelKey: channel$1,
439
+ accountId,
440
+ name
441
+ }),
442
+ validateInput: createSetupInputPresenceValidator({
443
+ defaultAccountOnlyEnvError: "Mattermost env vars can only be used for the default account.",
444
+ whenNotUseEnv: [{
445
+ someOf: ["botToken", "token"],
446
+ message: "Mattermost requires --bot-token and --http-url (or --use-env)."
447
+ }, {
448
+ someOf: ["httpUrl"],
449
+ message: "Mattermost requires --bot-token and --http-url (or --use-env)."
450
+ }],
451
+ validate: ({ input }) => {
452
+ const setupInput = input;
453
+ const token = setupInput.botToken ?? setupInput.token;
454
+ const baseUrl = normalizeMattermostBaseUrl(setupInput.httpUrl);
455
+ if (!setupInput.useEnv && (!token || !baseUrl)) return "Mattermost requires --bot-token and --http-url (or --use-env).";
456
+ if (setupInput.httpUrl && !baseUrl) return "Mattermost --http-url must include a valid base URL.";
457
+ return null;
458
+ }
459
+ }),
460
+ applyAccountConfig: ({ cfg, accountId, input }) => {
461
+ const setupInput = input;
462
+ const token = setupInput.botToken ?? setupInput.token;
463
+ const baseUrl = normalizeMattermostBaseUrl(setupInput.httpUrl);
464
+ return applyMattermostSetupConfigPatch({
465
+ cfg,
466
+ accountId,
467
+ name: setupInput.name,
468
+ patch: setupInput.useEnv ? {} : {
469
+ ...token ? { botToken: token } : {},
470
+ ...baseUrl ? { baseUrl } : {}
471
+ }
472
+ });
473
+ }
474
+ };
421
475
  const mattermostSetupContract = defineChannelSetupContract({
422
476
  fields: {
423
477
  token: {
@@ -452,47 +506,7 @@ const mattermostSetupContract = defineChannelSetupContract({
452
506
  envVars: ["MATTERMOST_BOT_TOKEN", "MATTERMOST_URL"]
453
507
  }
454
508
  },
455
- legacyAdapter: {
456
- resolveAccountId: ({ accountId }) => normalizeAccountId(accountId),
457
- applyAccountName: ({ cfg, accountId, name }) => applyAccountNameToChannelSection({
458
- cfg,
459
- channelKey: channel$1,
460
- accountId,
461
- name
462
- }),
463
- validateInput: createSetupInputPresenceValidator({
464
- defaultAccountOnlyEnvError: "Mattermost env vars can only be used for the default account.",
465
- whenNotUseEnv: [{
466
- someOf: ["botToken", "token"],
467
- message: "Mattermost requires --bot-token and --http-url (or --use-env)."
468
- }, {
469
- someOf: ["httpUrl"],
470
- message: "Mattermost requires --bot-token and --http-url (or --use-env)."
471
- }],
472
- validate: ({ input }) => {
473
- const setupInput = input;
474
- const token = setupInput.botToken ?? setupInput.token;
475
- const baseUrl = normalizeMattermostBaseUrl(setupInput.httpUrl);
476
- if (!setupInput.useEnv && (!token || !baseUrl)) return "Mattermost requires --bot-token and --http-url (or --use-env).";
477
- if (setupInput.httpUrl && !baseUrl) return "Mattermost --http-url must include a valid base URL.";
478
- return null;
479
- }
480
- }),
481
- applyAccountConfig: ({ cfg, accountId, input }) => {
482
- const setupInput = input;
483
- const token = setupInput.botToken ?? setupInput.token;
484
- const baseUrl = normalizeMattermostBaseUrl(setupInput.httpUrl);
485
- return applyMattermostSetupConfigPatch({
486
- cfg,
487
- accountId,
488
- name: setupInput.name,
489
- patch: setupInput.useEnv ? {} : {
490
- ...token ? { botToken: token } : {},
491
- ...baseUrl ? { baseUrl } : {}
492
- }
493
- });
494
- }
495
- }
509
+ legacyAdapter: mattermostSetupAdapter
496
510
  });
497
511
  //#endregion
498
512
  //#region extensions/mattermost/src/setup-surface.ts
@@ -580,7 +594,7 @@ const mattermostSetupWizard = {
580
594
  };
581
595
  //#endregion
582
596
  //#region extensions/mattermost/src/channel.ts
583
- const loadMattermostChannelRuntime = createLazyRuntimeModule(() => import("./channel.runtime-DLTjcasQ.js"));
597
+ const loadMattermostChannelRuntime = createLazyRuntimeModule(() => import("./channel.runtime-CdT1mcEl.js"));
584
598
  const MATTERMOST_PRESENTATION_CAPABILITIES = {
585
599
  supported: true,
586
600
  buttons: true,
@@ -614,6 +628,7 @@ const mattermostSecurityAdapter = createRestrictSendersChannelSecurity({
614
628
  groupAllowFromPath: "channels.mattermost.groupAllowFrom",
615
629
  findingTitle: "Mattermost security warning",
616
630
  policyPathSuffix: "dmPolicy",
631
+ classifyEntryAuthentication: identityEntryAuthenticationClassifier(mattermostIngressIdentity),
617
632
  normalizeDmEntry: (raw) => normalizeMattermostAllowEntry(raw)
618
633
  });
619
634
  function describeMattermostMessageTool({ cfg, accountId }) {
@@ -661,22 +676,6 @@ function extractMattermostToolSend(args) {
661
676
  ...threadSuppressed ? { threadSuppressed: true } : {}
662
677
  };
663
678
  }
664
- function extractMattermostToolSendResult(result, send) {
665
- if (!result || typeof result !== "object") return null;
666
- const details = result.details;
667
- if (!details || typeof details !== "object") return null;
668
- const toolSend = details.toolSend;
669
- if (!toolSend || typeof toolSend !== "object") return null;
670
- const record = toolSend;
671
- const to = normalizeOptionalString(record.to);
672
- if (!to) return null;
673
- const threadId = normalizeOptionalString(record.threadId);
674
- const originalTarget = normalizeOptionalString(send.to);
675
- return {
676
- to: originalTarget?.startsWith("user:") === true || originalTarget?.startsWith("@") === true ? originalTarget : to,
677
- ...threadId ? { threadId } : {}
678
- };
679
- }
680
679
  function resolveMattermostAutoThreadId(params) {
681
680
  const replyToId = normalizeOptionalString(params.replyToId);
682
681
  const context = params.toolContext;
@@ -707,10 +706,12 @@ function normalizeMattermostThreadId(value) {
707
706
  return typeof value === "number" ? String(value) : normalizeOptionalString(value);
708
707
  }
709
708
  function buildMattermostThreadingToolContext(params) {
710
- const configuredReplyToMode = resolveMattermostReplyToMode(resolveMattermostAccount({
709
+ const account = resolveMattermostAccount({
711
710
  cfg: params.cfg,
712
711
  accountId: params.accountId ?? resolveDefaultMattermostAccountId(params.cfg)
713
- }), params.context.ChatType === "direct" || params.context.ChatType === "group" || params.context.ChatType === "channel" ? params.context.ChatType : "channel");
712
+ });
713
+ const chatType = params.context.ChatType === "direct" || params.context.ChatType === "group" || params.context.ChatType === "channel" ? params.context.ChatType : "channel";
714
+ const configuredReplyToMode = resolveMattermostReplyToMode(account, chatType);
714
715
  const currentThreadTs = normalizeMattermostThreadId(params.context.MessageThreadId) ?? normalizeMattermostThreadId(params.context.TransportThreadId) ?? normalizeOptionalString(params.context.ReplyToId);
715
716
  const currentMessageId = normalizeMattermostThreadId(params.context.CurrentMessageId);
716
717
  const hasExistingThread = Boolean(currentThreadTs) && (!currentMessageId || currentThreadTs !== currentMessageId);
@@ -735,7 +736,6 @@ const mattermostMessageActions = {
735
736
  providerOwnedReadGates: ["read"],
736
737
  describeMessageTool: describeMattermostMessageTool,
737
738
  extractToolSend: ({ args }) => extractMattermostToolSend(args),
738
- extractToolSendResult: ({ result, send }) => extractMattermostToolSendResult(result, send),
739
739
  prepareSendPayload: ({ ctx, payload }) => {
740
740
  if (ctx.action !== "send") return null;
741
741
  const mediaUrl = resolveMattermostSendAttachmentMedia(ctx.params);
@@ -757,9 +757,9 @@ const mattermostMessageActions = {
757
757
  };
758
758
  },
759
759
  supportsAction: ({ action }) => {
760
- return action === "send" || action === "react" || action === "read";
760
+ return action === "react" || action === "read";
761
761
  },
762
- handleAction: async ({ action, params, cfg, accountId, mediaAccess, mediaLocalRoots, mediaReadFile, conversationReadOrigin, requesterAccountId, toolContext }) => {
762
+ handleAction: async ({ action, params, cfg, accountId, conversationReadOrigin, requesterAccountId, toolContext }) => {
763
763
  if (action === "read") {
764
764
  const resolvedAccountId = accountId ?? resolveDefaultMattermostAccountId(cfg);
765
765
  const mattermostConfig = cfg.channels?.mattermost;
@@ -843,43 +843,7 @@ const mattermostMessageActions = {
843
843
  details: {}
844
844
  };
845
845
  }
846
- if (action !== "send") throw new Error(`Unsupported Mattermost action: ${action}`);
847
- const to = typeof params.to === "string" ? params.to.trim() : typeof params.target === "string" ? params.target.trim() : "";
848
- if (!to) throw new Error("Mattermost send requires a target (to).");
849
- const { text: message, buttons } = resolveMattermostPresentation({
850
- text: typeof params.message === "string" ? params.message : void 0,
851
- presentation: params.presentation
852
- });
853
- const replyToId = normalizeOptionalString(params.replyToId) ?? normalizeOptionalString(params.threadId) ?? normalizeOptionalString(params.replyTo);
854
- const resolvedAccountId = accountId || void 0;
855
- const mediaUrl = resolveMattermostSendAttachmentMedia(params);
856
- const result = await (await loadMattermostChannelRuntime()).sendMessageMattermost(to, message, {
857
- cfg,
858
- accountId: resolvedAccountId,
859
- replyToId,
860
- buttons: buttons.length > 0 ? buttons : void 0,
861
- attachmentText: typeof params.attachmentText === "string" ? params.attachmentText : void 0,
862
- mediaUrl,
863
- mediaLocalRoots: mediaLocalRoots ?? mediaAccess?.localRoots,
864
- mediaReadFile: mediaReadFile ?? mediaAccess?.readFile,
865
- ...mediaAccess?.workspaceDir ? { workspaceDir: mediaAccess.workspaceDir } : {},
866
- requireMediaUpload: requiresMattermostMediaUpload(mediaUrl) ? true : void 0
867
- });
868
- return {
869
- content: [{
870
- type: "text",
871
- text: JSON.stringify({
872
- ok: true,
873
- channel: "mattermost",
874
- messageId: result.messageId,
875
- channelId: result.channelId
876
- })
877
- }],
878
- details: { toolSend: {
879
- to: `channel:${result.channelId}`,
880
- ...replyToId ? { threadId: replyToId } : {}
881
- } }
882
- };
846
+ throw new Error(`Unsupported Mattermost action: ${action}`);
883
847
  }
884
848
  };
885
849
  function parseMattermostReactActionParams(params) {
@@ -974,7 +938,7 @@ const mattermostOutbound = {
974
938
  ...ctx.payload,
975
939
  mediaUrl: ctx.payload.mediaUrl ?? ctx.mediaUrl
976
940
  }).map((url) => url.trim()).find(Boolean);
977
- return attachChannelToResult("mattermost", toMattermostOutboundResult(await (await loadMattermostChannelRuntime()).sendMessageMattermost(ctx.to, ctx.payload.text ?? ctx.text, {
941
+ const result = await (await loadMattermostChannelRuntime()).sendMessageMattermost(ctx.to, ctx.payload.text ?? ctx.text, {
978
942
  cfg: ctx.cfg,
979
943
  accountId: ctx.accountId ?? void 0,
980
944
  mediaUrl,
@@ -986,7 +950,8 @@ const mattermostOutbound = {
986
950
  buttons: buttons?.length ? buttons : void 0,
987
951
  attachmentText,
988
952
  onDeliveryResult: createMattermostDeliveryProgressReporter(ctx.onDeliveryResult)
989
- })));
953
+ });
954
+ return attachChannelToResult("mattermost", toMattermostOutboundResult(result));
990
955
  }
991
956
  return await sendTextMediaPayload({
992
957
  channel: "mattermost",
@@ -1231,4 +1196,4 @@ const mattermostPlugin = createChatChannelPlugin({
1231
1196
  outbound: mattermostOutbound
1232
1197
  });
1233
1198
  //#endregion
1234
- export { describeMattermostAccount as a, mattermostMeta as c, MattermostChannelConfigSchema as i, mattermostSetupWizard as n, isMattermostConfigured$1 as o, mattermostSetupContract as r, mattermostConfigAdapter as s, mattermostPlugin as t };
1199
+ export { describeMattermostAccount as a, MattermostChannelConfigSchema as i, mattermostSetupWizard as n, mattermostConfigAdapter as o, mattermostSetupContract as r, mattermostMeta as s, mattermostPlugin as t };
@@ -1,2 +1,2 @@
1
- import { t as mattermostPlugin } from "./channel-plugin-runtime-Bh8hcegp.js";
1
+ import { t as mattermostPlugin } from "./channel-plugin-runtime-C6tfh14W.js";
2
2
  export { mattermostPlugin };
@@ -1,11 +1,12 @@
1
1
  import { n as getOptionalMattermostRuntime, t as getMattermostRuntime } from "./runtime-CNB4YGqJ.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 { 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-k47k-7SP.js";
5
- import { a as inspectMattermostAccount, c as resolveMattermostAccount, l as resolveMattermostReplyToMode, n as normalizeMattermostMessagingTarget, o as listMattermostAccountIds } from "./normalize-bBDFEiyJ.js";
6
- 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-CfsJU7WW.js";
2
+ import { a as resolveInteractionCallbackPath, c as setInteractionSecret, i as createMattermostInteractionHandler, n as buildButtonProps, r as computeInteractionCallbackUrl, s as setInteractionCallbackUrl } from "./interactions-DF1FH27_.js";
3
+ 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-Dt7Q-j5B.js";
4
+ import { C as resolveDefaultGroupPolicy, T as warnMissingProviderGroupPolicyFallbackOnce, _ 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, x as resolveChannelMediaMaxBytes, y as registerPluginHttpRoute } from "./monitor-auth-C6RGYyn-.js";
5
+ import { n as normalizeMattermostAllowEntry } from "./ingress-identity-DNl4yQSc.js";
6
+ import { a as inspectMattermostAccount, l as resolveMattermostAccount, n as normalizeMattermostMessagingTarget, s as listMattermostAccountIds, u as resolveMattermostReplyToMode } from "./normalize-R-ATEEHC.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-njvQCdwt.js";
7
8
  import { randomUUID } from "node:crypto";
8
- import { resolveGatewayPort } from "openclaw/plugin-sdk/core";
9
+ import { resolveGatewayPort } from "openclaw/plugin-sdk/gateway-config-runtime";
9
10
  import { resolvePinnedMainDmOwnerFromAllowlist, sanitizeUntrustedFileName } from "openclaw/plugin-sdk/security-runtime";
10
11
  import { normalizeLowercaseStringOrEmpty, normalizeOptionalString, normalizeStringEntries, normalizeTrimmedStringList, uniqueStrings } from "openclaw/plugin-sdk/string-coerce-runtime";
11
12
  import { buildChannelInboundMediaPayload, createChannelPartialDeliveryError, formatInboundEnvelope, formatInboundFromLabel, formatInboundMediaUnavailableText, formatMediaPlaceholderText, implicitMentionKindWhen, isChannelPartialDeliveryError, resolveInboundMentionDecision, resolveInboundSessionEnvelopeContext, toInboundMediaFactsWithMetadata } from "openclaw/plugin-sdk/channel-inbound";
@@ -18,6 +19,7 @@ import { z } from "zod";
18
19
  import { bindIngressLifecycleToReplyOptions, buildChannelProgressDraftLineForEntry, createChannelIngressError, createChannelIngressMonitor, createChannelProgressDraftCompositor, createFinalizableDraftLifecycle, createMessageReceiptFromOutboundResults, defineFinalizableLivePreviewAdapter, deliverWithFinalizableLivePreviewAdapter, listMessageReceiptPlatformIds, resolveChannelStreamingPreviewToolProgress } from "openclaw/plugin-sdk/channel-outbound";
19
20
  import { resolveAllowlistProviderRuntimeGroupPolicy } from "openclaw/plugin-sdk/runtime-group-policy";
20
21
  import { rawDataToString } from "openclaw/plugin-sdk/webhook-ingress";
22
+ import { runDetachedWebhookWork } from "openclaw/plugin-sdk/webhook-request-guards";
21
23
  import { fanInChannelIngressLifecycles, resolveChannelImplicitMentions } from "openclaw/plugin-sdk/channel-ingress-runtime";
22
24
  import { buildTtsSupplementMediaPayload, countOutboundMedia, getReplyPayloadTtsSupplement, isReasoningReplyPayload, resolveSendableOutboundReplyParts } from "openclaw/plugin-sdk/reply-payload";
23
25
  import { normalizeAccountId } from "openclaw/plugin-sdk/account-id";
@@ -30,7 +32,6 @@ import { pruneMapToMaxSize } from "openclaw/plugin-sdk/collection-runtime";
30
32
  import { channelReadyPatch, isLoopbackHost } from "openclaw/plugin-sdk/gateway-runtime";
31
33
  import { captureWsEvent, createDebugProxyWebSocketAgent, resolveDebugProxySettings } from "openclaw/plugin-sdk/proxy-capture";
32
34
  import WebSocket from "ws";
33
- import { runDetachedWebhookWork } from "openclaw/plugin-sdk/webhook-request-guards";
34
35
  import { resolveChannelContextVisibilityMode, shouldIncludeSupplementalContext } from "openclaw/plugin-sdk/context-visibility-runtime";
35
36
  import { getGlobalHookRunner } from "openclaw/plugin-sdk/plugin-runtime";
36
37
  import { chunkMarkdownTextWithMode } from "openclaw/plugin-sdk/reply-chunking";
@@ -214,8 +215,9 @@ function shouldDropEmptyMattermostBody(params) {
214
215
  }
215
216
  //#endregion
216
217
  //#region extensions/mattermost/src/mattermost/monitor-websocket.ts
217
- const MATTERMOST_WEBSOCKET_MAX_PAYLOAD_BYTES = 16 * 1024 * 1024;
218
+ const MATTERMOST_WEBSOCKET_MAX_PAYLOAD_BYTES = 16777216;
218
219
  const MATTERMOST_WEBSOCKET_HANDSHAKE_TIMEOUT_MS = 3e4;
220
+ const MATTERMOST_WEBSOCKET_AUTH_TIMEOUT_MS = 3e4;
219
221
  const MattermostEventPayloadSchema = z.object({
220
222
  event: z.string().optional(),
221
223
  status: z.string().optional(),
@@ -251,6 +253,14 @@ var WebSocketClosedBeforeOpenError = class extends Error {
251
253
  this.name = "WebSocketClosedBeforeOpenError";
252
254
  }
253
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
+ };
254
264
  const defaultMattermostWebSocketFactory = (url, options) => {
255
265
  const agent = createDebugProxyWebSocketAgent(resolveDebugProxySettings());
256
266
  return new WebSocket(url, {
@@ -275,6 +285,7 @@ function createMattermostConnectOnce(opts) {
275
285
  try {
276
286
  return await new Promise((resolve, reject) => {
277
287
  let opened = false;
288
+ let authenticated = false;
278
289
  let settled = false;
279
290
  let healthCheckEnabled = getBotUpdateAt != null;
280
291
  let healthCheckInFlight = false;
@@ -284,11 +295,16 @@ function createMattermostConnectOnce(opts) {
284
295
  let protocolPongTimer;
285
296
  let initialUpdateAt;
286
297
  let authenticationSeq;
298
+ let authTimer;
287
299
  const clearTimers = () => {
288
300
  if (healthCheckTimer !== void 0) {
289
301
  clearTimeout(healthCheckTimer);
290
302
  healthCheckTimer = void 0;
291
303
  }
304
+ if (authTimer !== void 0) {
305
+ clearTimeout(authTimer);
306
+ authTimer = void 0;
307
+ }
292
308
  if (protocolPingTimer !== void 0) {
293
309
  clearTimeout(protocolPingTimer);
294
310
  protocolPingTimer = void 0;
@@ -403,6 +419,13 @@ function createMattermostConnectOnce(opts) {
403
419
  }
404
420
  });
405
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);
406
429
  scheduleProtocolPing();
407
430
  if (getBotUpdateAt) runHealthCheck();
408
431
  });
@@ -426,6 +449,11 @@ function createMattermostConnectOnce(opts) {
426
449
  const payload = parseMattermostEventPayload(raw);
427
450
  if (!payload) return;
428
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
+ }
429
457
  opts.statusSink?.(channelReadyPatch());
430
458
  return;
431
459
  }
@@ -467,10 +495,14 @@ function createMattermostConnectOnce(opts) {
467
495
  error: message || void 0
468
496
  }
469
497
  });
470
- if (opened) {
498
+ if (opened && authenticated) {
471
499
  resolveOnce();
472
500
  return;
473
501
  }
502
+ if (opened) {
503
+ rejectOnce(new WebSocketClosedBeforeAuthenticationError(code, message || void 0));
504
+ return;
505
+ }
474
506
  rejectOnce(new WebSocketClosedBeforeOpenError(code, message || void 0));
475
507
  });
476
508
  ws.on("error", (err) => {
@@ -1088,7 +1120,7 @@ function createMattermostModelPickerInteractionHandler(monitor) {
1088
1120
  agentId: eventPlan.route.agentId,
1089
1121
  sessionKey: eventPlan.thread.sessionKey
1090
1122
  };
1091
- const data = await buildModelsProviderData(cfg, eventPlan.route.agentId);
1123
+ const data = await buildPreparedModelsProviderData(cfg, eventPlan.route.agentId);
1092
1124
  if (data.providers.length === 0) return await updatePickerPost("No models available.");
1093
1125
  if (pickerState.action === "providers" || pickerState.action === "back") {
1094
1126
  const currentModel = resolveMattermostModelPickerCurrentModel({
@@ -1222,8 +1254,8 @@ function formatMattermostInboundMediaText(params) {
1222
1254
  notice: `[mattermost ${unavailableCount > 1 ? `${unavailableCount} attachments` : "attachment"} unavailable]${fileNameNotice}`
1223
1255
  });
1224
1256
  }
1225
- const CHANNEL_CACHE_TTL_MS = 5 * 6e4;
1226
- const USER_CACHE_TTL_MS = 10 * 6e4;
1257
+ const CHANNEL_CACHE_TTL_MS = 3e5;
1258
+ const USER_CACHE_TTL_MS = 6e5;
1227
1259
  const MONITOR_RESOURCE_CACHE_MAX_ENTRIES = 1e3;
1228
1260
  const MATTERMOST_MEDIA_RESPONSE_HEADER_TIMEOUT_MS = 12e4;
1229
1261
  const MATTERMOST_MEDIA_READ_IDLE_TIMEOUT_MS = 3e4;
@@ -1813,7 +1845,7 @@ async function deliverMattermostReplyWithDraftPreview(params) {
1813
1845
  //#region extensions/mattermost/src/mattermost/thread-participation.ts
1814
1846
  const threadParticipation = createPersistentDedupeCache({
1815
1847
  globalKey: Symbol.for("openclaw.mattermostThreadParticipation"),
1816
- ttlMs: 10080 * 60 * 1e3,
1848
+ ttlMs: 6048e5,
1817
1849
  maxSize: 5e3,
1818
1850
  persistent: {
1819
1851
  namespace: "mattermost.thread-participation",
@@ -2836,9 +2868,9 @@ async function monitorMattermostProvider(opts = {}) {
2836
2868
  };
2837
2869
  const mediaMaxBytes = resolveChannelMediaMaxBytes({
2838
2870
  cfg,
2839
- resolveChannelLimitMb: () => void 0,
2871
+ resolveChannelLimitMb: () => account.config.mediaMaxMb,
2840
2872
  accountId: account.accountId
2841
- }) ?? 8 * 1024 * 1024;
2873
+ }) ?? 8388608;
2842
2874
  const { groupPolicy, providerMissingFallbackApplied } = resolveAllowlistProviderRuntimeGroupPolicy$1({
2843
2875
  providerConfigPresent: cfg.channels?.mattermost !== void 0,
2844
2876
  groupPolicy: account.config.groupPolicy,
@@ -3053,7 +3085,7 @@ async function probeMattermost(baseUrl, botToken, timeoutMs = 2500, allowPrivate
3053
3085
  }
3054
3086
  //#endregion
3055
3087
  //#region extensions/mattermost/src/mattermost/reactions.ts
3056
- const BOT_USER_CACHE_TTL_MS = 10 * 6e4;
3088
+ const BOT_USER_CACHE_TTL_MS = 6e5;
3057
3089
  const botUserIdCache = /* @__PURE__ */ new Map();
3058
3090
  async function resolveBotUserId(client, cacheKey) {
3059
3091
  const rawNow = Date.now();