@openclaw/mattermost 2026.10.10-beta.5 → 2026.11.5-beta.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.
Files changed (56) hide show
  1. package/dist/.setup/{callback-host-Bu2cmtfI.mjs → callback-host-CRQTeNn9.mjs} +1 -2
  2. package/dist/.setup/channel-plugin-api-C5kL5jd0.mjs +1 -0
  3. package/dist/.setup/{channel-plugin-runtime-BHcfJ_4v.mjs → channel-plugin-api-CC8EU4bs.mjs} +162 -159
  4. package/dist/.setup/{channel.runtime-C0yG8kgq.mjs → channel.runtime-ukouI9k4.mjs} +41 -45
  5. package/dist/.setup/{client-B_4C9q6z.mjs → client-CVipK0N2.mjs} +12 -86
  6. package/dist/.setup/{doctor-contract-CjgZkyPm.mjs → doctor-contract-i788N90j.mjs} +6 -11
  7. package/dist/.setup/{gateway-auth-bypass-Lf99Gilr.mjs → gateway-auth-bypass-DhWaV22L.mjs} +2 -3
  8. package/dist/.setup/{ingress-identity-D6hxfxvo.mjs → ingress-identity-CtHiOUDu.mjs} +0 -1
  9. package/dist/.setup/{interactions-CQcJYGsz.mjs → interactions-cgV9-piH.mjs} +33 -53
  10. package/dist/.setup/{monitor-DYEU-u6s.mjs → monitor-Bn-I4iu7.mjs} +313 -439
  11. package/dist/.setup/{monitor-auth-DYWeWEJ4.mjs → monitor-auth-D7Fl9CyF.mjs} +7 -12
  12. package/dist/.setup/{normalize-Dli2PK7k.mjs → normalize-DuLSV4tT.mjs} +23 -11
  13. package/dist/.setup/{rolldown-runtime-BBjsoOtd.mjs → rolldown-runtime-782esTHO.mjs} +1 -2
  14. package/dist/.setup/{runtime-CNB4YGqJ.mjs → runtime-y_L8jPMH.mjs} +1 -2
  15. package/dist/.setup/secret-contract-BkDCURCE.mjs +19 -0
  16. package/dist/.setup/{secret-contract-api-ChqAE2v-.mjs → secret-contract-api-DydsmAPQ.mjs} +1 -1
  17. package/dist/.setup/send-CoWXMKnY.mjs +300 -0
  18. package/dist/.setup/{slash-state-CDj8M2pP.mjs → slash-state-CwLVacYg.mjs} +367 -420
  19. package/dist/.source-module-urls/8fb0cb1067b83fd2cf3f3ba0f7a23e627c27e8e3adf1a4ea18753ddb884ff71e.json +1 -0
  20. package/dist/api.js +2 -2
  21. package/dist/channel-plugin-api.js +1 -1
  22. package/dist/doctor-contract-api.js +1 -1
  23. package/dist/gateway-auth-api.js +1 -1
  24. package/dist/index.js +1 -2
  25. package/dist/policy-api.js +1 -1
  26. package/dist/runtime-api.js +1 -1
  27. package/dist/secret-contract-api.js +1 -1
  28. package/dist/setup-entry.js +3 -4
  29. package/dist/slash-route-api.js +1 -1
  30. package/node_modules/zod/package.json +1 -1
  31. package/node_modules/zod/src/v4/classic/tests/array.test.ts +27 -0
  32. package/node_modules/zod/src/v4/classic/tests/map.test.ts +7 -0
  33. package/node_modules/zod/src/v4/classic/tests/set.test.ts +6 -0
  34. package/node_modules/zod/src/v4/core/compile.ts +9 -0
  35. package/node_modules/zod/src/v4/core/schemas.ts +35 -1
  36. package/node_modules/zod/src/v4/core/util.ts +13 -0
  37. package/node_modules/zod/src/v4/core/versions.ts +1 -1
  38. package/node_modules/zod/v4/core/compile.cjs +8 -0
  39. package/node_modules/zod/v4/core/compile.js +8 -0
  40. package/node_modules/zod/v4/core/schemas.cjs +30 -0
  41. package/node_modules/zod/v4/core/schemas.d.cts +3 -1
  42. package/node_modules/zod/v4/core/schemas.d.ts +3 -1
  43. package/node_modules/zod/v4/core/schemas.js +30 -0
  44. package/node_modules/zod/v4/core/util.cjs +15 -0
  45. package/node_modules/zod/v4/core/util.d.cts +2 -0
  46. package/node_modules/zod/v4/core/util.d.ts +2 -0
  47. package/node_modules/zod/v4/core/util.js +14 -0
  48. package/node_modules/zod/v4/core/versions.cjs +1 -1
  49. package/node_modules/zod/v4/core/versions.js +1 -1
  50. package/openclaw.plugin.json +172 -0
  51. package/package.json +5 -5
  52. package/dist/.setup/channel-plugin-api-Di7yxxmg.mjs +0 -2
  53. package/dist/.setup/secret-contract-qg3NXRlS.mjs +0 -12
  54. package/dist/.setup/send-1f6TWzMJ.mjs +0 -400
  55. package/dist/.source-module-urls/9b327bbbce22c2cbef393c115f9a63999afd57e223aad992389710cb3f1e29cc.json +0 -1
  56. package/dist/channel-plugin-runtime.js +0 -1
@@ -1,5 +1,5 @@
1
1
  import { asOptionalRecord, normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
2
- //#region extensions/mattermost/src/mattermost/callback-host.ts
2
+ // extensions/mattermost/src/mattermost/callback-host.ts
3
3
  const DEFAULT_SLASH_CALLBACK_PATH = "/api/channels/mattermost/command";
4
4
  function normalizeCallbackPath(value) {
5
5
  const path = normalizeOptionalString(value) ?? DEFAULT_SLASH_CALLBACK_PATH;
@@ -30,5 +30,4 @@ function resolveCallbackHost(rawHost, trim = false) {
30
30
  const host = rawHost && !isWildcardBindHost(rawHost) ? trim ? rawHost.trim() : rawHost : "localhost";
31
31
  return host.includes(":") && !(host.startsWith("[") && host.endsWith("]")) ? `[${host}]` : host;
32
32
  }
33
- //#endregion
34
33
  export { normalizeCallbackPath as n, resolveCallbackHost as r, collectMattermostCallbackPaths as t };
@@ -0,0 +1 @@
1
+ export { t as mattermostPlugin, n as mattermostSetupPlugin } from "./channel-plugin-api-CC8EU4bs.mjs";
@@ -1,11 +1,10 @@
1
- import { h as normalizeMattermostBaseUrl } from "./client-B_4C9q6z.mjs";
2
- import { t as mattermostIngressIdentity } from "./ingress-identity-D6hxfxvo.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-Dli2PK7k.mjs";
4
- import { t as resolveMattermostGatewayAuthBypassPaths } from "./gateway-auth-bypass-Lf99Gilr.mjs";
5
- import { n as normalizeCompatibilityConfig, t as legacyConfigRules } from "./doctor-contract-CjgZkyPm.mjs";
6
- import { n as collectRuntimeConfigAssignments, r as secretTargetRegistryEntries } from "./secret-contract-qg3NXRlS.mjs";
1
+ import { h as normalizeMattermostBaseUrl } from "./client-CVipK0N2.mjs";
2
+ import { t as mattermostIngressIdentity } from "./ingress-identity-CtHiOUDu.mjs";
3
+ import { a as resolveMattermostPresentation, c as isMattermostConfigured, d as resolveMattermostAccount, f as resolveMattermostReplyToMode, i as requiresMattermostMediaUpload, l as listMattermostAccountIds, n as normalizeMattermostMessagingTarget, s as inspectMattermostAccount, t as looksLikeMattermostTargetId, u as resolveDefaultMattermostAccountId } from "./normalize-DuLSV4tT.mjs";
4
+ import { t as resolveMattermostGatewayAuthBypassPaths } from "./gateway-auth-bypass-DhWaV22L.mjs";
5
+ import { n as normalizeCompatibilityConfig, t as legacyConfigRules } from "./doctor-contract-i788N90j.mjs";
6
+ import { n as collectRuntimeConfigAssignments, r as secretTargetRegistryEntries } from "./secret-contract-BkDCURCE.mjs";
7
7
  import { asOptionalRecord, normalizeLowercaseStringOrEmpty, normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
8
- import { buildPassiveProbedChannelStatusSummary } from "openclaw/plugin-sdk/extension-shared";
9
8
  import { z } from "zod";
10
9
  import { formatNormalizedAllowFromEntries } from "openclaw/plugin-sdk/allow-from";
11
10
  import { createLoggedPairingApprovalNotifier } from "openclaw/plugin-sdk/channel-pairing";
@@ -19,6 +18,7 @@ import { identityEntryAuthenticationClassifier } from "openclaw/plugin-sdk/chann
19
18
  import { buildChannelGroupsScopeTree, buildMutableAllowEntryDetector, collectStandardAllowlistLists, createDangerousNameMatchingMutableAllowlistWarningCollector, createRestrictSendersChannelSecurity, resolveScopeRequireMention } from "openclaw/plugin-sdk/channel-policy";
20
19
  import { attachChannelToResult, createAttachedChannelResultAdapter } from "openclaw/plugin-sdk/channel-send-result";
21
20
  import { createChannelDirectoryAdapter } from "openclaw/plugin-sdk/directory-runtime";
21
+ import { buildPassiveProbedChannelStatusSummary } from "openclaw/plugin-sdk/extension-shared";
22
22
  import { resolveMessagePresentationButtonAction } from "openclaw/plugin-sdk/interactive-runtime";
23
23
  import { createLazyRuntimeModule } from "openclaw/plugin-sdk/lazy-runtime";
24
24
  import { resolvePayloadMediaUrls, sendTextMediaPayload } from "openclaw/plugin-sdk/reply-payload";
@@ -28,11 +28,11 @@ import { textResult } from "openclaw/plugin-sdk/tool-results";
28
28
  import { createChannelApprovalAuth } from "openclaw/plugin-sdk/approval-auth-runtime";
29
29
  import { buildSecretInputSchema, hasConfiguredSecretInput } from "openclaw/plugin-sdk/secret-input";
30
30
  import { adaptScopedAccountAccessor, createScopedChannelConfigAdapter } from "openclaw/plugin-sdk/channel-config-helpers";
31
- import { ChannelImplicitMentionsSchema, ChannelPreviewStreamingConfigSchema, ChannelStreamingPreviewSchema, ChannelStreamingProgressSchema, ContextVisibilityModeSchema, DmPolicySchema, GroupPolicySchema, MarkdownConfigSchema, buildChannelConfigSchema, buildGroupEntrySchema, buildMultiAccountChannelSchema, requireOpenAllowFrom } from "openclaw/plugin-sdk/channel-config-schema";
31
+ import { ChannelBotLoopProtectionSchema, ChannelImplicitMentionsSchema, ChannelPreviewStreamingConfigSchema, ChannelStreamingPreviewSchema, ChannelStreamingProgressSchema, ContextVisibilityModeSchema, DmPolicySchema, GroupPolicySchema, MarkdownConfigSchema, buildChannelAllowBotsSchema, buildChannelConfigSchema, buildGroupEntrySchema, buildMultiAccountChannelSchema, requireOpenAllowFrom } from "openclaw/plugin-sdk/channel-config-schema";
32
32
  import { defineChannelSetupContract } from "openclaw/plugin-sdk/channel-setup";
33
- import { applyAccountNameToChannelSection, applySetupAccountConfigPatch, baseUrlTextInput, createSetupTranslator, createStandardChannelSetupStatus, defineTokenCredential, formatDocsLink, migrateBaseNameToDefaultAccount, setSetupChannelEnabled } from "openclaw/plugin-sdk/setup";
33
+ import { applyAccountNameToChannelSection, applySetupAccountConfigPatch, baseUrlTextInput, createSetupTranslator, createStandardChannelSetupStatus, defineTokenCredential, formatDocsLink, prepareScopedSetupConfig, setSetupChannelEnabled } from "openclaw/plugin-sdk/setup";
34
34
  import { createSetupInputPresenceValidator } from "openclaw/plugin-sdk/setup-runtime";
35
- //#region extensions/mattermost/src/approval-auth.ts
35
+ // extensions/mattermost/src/approval-auth.ts
36
36
  const MATTERMOST_USER_ID_RE = /^[a-z0-9]{26}$/;
37
37
  function normalizeMattermostApproverId(value) {
38
38
  const normalized = String(value).trim().replace(/^(mattermost|user):/i, "").replace(/^@/, "");
@@ -49,8 +49,7 @@ const mattermostApprovalAuth = createChannelApprovalAuth({
49
49
  },
50
50
  normalizeApprover: normalizeMattermostApproverId
51
51
  }).approvalAuth;
52
- //#endregion
53
- //#region extensions/mattermost/src/channel-config-shared.ts
52
+ // extensions/mattermost/src/channel-config-shared.ts
54
53
  const mattermostMeta = {
55
54
  id: "mattermost",
56
55
  label: "Mattermost",
@@ -95,7 +94,7 @@ const mattermostConfigAdapter = createScopedChannelConfigAdapter({
95
94
  function describeMattermostAccount(account) {
96
95
  return describeAccountSnapshot({
97
96
  account,
98
- configured: isMattermostConfigured$1(account),
97
+ configured: isMattermostConfigured(account),
99
98
  extra: {
100
99
  botTokenSource: account.botTokenSource,
101
100
  botTokenStatus: account.botTokenStatus,
@@ -103,8 +102,7 @@ function describeMattermostAccount(account) {
103
102
  }
104
103
  });
105
104
  }
106
- //#endregion
107
- //#region extensions/mattermost/src/channel-send-result.ts
105
+ // extensions/mattermost/src/channel-send-result.ts
108
106
  function toMattermostOutboundResult(result) {
109
107
  const { channelId, ...delivery } = result;
110
108
  return {
@@ -120,9 +118,12 @@ function createMattermostDeliveryProgressReporter(onDeliveryResult) {
120
118
  await onDeliveryResult(attachChannelToResult("mattermost", toMattermostOutboundResult(result)));
121
119
  } : void 0;
122
120
  }
123
- //#endregion
124
- //#region extensions/mattermost/src/config-schema-core.ts
125
- const MattermostGroupSchema = buildGroupEntrySchema({ requireMentionInBotThreads: z.boolean().optional() }).omit({
121
+ // extensions/mattermost/src/config-schema-core.ts
122
+ const MattermostGroupSchema = buildGroupEntrySchema({
123
+ requireMentionInBotThreads: z.boolean().optional(),
124
+ allowBots: buildChannelAllowBotsSchema({ allowMentions: true }),
125
+ botLoopProtection: ChannelBotLoopProtectionSchema.optional()
126
+ }).omit({
126
127
  tools: true,
127
128
  toolsBySender: true,
128
129
  skills: true,
@@ -197,6 +198,8 @@ const MattermostAccountSchemaBase = z.object({
197
198
  oncharPrefixes: z.array(z.string()).optional(),
198
199
  requireMention: z.boolean().optional(),
199
200
  requireMentionInBotThreads: z.boolean().optional(),
201
+ allowBots: buildChannelAllowBotsSchema({ allowMentions: true }),
202
+ botLoopProtection: ChannelBotLoopProtectionSchema.optional(),
200
203
  implicitMentions: ChannelImplicitMentionsSchema.optional(),
201
204
  dmPolicy: DmPolicySchema.optional().default("pairing"),
202
205
  allowFrom: z.array(z.union([z.string(), z.number()])).optional(),
@@ -220,7 +223,6 @@ const MattermostAccountSchemaBase = z.object({
220
223
  groups: z.record(z.string(), MattermostGroupSchema.optional()).optional(),
221
224
  /** Network policy overrides for self-hosted Mattermost on trusted private/internal hosts. */
222
225
  network: MattermostNetworkSchema,
223
- /** Retry configuration for DM channel creation */
224
226
  dmChannelRetry: DmChannelRetrySchema
225
227
  }).strict();
226
228
  const MattermostConfigSchema = buildMultiAccountChannelSchema(MattermostAccountSchemaBase, {
@@ -235,8 +237,7 @@ const MattermostConfigSchema = buildMultiAccountChannelSchema(MattermostAccountS
235
237
  });
236
238
  }
237
239
  });
238
- //#endregion
239
- //#region extensions/mattermost/src/config-ui-hints.ts
240
+ // extensions/mattermost/src/config-surface.ts
240
241
  const mattermostChannelConfigUiHints = {
241
242
  "": {
242
243
  label: "Mattermost",
@@ -250,6 +251,38 @@ const mattermostChannelConfigUiHints = {
250
251
  label: "Mention in Bot Threads",
251
252
  help: "Override bot-created thread mention policy for this Mattermost channel. Exact channel settings override the wildcard, then the account setting."
252
253
  },
254
+ allowBots: {
255
+ label: "Mattermost Allow Bot Posts",
256
+ help: "Allow posts from Mattermost bot accounts to trigger replies (default: true). Set false to ignore them, or \"mentions\" to require an explicit @mention or onchar trigger in channels; thread participation does not count. Access, mention, and loop-protection rules still apply."
257
+ },
258
+ "groups.*.allowBots": {
259
+ label: "Mattermost Allow Bot Posts",
260
+ help: "Override allowBots for this Mattermost channel. Exact channel settings override the wildcard, then the account setting."
261
+ },
262
+ botLoopProtection: {
263
+ label: "Mattermost Bot Loop Protection",
264
+ help: "Sliding-window guard for Mattermost bot-to-bot loops. Default is enabled whenever allowBots lets bot posts reach dispatch."
265
+ },
266
+ "botLoopProtection.enabled": {
267
+ label: "Mattermost Bot Loop Protection Enabled",
268
+ help: "Enable the bot-pair loop guard. Defaults to true when allowBots is true or \"mentions\"; bot posts are ignored when allowBots is false."
269
+ },
270
+ "botLoopProtection.maxEventsPerWindow": {
271
+ label: "Mattermost Bot Loop Events per Window",
272
+ help: "Maximum accepted bot-pair posts within the sliding window before suppression starts. Default: 20."
273
+ },
274
+ "botLoopProtection.windowSeconds": {
275
+ label: "Mattermost Bot Loop Window Seconds",
276
+ help: "Sliding window length for counting bot-pair posts. Default: 60."
277
+ },
278
+ "botLoopProtection.cooldownSeconds": {
279
+ label: "Mattermost Bot Loop Cooldown Seconds",
280
+ help: "How long to suppress the bot pair after it exceeds the budget. Default: 60."
281
+ },
282
+ "groups.*.botLoopProtection": {
283
+ label: "Mattermost Channel Bot Loop Protection",
284
+ help: "Per-channel loop guard overrides, merged key by key over the wildcard and account settings."
285
+ },
253
286
  ...createChannelConfigUiHints({
254
287
  channelLabel: "Mattermost",
255
288
  dmPolicy: { channelKey: "mattermost" },
@@ -265,28 +298,18 @@ const mattermostChannelConfigUiHints = {
265
298
  progress: {}
266
299
  })
267
300
  };
268
- //#endregion
269
- //#region extensions/mattermost/src/config-surface.ts
270
301
  const MattermostChannelConfigSchema = buildChannelConfigSchema(MattermostConfigSchema, { uiHints: mattermostChannelConfigUiHints });
271
- //#endregion
272
- //#region extensions/mattermost/src/setup-core.ts
302
+ // extensions/mattermost/src/setup-core.ts
273
303
  const channel$1 = "mattermost";
274
- function isMattermostConfigured(account) {
275
- return (Boolean(account.botToken?.trim()) || hasConfiguredSecretInput(account.config.botToken)) && Boolean(account.baseUrl);
276
- }
277
304
  function applyMattermostSetupConfigPatch(params) {
278
- const namedConfig = applyAccountNameToChannelSection({
279
- cfg: params.cfg,
280
- channelKey: channel$1,
281
- accountId: params.accountId,
282
- name: params.name
283
- });
284
- const next = params.accountId !== DEFAULT_ACCOUNT_ID ? migrateBaseNameToDefaultAccount({
285
- cfg: namedConfig,
286
- channelKey: channel$1
287
- }) : namedConfig;
288
305
  return applySetupAccountConfigPatch({
289
- cfg: next,
306
+ cfg: prepareScopedSetupConfig({
307
+ cfg: params.cfg,
308
+ channelKey: channel$1,
309
+ accountId: params.accountId,
310
+ name: params.name,
311
+ migrateBaseName: true
312
+ }),
290
313
  channelKey: channel$1,
291
314
  accountId: params.accountId,
292
315
  patch: params.patch
@@ -372,8 +395,7 @@ const mattermostSetupContract = defineChannelSetupContract({
372
395
  },
373
396
  legacyAdapter: mattermostSetupAdapter
374
397
  });
375
- //#endregion
376
- //#region extensions/mattermost/src/setup-surface.ts
398
+ // extensions/mattermost/src/setup-surface.ts
377
399
  const t = createSetupTranslator();
378
400
  const channel = "mattermost";
379
401
  const mattermostSetupWizard = {
@@ -460,11 +482,10 @@ const mattermostSetupWizard = {
460
482
  })],
461
483
  disable: (cfg) => setSetupChannelEnabled(cfg, channel, false)
462
484
  };
463
- //#endregion
464
- //#region extensions/mattermost/src/channel.setup.ts
485
+ // extensions/mattermost/src/channel.setup.ts
465
486
  const mattermostSetupPlugin = {
466
487
  id: "mattermost",
467
- meta: { ...mattermostMeta },
488
+ meta: mattermostMeta,
468
489
  capabilities: {
469
490
  chatTypes: [
470
491
  "direct",
@@ -489,15 +510,14 @@ const mattermostSetupPlugin = {
489
510
  configSchema: MattermostChannelConfigSchema,
490
511
  config: {
491
512
  ...mattermostConfigAdapter,
492
- isConfigured: isMattermostConfigured$1,
513
+ isConfigured: isMattermostConfigured,
493
514
  describeAccount: describeMattermostAccount
494
515
  },
495
516
  gateway: { resolveGatewayAuthBypassPaths: resolveMattermostGatewayAuthBypassPaths },
496
517
  setupContract: mattermostSetupContract,
497
518
  setupWizard: mattermostSetupWizard
498
519
  };
499
- //#endregion
500
- //#region extensions/mattermost/src/doctor.ts
520
+ // extensions/mattermost/src/doctor.ts
501
521
  const isMattermostMutableAllowEntry = buildMutableAllowEntryDetector({ stableIdPattern: /^(?:(?:mattermost|user):)?@?[a-z0-9]{26}$/i });
502
522
  const collectMattermostMutableAllowlistWarnings = createDangerousNameMatchingMutableAllowlistWarningCollector({
503
523
  channel: "mattermost",
@@ -509,8 +529,7 @@ const mattermostDoctor = {
509
529
  normalizeCompatibilityConfig,
510
530
  collectMutableAllowlistWarnings: collectMattermostMutableAllowlistWarnings
511
531
  };
512
- //#endregion
513
- //#region extensions/mattermost/src/group-mentions.ts
532
+ // extensions/mattermost/src/group-mentions.ts
514
533
  function resolveMattermostGroupRequireMention(params) {
515
534
  const account = resolveMattermostAccount({
516
535
  cfg: params.cfg,
@@ -523,8 +542,7 @@ function resolveMattermostGroupRequireMention(params) {
523
542
  overrideOrder: "after-config"
524
543
  });
525
544
  }
526
- //#endregion
527
- //#region extensions/mattermost/src/mattermost/emoji.ts
545
+ // extensions/mattermost/src/mattermost/emoji.ts
528
546
  const MATTERMOST_EMOJI_SHORTNAME_BY_GLYPH = {
529
547
  "✅": "white_check_mark",
530
548
  "❌": "x",
@@ -578,8 +596,7 @@ function normalizeMattermostEmojiName(raw) {
578
596
  if (!toneSuffix || !MATTERMOST_EMOJI_TONE_CAPABLE_NAMES.has(shortname)) return shortname;
579
597
  return `${shortname}_${toneSuffix}`;
580
598
  }
581
- //#endregion
582
- //#region extensions/mattermost/src/session-route.ts
599
+ // extensions/mattermost/src/session-route.ts
583
600
  /**
584
601
  * Reads the peer chat-kind already recorded for `peerId` in an agent session
585
602
  * key. Agent session keys are
@@ -628,9 +645,8 @@ function resolveMattermostOutboundSessionRoute(params) {
628
645
  canRecoverCurrentThread: ({ route }) => route.chatType !== "direct" || (params.cfg.session?.dmScope ?? "main") !== "main"
629
646
  });
630
647
  }
631
- //#endregion
632
- //#region extensions/mattermost/src/channel.ts
633
- const loadMattermostChannelRuntime = createLazyRuntimeModule(() => import("./channel.runtime-C0yG8kgq.mjs"));
648
+ // extensions/mattermost/src/channel.ts
649
+ const loadMattermostChannelRuntime = createLazyRuntimeModule(() => import("./channel.runtime-ukouI9k4.mjs"));
634
650
  const MATTERMOST_PRESENTATION_CAPABILITIES = {
635
651
  supported: true,
636
652
  buttons: true,
@@ -645,9 +661,6 @@ function hasMattermostPresentationNavigation(presentation) {
645
661
  return action?.type === "url" || action?.type === "web-app" && Boolean(action.url);
646
662
  }));
647
663
  }
648
- function readMattermostPayloadData(payload) {
649
- return asOptionalRecord(payload.channelData?.mattermost);
650
- }
651
664
  const mattermostSecurityAdapter = createRestrictSendersChannelSecurity({
652
665
  channelKey: "mattermost",
653
666
  resolveDmPolicy: (account) => account.config.dmPolicy,
@@ -671,87 +684,15 @@ function listEnabledMattermostAccounts({ cfg, accountId }) {
671
684
  accountId: listedAccountId
672
685
  }))).filter((account) => account.enabled && account.botToken?.trim() && account.baseUrl?.trim());
673
686
  }
674
- function describeMattermostMessageTool({ cfg, accountId }) {
675
- const enabledAccounts = listEnabledMattermostAccounts({
676
- cfg,
677
- accountId
678
- });
679
- const actions = [];
680
- if (enabledAccounts.length > 0) actions.push("send");
681
- const actionsConfig = (cfg.channels?.mattermost)?.actions;
682
- const baseMessages = actionsConfig?.messages;
683
- const baseReactions = actionsConfig?.reactions;
684
- if (enabledAccounts.some((account) => {
685
- return account.config.actions?.reactions ?? baseReactions ?? true;
686
- })) actions.push("react");
687
- if (enabledAccounts.some((account) => account.config.actions?.messages ?? baseMessages ?? false)) actions.push("read");
688
- return {
689
- actions,
690
- capabilities: enabledAccounts.length > 0 ? ["presentation"] : []
691
- };
692
- }
693
- function extractMattermostToolSend(args) {
694
- if (normalizeOptionalString(args.action) !== "send") return null;
695
- const to = normalizeOptionalString(args.to) ?? normalizeOptionalString(args.target);
696
- if (!to) return null;
697
- const threadId = normalizeOptionalString(args.threadId) ?? normalizeOptionalString(args.replyToId) ?? normalizeOptionalString(args.replyTo);
698
- const threadSuppressed = args.topLevel === true || args.threadId === null;
699
- return {
700
- to,
701
- accountId: normalizeOptionalString(args.accountId),
702
- ...threadId ? { threadId } : {},
703
- ...!threadId && !threadSuppressed ? { threadImplicit: true } : {},
704
- ...threadSuppressed ? { threadSuppressed: true } : {}
705
- };
706
- }
707
- function resolveMattermostAutoThreadId(params) {
708
- const replyToId = normalizeOptionalString(params.replyToId);
709
- const context = params.toolContext;
710
- const currentThreadId = normalizeOptionalString(context?.currentThreadTs);
711
- const currentMessageId = normalizeMattermostThreadId(context?.currentMessageId);
712
- const currentTarget = normalizeMattermostThreadTarget(context?.currentChannelId);
713
- if (currentThreadId && currentTarget === normalizeMattermostThreadTarget(params.to)) {
714
- if (replyToId === currentMessageId) return currentThreadId;
715
- if (!replyToId) {
716
- const replyToMode = context?.replyToMode;
717
- return replyToMode === "all" || replyToMode === "first" && context?.hasRepliedRef?.value !== true ? currentThreadId : void 0;
718
- }
719
- }
720
- return replyToId;
721
- }
722
687
  function normalizeMattermostThreadTarget(raw) {
723
688
  const normalized = raw ? normalizeMattermostMessagingTarget(raw) : void 0;
724
689
  if (normalized) return normalized;
725
690
  const trimmed = normalizeOptionalString(raw);
726
691
  return trimmed && /^[a-z0-9]{26}$/i.test(trimmed) ? `channel:${trimmed}` : void 0;
727
692
  }
728
- function matchesMattermostToolContextTarget(params) {
729
- const target = normalizeMattermostThreadTarget(params.target);
730
- if (!target) return false;
731
- return [params.toolContext.currentChannelId, params.toolContext.currentMessagingTarget].some((currentTarget) => normalizeMattermostThreadTarget(currentTarget) === target);
732
- }
733
693
  function normalizeMattermostThreadId(value) {
734
694
  return typeof value === "number" ? String(value) : normalizeOptionalString(value);
735
695
  }
736
- function buildMattermostThreadingToolContext(params) {
737
- const account = resolveMattermostAccount({
738
- cfg: params.cfg,
739
- accountId: params.accountId ?? resolveDefaultMattermostAccountId(params.cfg)
740
- });
741
- const chatType = params.context.ChatType === "direct" || params.context.ChatType === "group" || params.context.ChatType === "channel" ? params.context.ChatType : "channel";
742
- const configuredReplyToMode = resolveMattermostReplyToMode(account, chatType);
743
- const currentThreadTs = normalizeMattermostThreadId(params.context.MessageThreadId) ?? normalizeMattermostThreadId(params.context.TransportThreadId) ?? normalizeOptionalString(params.context.ReplyToId);
744
- const currentMessageId = normalizeMattermostThreadId(params.context.CurrentMessageId);
745
- const hasExistingThread = Boolean(currentThreadTs) && (!currentMessageId || currentThreadTs !== currentMessageId);
746
- return {
747
- currentChannelId: params.context.To ? normalizeMattermostMessagingTarget(params.context.To) : void 0,
748
- currentThreadTs,
749
- currentMessageId: params.context.CurrentMessageId,
750
- replyToMode: hasExistingThread ? "all" : configuredReplyToMode,
751
- hasRepliedRef: params.hasRepliedRef,
752
- sameChannelThreadRequired: Boolean(currentThreadTs)
753
- };
754
- }
755
696
  async function listMattermostDirectoryGroups(params) {
756
697
  if (listEnabledMattermostAccounts(params).length === 0) return [];
757
698
  return (await loadMattermostChannelRuntime()).listMattermostDirectoryGroups(params);
@@ -763,13 +704,44 @@ async function listMattermostDirectoryPeers(params) {
763
704
  const mattermostMessageActions = {
764
705
  providerOwnedReadGates: ["read"],
765
706
  readAuthorityActions: ["read"],
766
- describeMessageTool: describeMattermostMessageTool,
767
- extractToolSend: ({ args }) => extractMattermostToolSend(args),
707
+ describeMessageTool({ cfg, accountId }) {
708
+ const enabledAccounts = listEnabledMattermostAccounts({
709
+ cfg,
710
+ accountId
711
+ });
712
+ const actions = [];
713
+ if (enabledAccounts.length > 0) actions.push("send");
714
+ const actionsConfig = (cfg.channels?.mattermost)?.actions;
715
+ const baseMessages = actionsConfig?.messages;
716
+ const baseReactions = actionsConfig?.reactions;
717
+ if (enabledAccounts.some((account) => {
718
+ return account.config.actions?.reactions ?? baseReactions ?? true;
719
+ })) actions.push("react");
720
+ if (enabledAccounts.some((account) => account.config.actions?.messages ?? baseMessages ?? false)) actions.push("read");
721
+ return {
722
+ actions,
723
+ capabilities: enabledAccounts.length > 0 ? ["presentation"] : []
724
+ };
725
+ },
726
+ extractToolSend({ args }) {
727
+ if (normalizeOptionalString(args.action) !== "send") return null;
728
+ const to = normalizeOptionalString(args.to) ?? normalizeOptionalString(args.target);
729
+ if (!to) return null;
730
+ const threadId = normalizeOptionalString(args.threadId) ?? normalizeOptionalString(args.replyToId) ?? normalizeOptionalString(args.replyTo);
731
+ const threadSuppressed = args.topLevel === true || args.threadId === null;
732
+ return {
733
+ to,
734
+ accountId: normalizeOptionalString(args.accountId),
735
+ ...threadId ? { threadId } : {},
736
+ ...!threadId && !threadSuppressed ? { threadImplicit: true } : {},
737
+ ...threadSuppressed ? { threadSuppressed: true } : {}
738
+ };
739
+ },
768
740
  prepareSendPayload: ({ ctx, payload }) => {
769
741
  if (ctx.action !== "send") return null;
770
742
  const mediaUrl = resolveMattermostSendAttachmentMedia(ctx.params);
771
743
  const attachmentText = typeof ctx.params.attachmentText === "string" ? ctx.params.attachmentText : void 0;
772
- const existingMattermostData = readMattermostPayloadData(payload);
744
+ const existingMattermostData = asOptionalRecord(payload.channelData?.mattermost);
773
745
  return {
774
746
  ...payload,
775
747
  ...mediaUrl ? {
@@ -826,7 +798,11 @@ const mattermostMessageActions = {
826
798
  });
827
799
  }
828
800
  if (!(account.config.actions?.reactions ?? actionsConfig?.reactions ?? true)) throw new Error("Mattermost reactions are disabled in config");
829
- const { postId, emojiName, remove } = parseMattermostReactActionParams(params);
801
+ const postId = normalizeOptionalString(params.messageId) ?? normalizeOptionalString(params.postId);
802
+ if (!postId) throw new Error("Mattermost react requires messageId (post id)");
803
+ const emojiName = normalizeMattermostEmojiName(normalizeOptionalString(params.emoji));
804
+ if (!emojiName) throw new Error("Mattermost react requires emoji");
805
+ const remove = params.remove === true;
830
806
  const authorizedTarget = normalizeOptionalString(params.to);
831
807
  const runtime = await loadMattermostChannelRuntime();
832
808
  const result = await (remove ? runtime.removeMattermostReaction : runtime.addMattermostReaction)({
@@ -841,16 +817,11 @@ const mattermostMessageActions = {
841
817
  return textResult(remove ? `Removed reaction :${emojiName}: from ${postId}` : `Reacted with :${emojiName}: on ${postId}`, {});
842
818
  }
843
819
  };
844
- function parseMattermostReactActionParams(params) {
845
- const postId = normalizeOptionalString(params.messageId) ?? normalizeOptionalString(params.postId);
846
- if (!postId) throw new Error("Mattermost react requires messageId (post id)");
847
- const emojiName = normalizeMattermostEmojiName(normalizeOptionalString(params.emoji));
848
- if (!emojiName) throw new Error("Mattermost react requires emoji");
849
- return {
850
- postId,
851
- emojiName,
852
- remove: params.remove === true
853
- };
820
+ function hasUnsupportedMattermostAttachmentPayload(record) {
821
+ return ["buffer", "base64"].some((key) => {
822
+ const value = record[key];
823
+ return typeof value === "string" ? Boolean(value.trim()) : value != null;
824
+ });
854
825
  }
855
826
  function resolveMattermostSendAttachmentMedia(params) {
856
827
  const sourceKeys = [
@@ -862,13 +833,13 @@ function resolveMattermostSendAttachmentMedia(params) {
862
833
  ];
863
834
  const candidates = sourceKeys.map((key) => readStringParam(params, key));
864
835
  candidates.push(...readStringArrayParam(params, "mediaUrls") ?? []);
865
- let hasUnsupportedAttachmentPayload = Boolean(readStringParam(params, "buffer") ?? readStringParam(params, "base64"));
836
+ let hasUnsupportedAttachmentPayload = hasUnsupportedMattermostAttachmentPayload(params);
866
837
  if (Array.isArray(params.attachments)) for (const attachment of params.attachments) {
867
838
  if (!attachment || typeof attachment !== "object" || Array.isArray(attachment)) continue;
868
839
  const record = attachment;
869
840
  candidates.push(...sourceKeys.map((key) => readStringParam(record, key)));
870
841
  candidates.push(readStringParam(record, "url"));
871
- hasUnsupportedAttachmentPayload ||= Boolean(readStringParam(record, "buffer") ?? readStringParam(record, "base64"));
842
+ hasUnsupportedAttachmentPayload ||= hasUnsupportedMattermostAttachmentPayload(record);
872
843
  }
873
844
  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.");
874
845
  const mediaUrls = [...new Set(candidates.filter((candidate) => Boolean(candidate)))];
@@ -928,7 +899,7 @@ const mattermostOutbound = {
928
899
  };
929
900
  },
930
901
  sendPayload: async (ctx) => {
931
- const mattermostData = readMattermostPayloadData(ctx.payload);
902
+ const mattermostData = asOptionalRecord(ctx.payload.channelData?.mattermost);
932
903
  const buttons = Array.isArray(mattermostData?.presentationButtons) ? mattermostData.presentationButtons : void 0;
933
904
  const rawAttachmentText = mattermostData?.attachmentText;
934
905
  const attachmentText = typeof rawAttachmentText === "string" ? rawAttachmentText : void 0;
@@ -1093,18 +1064,15 @@ const mattermostPlugin = createChatChannelPlugin({
1093
1064
  ...mattermostSetupPlugin.gateway,
1094
1065
  startAccount: async (ctx) => {
1095
1066
  const account = ctx.account;
1096
- const statusSink = createAccountStatusSink({
1097
- accountId: ctx.accountId,
1098
- setStatus: ctx.setStatus
1099
- });
1067
+ const statusSink = createAccountStatusSink(ctx);
1100
1068
  statusSink({
1101
1069
  baseUrl: account.baseUrl,
1102
1070
  botTokenSource: account.botTokenSource
1103
1071
  });
1104
1072
  ctx.log?.info(`[${account.accountId}] starting channel`);
1105
- return (await import("./monitor-DYEU-u6s.mjs")).monitorMattermostProvider({
1106
- botToken: account.botToken ?? void 0,
1107
- baseUrl: account.baseUrl ?? void 0,
1073
+ return (await import("./monitor-Bn-I4iu7.mjs")).monitorMattermostProvider({
1074
+ botToken: account.botToken,
1075
+ baseUrl: account.baseUrl,
1108
1076
  accountId: account.accountId,
1109
1077
  config: ctx.cfg,
1110
1078
  runtime: ctx.runtime,
@@ -1121,7 +1089,25 @@ const mattermostPlugin = createChatChannelPlugin({
1121
1089
  notify: createLoggedPairingApprovalNotifier(({ id }) => `[mattermost] User ${id} approved for pairing`)
1122
1090
  } },
1123
1091
  threading: {
1124
- buildToolContext: buildMattermostThreadingToolContext,
1092
+ buildToolContext(params) {
1093
+ const account = resolveMattermostAccount({
1094
+ cfg: params.cfg,
1095
+ accountId: params.accountId ?? resolveDefaultMattermostAccountId(params.cfg)
1096
+ });
1097
+ const chatType = params.context.ChatType === "direct" || params.context.ChatType === "group" || params.context.ChatType === "channel" ? params.context.ChatType : "channel";
1098
+ const configuredReplyToMode = resolveMattermostReplyToMode(account, chatType);
1099
+ const currentThreadTs = normalizeMattermostThreadId(params.context.MessageThreadId) ?? normalizeMattermostThreadId(params.context.TransportThreadId) ?? normalizeOptionalString(params.context.ReplyToId);
1100
+ const currentMessageId = normalizeMattermostThreadId(params.context.CurrentMessageId);
1101
+ const hasExistingThread = Boolean(currentThreadTs) && (!currentMessageId || currentThreadTs !== currentMessageId);
1102
+ return {
1103
+ currentChannelId: params.context.To ? normalizeMattermostMessagingTarget(params.context.To) : void 0,
1104
+ currentThreadTs,
1105
+ currentMessageId: params.context.CurrentMessageId,
1106
+ replyToMode: hasExistingThread ? "all" : configuredReplyToMode,
1107
+ hasRepliedRef: params.hasRepliedRef,
1108
+ sameChannelThreadRequired: Boolean(currentThreadTs)
1109
+ };
1110
+ },
1125
1111
  scopedAccountReplyToMode: {
1126
1112
  resolveAccount: (cfg, accountId) => resolveMattermostAccount({
1127
1113
  cfg,
@@ -1129,8 +1115,26 @@ const mattermostPlugin = createChatChannelPlugin({
1129
1115
  }),
1130
1116
  resolveReplyToMode: (account, chatType) => resolveMattermostReplyToMode(account, chatType === "direct" || chatType === "group" || chatType === "channel" ? chatType : "channel")
1131
1117
  },
1132
- resolveAutoThreadId: resolveMattermostAutoThreadId,
1133
- matchesToolContextTarget: matchesMattermostToolContextTarget,
1118
+ resolveAutoThreadId(params) {
1119
+ const replyToId = normalizeOptionalString(params.replyToId);
1120
+ const context = params.toolContext;
1121
+ const currentThreadId = normalizeOptionalString(context?.currentThreadTs);
1122
+ const currentMessageId = normalizeMattermostThreadId(context?.currentMessageId);
1123
+ const currentTarget = normalizeMattermostThreadTarget(context?.currentChannelId);
1124
+ if (currentThreadId && currentTarget === normalizeMattermostThreadTarget(params.to)) {
1125
+ if (replyToId === currentMessageId) return currentThreadId;
1126
+ if (!replyToId) {
1127
+ const replyToMode = context?.replyToMode;
1128
+ return replyToMode === "all" || replyToMode === "first" && context?.hasRepliedRef?.value !== true ? currentThreadId : void 0;
1129
+ }
1130
+ }
1131
+ return replyToId;
1132
+ },
1133
+ matchesToolContextTarget(params) {
1134
+ const target = normalizeMattermostThreadTarget(params.target);
1135
+ if (!target) return false;
1136
+ return [params.toolContext.currentChannelId, params.toolContext.currentMessagingTarget].some((currentTarget) => normalizeMattermostThreadTarget(currentTarget) === target);
1137
+ },
1134
1138
  resolveReplyTransport: ({ threadId, replyToId, replyToIsExplicit, replyDelivery }) => {
1135
1139
  const ambientThreadId = threadId != null ? String(threadId) : void 0;
1136
1140
  const isFlatDirect = replyDelivery?.chatType === "direct" && replyDelivery.replyToMode === "off";
@@ -1144,5 +1148,4 @@ const mattermostPlugin = createChatChannelPlugin({
1144
1148
  security: mattermostSecurityAdapter,
1145
1149
  outbound: mattermostOutbound
1146
1150
  });
1147
- //#endregion
1148
1151
  export { mattermostSetupPlugin as n, mattermostPlugin as t };