@openclaw/mattermost 2026.8.1-beta.3 → 2026.8.2

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-Du_EJMeN.js";
1
+ import { r as isMattermostSenderAllowed } from "./monitor-auth-DvyW7bpd.js";
2
+ import { t as buildButtonAttachments } from "./interactions-DN1Dzzc_.js";
3
3
  export { buildButtonAttachments, isMattermostSenderAllowed };
@@ -1,4 +1,5 @@
1
- import { a as MattermostChannelConfigSchema, c as mattermostConfigAdapter, l as mattermostMeta, n as mattermostSetupWizard, o as describeMattermostAccount, r as mattermostSetupContract, s as isMattermostConfigured, t as mattermostPlugin } from "./channel-plugin-runtime-C_mWt_83.js";
1
+ import { o as isMattermostConfigured } from "./normalize-BtFTWPoG.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-iEa9Cv5W.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-B_hd-kwM.js";
2
- import { a as resolveMattermostReplyToMode, i as resolveMattermostAccount, n as listMattermostAccountIds, o as buildSecretInputSchema, r as resolveDefaultMattermostAccountId, s as hasConfiguredSecretInput, t as inspectMattermostAccount } from "./accounts-DspH-NMT.js";
1
+ import { m as normalizeMattermostBaseUrl } from "./client-D3Btt1WT.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-BtFTWPoG.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,28 +11,31 @@ 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 { jsonResult, readPositiveIntegerParam, readStringParam, withNormalizedTimestamp } from "openclaw/plugin-sdk/channel-actions";
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";
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";
17
20
  import { buildChannelGroupsScopeTree, buildMutableAllowEntryDetector, collectStandardAllowlistLists, createDangerousNameMatchingMutableAllowlistWarningCollector, createRestrictSendersChannelSecurity, resolveScopeRequireMention } from "openclaw/plugin-sdk/channel-policy";
18
21
  import { attachChannelToResult, createAttachedChannelResultAdapter } from "openclaw/plugin-sdk/channel-send-result";
19
22
  import { createChannelDirectoryAdapter } from "openclaw/plugin-sdk/directory-runtime";
20
- import { normalizeMessagePresentation, renderMessagePresentationFallbackText, resolveMessagePresentationButtonAction, resolveMessagePresentationControlValue } from "openclaw/plugin-sdk/interactive-runtime";
23
+ import { resolveMessagePresentationButtonAction } from "openclaw/plugin-sdk/interactive-runtime";
21
24
  import { createLazyRuntimeModule } from "openclaw/plugin-sdk/lazy-runtime";
22
25
  import { resolvePayloadMediaUrls, sendTextMediaPayload } from "openclaw/plugin-sdk/reply-payload";
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,15 +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(),
200
+ historyLimit: z.number().int().min(0).optional(),
201
+ mediaMaxMb: z.number().positive().optional(),
201
202
  botToken: buildSecretInputSchema().optional(),
202
203
  baseUrl: z.string().optional(),
203
204
  chatmode: z.enum([
@@ -232,7 +233,8 @@ const MattermostChannelConfigSchema = buildChannelConfigSchema(buildMultiAccount
232
233
  network: MattermostNetworkSchema,
233
234
  /** Retry configuration for DM channel creation */
234
235
  dmChannelRetry: DmChannelRetrySchema
235
- }).strict(), {
236
+ }).strict();
237
+ const MattermostConfigSchema = buildMultiAccountChannelSchema(MattermostAccountSchemaBase, {
236
238
  optionalAccount: true,
237
239
  refine: (value, ctx) => {
238
240
  requireMattermostOpenAllowFrom({
@@ -241,7 +243,10 @@ const MattermostChannelConfigSchema = buildChannelConfigSchema(buildMultiAccount
241
243
  ctx
242
244
  });
243
245
  }
244
- }), { uiHints: {
246
+ });
247
+ //#endregion
248
+ //#region extensions/mattermost/src/config-ui-hints.ts
249
+ const mattermostChannelConfigUiHints = {
245
250
  "": {
246
251
  label: "Mattermost",
247
252
  help: "Mattermost channel provider configuration for bot auth, access policy, slash commands, and preview streaming."
@@ -260,15 +265,22 @@ const MattermostChannelConfigSchema = buildChannelConfigSchema(buildMultiAccount
260
265
  },
261
266
  progress: {}
262
267
  })
263
- } });
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
+ });
264
280
  const mattermostDoctor = {
265
281
  legacyConfigRules,
266
282
  normalizeCompatibilityConfig,
267
- collectMutableAllowlistWarnings: createDangerousNameMatchingMutableAllowlistWarningCollector({
268
- channel: "mattermost",
269
- detector: buildMutableAllowEntryDetector({ stableIdPattern: /^(?:(?:mattermost|user):)?@?[a-z0-9]{26}$/i }),
270
- collectLists: (scope) => collectStandardAllowlistLists(scope)
271
- })
283
+ collectMutableAllowlistWarnings: collectMattermostMutableAllowlistWarnings
272
284
  };
273
285
  //#endregion
274
286
  //#region extensions/mattermost/src/group-mentions.ts
@@ -285,39 +297,59 @@ function resolveMattermostGroupRequireMention(params) {
285
297
  });
286
298
  }
287
299
  //#endregion
288
- //#region extensions/mattermost/src/normalize.ts
289
- function normalizeMattermostMessagingTarget(raw) {
290
- const trimmed = raw.trim();
291
- if (!trimmed) return;
292
- const lower = normalizeLowercaseStringOrEmpty(trimmed);
293
- if (lower.startsWith("channel:")) {
294
- const id = trimmed.slice(8).trim();
295
- return id ? `channel:${id}` : void 0;
296
- }
297
- if (lower.startsWith("group:")) {
298
- const id = trimmed.slice(6).trim();
299
- return id ? `channel:${id}` : void 0;
300
- }
301
- if (lower.startsWith("user:")) {
302
- const id = trimmed.slice(5).trim();
303
- return id ? `user:${id}` : void 0;
304
- }
305
- if (lower.startsWith("mattermost:")) {
306
- const id = trimmed.slice(11).trim();
307
- return id ? `user:${id}` : void 0;
308
- }
309
- if (trimmed.startsWith("@")) {
310
- const id = trimmed.slice(1).trim();
311
- return id ? `@${id}` : void 0;
312
- }
313
- if (trimmed.startsWith("#")) return;
314
- }
315
- function looksLikeMattermostTargetId(raw, _normalized) {
316
- const trimmed = raw.trim();
317
- if (!trimmed) return false;
318
- if (/^(user|channel|group|mattermost):/i.test(trimmed)) return true;
319
- if (trimmed.startsWith("@")) return true;
320
- return /^[a-z0-9]{26}$/i.test(trimmed) || /^[a-z0-9]{26}__[a-z0-9]{26}$/i.test(trimmed);
300
+ //#region extensions/mattermost/src/mattermost/emoji.ts
301
+ const MATTERMOST_EMOJI_SHORTNAME_BY_GLYPH = {
302
+ "✅": "white_check_mark",
303
+ "❌": "x",
304
+ "👍": "thumbsup",
305
+ "👎": "thumbsdown",
306
+ "🎉": "tada",
307
+ "❤": "heart",
308
+ "😄": "smile",
309
+ "😂": "joy",
310
+ "🚀": "rocket",
311
+ "👀": "eyes",
312
+ "🙏": "pray",
313
+ "🔥": "fire",
314
+ "💯": "100",
315
+ "⚠": "warning",
316
+ "➕": "heavy_plus_sign",
317
+ "➖": "heavy_minus_sign",
318
+ "🤔": "thinking_face",
319
+ "⚡": "zap",
320
+ "🌐": "globe_with_meridians",
321
+ "😱": "scream",
322
+ "🧠": "brain",
323
+ "💻": "computer",
324
+ "👋": "wave",
325
+ "🙌": "raised_hands"
326
+ };
327
+ const MATTERMOST_EMOJI_TONE_CAPABLE_NAMES = /* @__PURE__ */ new Set([
328
+ "thumbsup",
329
+ "thumbsdown",
330
+ "pray",
331
+ "wave",
332
+ "raised_hands"
333
+ ]);
334
+ const MATTERMOST_EMOJI_TONE_SUFFIX_BY_MODIFIER = /* @__PURE__ */ new Map([
335
+ ["🏻", "light_skin_tone"],
336
+ ["🏼", "medium_light_skin_tone"],
337
+ ["🏽", "medium_skin_tone"],
338
+ ["🏾", "medium_dark_skin_tone"],
339
+ ["🏿", "dark_skin_tone"]
340
+ ]);
341
+ const EMOJI_SKIN_TONE_MODIFIER_RE = /[\u{1F3FB}-\u{1F3FF}]/gu;
342
+ const EMOJI_VARIATION_SELECTOR_RE = /[\u{FE00}-\u{FE0F}]/gu;
343
+ function normalizeMattermostEmojiName(raw) {
344
+ const withoutColons = raw?.trim().replace(/^:+|:+$/g, "");
345
+ if (!withoutColons) return;
346
+ const toneModifier = withoutColons.match(EMOJI_SKIN_TONE_MODIFIER_RE)?.[0];
347
+ const glyphKey = withoutColons.replace(EMOJI_SKIN_TONE_MODIFIER_RE, "").replace(EMOJI_VARIATION_SELECTOR_RE, "");
348
+ const shortname = Object.hasOwn(MATTERMOST_EMOJI_SHORTNAME_BY_GLYPH, glyphKey) ? MATTERMOST_EMOJI_SHORTNAME_BY_GLYPH[glyphKey] : void 0;
349
+ if (shortname === void 0) return withoutColons;
350
+ const toneSuffix = toneModifier ? MATTERMOST_EMOJI_TONE_SUFFIX_BY_MODIFIER.get(toneModifier) : void 0;
351
+ if (!toneSuffix || !MATTERMOST_EMOJI_TONE_CAPABLE_NAMES.has(shortname)) return shortname;
352
+ return `${shortname}_${toneSuffix}`;
321
353
  }
322
354
  //#endregion
323
355
  //#region extensions/mattermost/src/session-route.ts
@@ -347,21 +379,22 @@ function resolveMattermostOutboundSessionRoute(params) {
347
379
  const recipientSessionExact = isUser && hasExplicitUserKind && /^[a-z0-9]{26}$/.test(rawId);
348
380
  const isGroup = !isUser && (resolvedKind === "group" || resolvedKind !== "channel" && (lower.startsWith("group:") || mattermostSessionKeyPeerKind(params.currentSessionKey, rawId) === "group"));
349
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
+ });
350
396
  return buildThreadAwareOutboundSessionRoute({
351
- route: buildChannelOutboundSessionRoute({
352
- cfg: params.cfg,
353
- agentId: params.agentId,
354
- channel: "mattermost",
355
- accountId: params.accountId,
356
- recipientSessionExact,
357
- peer: {
358
- kind,
359
- id: rawId
360
- },
361
- chatType: kind,
362
- from: isUser ? `mattermost:${rawId}` : `mattermost:${kind}:${rawId}`,
363
- to: isUser ? `user:${rawId}` : `channel:${rawId}`
364
- }),
397
+ route: baseRoute,
365
398
  replyToId: params.replyToId,
366
399
  threadId: params.threadId,
367
400
  currentSessionKey: params.currentSessionKey,
@@ -387,16 +420,58 @@ function applyMattermostSetupConfigPatch(params) {
387
420
  accountId: params.accountId,
388
421
  name: params.name
389
422
  });
423
+ const next = params.accountId !== DEFAULT_ACCOUNT_ID ? migrateBaseNameToDefaultAccount({
424
+ cfg: namedConfig,
425
+ channelKey: channel$1
426
+ }) : namedConfig;
390
427
  return applySetupAccountConfigPatch({
391
- cfg: params.accountId !== DEFAULT_ACCOUNT_ID ? migrateBaseNameToDefaultAccount({
392
- cfg: namedConfig,
393
- channelKey: channel$1
394
- }) : namedConfig,
428
+ cfg: next,
395
429
  channelKey: channel$1,
396
430
  accountId: params.accountId,
397
431
  patch: params.patch
398
432
  });
399
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
+ };
400
475
  const mattermostSetupContract = defineChannelSetupContract({
401
476
  fields: {
402
477
  token: {
@@ -431,47 +506,7 @@ const mattermostSetupContract = defineChannelSetupContract({
431
506
  envVars: ["MATTERMOST_BOT_TOKEN", "MATTERMOST_URL"]
432
507
  }
433
508
  },
434
- legacyAdapter: {
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
- }
509
+ legacyAdapter: mattermostSetupAdapter
475
510
  });
476
511
  //#endregion
477
512
  //#region extensions/mattermost/src/setup-surface.ts
@@ -559,20 +594,7 @@ const mattermostSetupWizard = {
559
594
  };
560
595
  //#endregion
561
596
  //#region extensions/mattermost/src/channel.ts
562
- const loadMattermostChannelRuntime = createLazyRuntimeModule(() => import("./channel.runtime-CpQzh8-1.js"));
563
- function buildMattermostPresentationButtons(presentation) {
564
- return presentation.blocks.filter((block) => block.type === "buttons").map((block) => block.buttons.flatMap((button) => {
565
- if (button.action) return [];
566
- const value = resolveMessagePresentationControlValue(button);
567
- return value ? [{
568
- id: value,
569
- text: button.label,
570
- callback_data: value,
571
- context: { callback_data: value },
572
- style: button.style
573
- }] : [];
574
- })).filter((row) => row.length > 0);
575
- }
597
+ const loadMattermostChannelRuntime = createLazyRuntimeModule(() => import("./channel.runtime-tEMiKAyb.js"));
576
598
  const MATTERMOST_PRESENTATION_CAPABILITIES = {
577
599
  supported: true,
578
600
  buttons: true,
@@ -606,6 +628,7 @@ const mattermostSecurityAdapter = createRestrictSendersChannelSecurity({
606
628
  groupAllowFromPath: "channels.mattermost.groupAllowFrom",
607
629
  findingTitle: "Mattermost security warning",
608
630
  policyPathSuffix: "dmPolicy",
631
+ classifyEntryAuthentication: identityEntryAuthenticationClassifier(mattermostIngressIdentity),
609
632
  normalizeDmEntry: (raw) => normalizeMattermostAllowEntry(raw)
610
633
  });
611
634
  function describeMattermostMessageTool({ cfg, accountId }) {
@@ -699,10 +722,12 @@ function normalizeMattermostThreadId(value) {
699
722
  return typeof value === "number" ? String(value) : normalizeOptionalString(value);
700
723
  }
701
724
  function buildMattermostThreadingToolContext(params) {
702
- const configuredReplyToMode = resolveMattermostReplyToMode(resolveMattermostAccount({
725
+ const account = resolveMattermostAccount({
703
726
  cfg: params.cfg,
704
727
  accountId: params.accountId ?? resolveDefaultMattermostAccountId(params.cfg)
705
- }), params.context.ChatType === "direct" || params.context.ChatType === "group" || params.context.ChatType === "channel" ? params.context.ChatType : "channel");
728
+ });
729
+ const chatType = params.context.ChatType === "direct" || params.context.ChatType === "group" || params.context.ChatType === "channel" ? params.context.ChatType : "channel";
730
+ const configuredReplyToMode = resolveMattermostReplyToMode(account, chatType);
706
731
  const currentThreadTs = normalizeMattermostThreadId(params.context.MessageThreadId) ?? normalizeMattermostThreadId(params.context.TransportThreadId) ?? normalizeOptionalString(params.context.ReplyToId);
707
732
  const currentMessageId = normalizeMattermostThreadId(params.context.CurrentMessageId);
708
733
  const hasExistingThread = Boolean(currentThreadTs) && (!currentMessageId || currentThreadTs !== currentMessageId);
@@ -838,15 +863,13 @@ const mattermostMessageActions = {
838
863
  if (action !== "send") throw new Error(`Unsupported Mattermost action: ${action}`);
839
864
  const to = typeof params.to === "string" ? params.to.trim() : typeof params.target === "string" ? params.target.trim() : "";
840
865
  if (!to) throw new Error("Mattermost send requires a target (to).");
841
- const presentation = normalizeMessagePresentation(params.presentation);
842
- const message = presentation ? renderMessagePresentationFallbackText({
843
- text: typeof params.message === "string" ? params.message : "",
844
- presentation
845
- }) : typeof params.message === "string" ? params.message : "";
866
+ const { text: message, buttons } = resolveMattermostPresentation({
867
+ text: typeof params.message === "string" ? params.message : void 0,
868
+ presentation: params.presentation
869
+ });
846
870
  const replyToId = normalizeOptionalString(params.replyToId) ?? normalizeOptionalString(params.threadId) ?? normalizeOptionalString(params.replyTo);
847
871
  const resolvedAccountId = accountId || void 0;
848
872
  const mediaUrl = resolveMattermostSendAttachmentMedia(params);
849
- const buttons = presentation ? buildMattermostPresentationButtons(presentation) : [];
850
873
  const result = await (await loadMattermostChannelRuntime()).sendMessageMattermost(to, message, {
851
874
  cfg,
852
875
  accountId: resolvedAccountId,
@@ -879,7 +902,7 @@ const mattermostMessageActions = {
879
902
  function parseMattermostReactActionParams(params) {
880
903
  const postId = normalizeOptionalString(params.messageId) ?? normalizeOptionalString(params.postId);
881
904
  if (!postId) throw new Error("Mattermost react requires messageId (post id)");
882
- const emojiName = normalizeOptionalString(params.emoji)?.replace(/^:+|:+$/g, "");
905
+ const emojiName = normalizeMattermostEmojiName(normalizeOptionalString(params.emoji));
883
906
  if (!emojiName) throw new Error("Mattermost react requires emoji");
884
907
  return {
885
908
  postId,
@@ -887,72 +910,28 @@ function parseMattermostReactActionParams(params) {
887
910
  remove: params.remove === true
888
911
  };
889
912
  }
890
- function collectNonBlankStrings(values) {
891
- const collected = [];
892
- const seen = /* @__PURE__ */ new Set();
893
- for (const value of values) {
894
- const trimmed = value?.trim();
895
- if (trimmed && !seen.has(trimmed)) {
896
- seen.add(trimmed);
897
- collected.push(trimmed);
898
- }
899
- }
900
- return collected;
901
- }
902
- function toSnakeCaseKey(key) {
903
- return key.replace(/([A-Z]+)([A-Z][a-z])/g, "$1_$2").replace(/([a-z0-9])([A-Z])/g, "$1_$2").toLowerCase();
904
- }
905
- function readMattermostParam(params, key) {
906
- if (Object.hasOwn(params, key)) return params[key];
907
- const snakeKey = toSnakeCaseKey(key);
908
- return snakeKey === key || !Object.hasOwn(params, snakeKey) ? void 0 : params[snakeKey];
909
- }
910
- function readMattermostStringParam(params, key) {
911
- const raw = readMattermostParam(params, key);
912
- return typeof raw === "string" ? normalizeOptionalString(raw) : void 0;
913
- }
914
- function readMattermostStringArrayParam(params, key) {
915
- const raw = readMattermostParam(params, key);
916
- if (Array.isArray(raw)) return raw.filter((entry) => typeof entry === "string").flatMap((entry) => {
917
- const normalized = normalizeOptionalString(entry);
918
- return normalized ? [normalized] : [];
919
- });
920
- if (typeof raw === "string") {
921
- const normalized = normalizeOptionalString(raw);
922
- return normalized ? [normalized] : [];
923
- }
924
- return [];
925
- }
926
- function requiresMattermostMediaUpload(mediaUrl) {
927
- const normalized = normalizeOptionalString(mediaUrl);
928
- return Boolean(normalized && !/^https?:\/\//i.test(normalized));
929
- }
930
- function collectMattermostAttachmentMedia(params) {
931
- const mediaUrlCandidates = [
932
- readMattermostStringParam(params, "media"),
933
- readMattermostStringParam(params, "mediaUrl"),
934
- readMattermostStringParam(params, "path"),
935
- readMattermostStringParam(params, "filePath"),
936
- readMattermostStringParam(params, "fileUrl")
913
+ function resolveMattermostSendAttachmentMedia(params) {
914
+ const sourceKeys = [
915
+ "media",
916
+ "mediaUrl",
917
+ "path",
918
+ "filePath",
919
+ "fileUrl"
937
920
  ];
938
- mediaUrlCandidates.push(...readMattermostStringArrayParam(params, "mediaUrls"));
939
- let hasUnsupportedAttachmentPayload = Boolean(readMattermostStringParam(params, "buffer") ?? readMattermostStringParam(params, "base64"));
921
+ const candidates = sourceKeys.map((key) => readStringParam(params, key));
922
+ candidates.push(...readStringArrayParam(params, "mediaUrls") ?? []);
923
+ let hasUnsupportedAttachmentPayload = Boolean(readStringParam(params, "buffer") ?? readStringParam(params, "base64"));
940
924
  if (Array.isArray(params.attachments)) for (const attachment of params.attachments) {
941
925
  if (!attachment || typeof attachment !== "object" || Array.isArray(attachment)) continue;
942
926
  const record = attachment;
943
- mediaUrlCandidates.push(readMattermostStringParam(record, "media"), readMattermostStringParam(record, "mediaUrl"), readMattermostStringParam(record, "path"), readMattermostStringParam(record, "filePath"), readMattermostStringParam(record, "fileUrl"), readMattermostStringParam(record, "url"));
944
- hasUnsupportedAttachmentPayload ||= Boolean(readMattermostStringParam(record, "buffer") ?? readMattermostStringParam(record, "base64"));
927
+ candidates.push(...sourceKeys.map((key) => readStringParam(record, key)));
928
+ candidates.push(readStringParam(record, "url"));
929
+ hasUnsupportedAttachmentPayload ||= Boolean(readStringParam(record, "buffer") ?? readStringParam(record, "base64"));
945
930
  }
946
- return {
947
- mediaUrls: collectNonBlankStrings(mediaUrlCandidates),
948
- hasUnsupportedAttachmentPayload
949
- };
950
- }
951
- function resolveMattermostSendAttachmentMedia(params) {
952
- const attachmentMedia = collectMattermostAttachmentMedia(params);
953
- if (attachmentMedia.hasUnsupportedAttachmentPayload) throw new Error("Mattermost send attachments require media, mediaUrl, path, filePath, fileUrl, mediaUrls, or attachments[] with one of those fields; buffer/base64 payloads are not supported.");
954
- if (attachmentMedia.mediaUrls.length > 1) throw new Error("Mattermost send supports one attachment per message; split multiple mediaUrls or attachments[] entries into separate sends.");
955
- return attachmentMedia.mediaUrls[0];
931
+ if (hasUnsupportedAttachmentPayload) throw new Error("Mattermost send attachments require media, mediaUrl, path, filePath, fileUrl, mediaUrls, or attachments[] with one of those fields; buffer/base64 payloads are not supported.");
932
+ const mediaUrls = [...new Set(candidates.filter((candidate) => Boolean(candidate)))];
933
+ if (mediaUrls.length > 1) throw new Error("Mattermost send supports one attachment per message; split multiple mediaUrls or attachments[] entries into separate sends.");
934
+ return mediaUrls[0];
956
935
  }
957
936
  function toMattermostOutboundResult(result) {
958
937
  const { channelId, ...delivery } = result;
@@ -986,16 +965,15 @@ const mattermostOutbound = {
986
965
  presentationCapabilities: MATTERMOST_PRESENTATION_CAPABILITIES,
987
966
  renderPresentation: ({ payload, presentation }) => {
988
967
  if (payload.mediaUrls && payload.mediaUrls.length > 1) return null;
989
- const buttons = buildMattermostPresentationButtons(presentation);
990
- const hasButtons = buttons.some((row) => row.length > 0);
991
- if (!hasButtons && !hasMattermostPresentationNavigation(presentation)) return null;
968
+ const { text, buttons } = resolveMattermostPresentation({
969
+ text: payload.text,
970
+ presentation
971
+ });
972
+ if (!buttons.length && !hasMattermostPresentationNavigation(presentation)) return null;
992
973
  return {
993
974
  ...payload,
994
- text: renderMessagePresentationFallbackText({
995
- text: payload.text,
996
- presentation
997
- }),
998
- ...hasButtons ? { channelData: {
975
+ text,
976
+ ...buttons.length ? { channelData: {
999
977
  ...payload.channelData,
1000
978
  mattermost: {
1001
979
  ...payload.channelData?.mattermost,
@@ -1013,7 +991,7 @@ const mattermostOutbound = {
1013
991
  ...ctx.payload,
1014
992
  mediaUrl: ctx.payload.mediaUrl ?? ctx.mediaUrl
1015
993
  }).map((url) => url.trim()).find(Boolean);
1016
- return attachChannelToResult("mattermost", toMattermostOutboundResult(await (await loadMattermostChannelRuntime()).sendMessageMattermost(ctx.to, ctx.payload.text ?? ctx.text, {
994
+ const result = await (await loadMattermostChannelRuntime()).sendMessageMattermost(ctx.to, ctx.payload.text ?? ctx.text, {
1017
995
  cfg: ctx.cfg,
1018
996
  accountId: ctx.accountId ?? void 0,
1019
997
  mediaUrl,
@@ -1025,7 +1003,8 @@ const mattermostOutbound = {
1025
1003
  buttons: buttons?.length ? buttons : void 0,
1026
1004
  attachmentText,
1027
1005
  onDeliveryResult: createMattermostDeliveryProgressReporter(ctx.onDeliveryResult)
1028
- })));
1006
+ });
1007
+ return attachChannelToResult("mattermost", toMattermostOutboundResult(result));
1029
1008
  }
1030
1009
  return await sendTextMediaPayload({
1031
1010
  channel: "mattermost",
@@ -1270,4 +1249,4 @@ const mattermostPlugin = createChatChannelPlugin({
1270
1249
  outbound: mattermostOutbound
1271
1250
  });
1272
1251
  //#endregion
1273
- export { MattermostChannelConfigSchema as a, mattermostConfigAdapter as c, normalizeMattermostMessagingTarget as i, mattermostMeta as l, mattermostSetupWizard as n, describeMattermostAccount as o, mattermostSetupContract as r, isMattermostConfigured$1 as s, mattermostPlugin as t };
1252
+ 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-C_mWt_83.js";
1
+ import { t as mattermostPlugin } from "./channel-plugin-runtime-iEa9Cv5W.js";
2
2
  export { mattermostPlugin };