@openclaw/mattermost 2026.7.2-beta.5 → 2026.7.33

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 (31) hide show
  1. package/dist/{client-w0lkxuKh.js → .setup/accounts-CkvUBI7I.mjs} +100 -31
  2. package/dist/.setup/channel-plugin-api-DQ6gNcH0.mjs +31 -0
  3. package/dist/.setup/channel-plugin-api-jFFWYXht.mjs +3 -0
  4. package/dist/{channel-plugin-runtime-DLBTUlbh.js → .setup/channel-plugin-runtime-BLOKRsgT.mjs} +212 -215
  5. package/dist/.setup/channel.runtime-CK6s04r7.mjs +2653 -0
  6. package/dist/.setup/doctor-contract-ttH0DCuq.mjs +7 -0
  7. package/dist/{gateway-auth-bypass-CL1PxV3z.js → .setup/gateway-auth-bypass-BIXLORHU.mjs} +2 -3
  8. package/dist/{monitor-auth-BOh6zLW9.js → .setup/monitor-auth-CeakcTAO.mjs} +12 -13
  9. package/dist/.setup/secret-contract-Cx0LUNXy.mjs +44 -0
  10. package/dist/.setup/secret-contract-api-BLTnjVCZ.mjs +3 -0
  11. package/dist/{slash-state-VCRdqj5F.js → .setup/slash-state-D1e1_KaK.mjs} +534 -189
  12. package/dist/api.js +2 -3
  13. package/dist/channel-plugin-api.js +2 -38
  14. package/dist/channel-plugin-runtime.js +1 -1
  15. package/dist/doctor-contract-api.js +1 -1
  16. package/dist/gateway-auth-api.js +1 -1
  17. package/dist/policy-api.js +1 -1
  18. package/dist/runtime-api.js +3 -2
  19. package/dist/secret-contract-api.js +1 -1
  20. package/dist/setup-entry.js +3 -2
  21. package/dist/slash-route-api.js +1 -1
  22. package/node_modules/ws/lib/permessage-deflate.js +3 -1
  23. package/node_modules/ws/package.json +1 -1
  24. package/openclaw.plugin.json +215 -255
  25. package/package.json +6 -52
  26. package/dist/accounts-BR6Nl5Qf.js +0 -71
  27. package/dist/channel.runtime-CR1V5M8l.js +0 -2873
  28. package/dist/doctor-contract-BaUvVh8e.js +0 -19
  29. package/dist/interactions-B4gg-KRm.js +0 -375
  30. package/dist/secret-contract-B4R5Bmhv.js +0 -28
  31. /package/dist/{runtime-CNB4YGqJ.js → .setup/runtime-CNB4YGqJ.mjs} +0 -0
@@ -1,49 +1,52 @@
1
- import { p as normalizeMattermostBaseUrl } from "./client-w0lkxuKh.js";
2
- import { a as buildSecretInputSchema, i as resolveMattermostReplyToMode, n as resolveDefaultMattermostAccountId, o as hasConfiguredSecretInput, r as resolveMattermostAccount, t as listMattermostAccountIds } from "./accounts-BR6Nl5Qf.js";
3
- import { t as resolveMattermostGatewayAuthBypassPaths } from "./gateway-auth-bypass-CL1PxV3z.js";
4
- import { n as normalizeCompatibilityConfig, t as legacyConfigRules } from "./doctor-contract-BaUvVh8e.js";
5
- import { n as collectRuntimeConfigAssignments, r as secretTargetRegistryEntries } from "./secret-contract-B4R5Bmhv.js";
1
+ import { C as hasConfiguredSecretInput, S as buildSecretInputSchema, g as normalizeMattermostBaseUrl, i as resolveMattermostReplyToMode, n as resolveDefaultMattermostAccountId, r as resolveMattermostAccount, t as listMattermostAccountIds } from "./accounts-CkvUBI7I.mjs";
2
+ import { t as resolveMattermostGatewayAuthBypassPaths } from "./gateway-auth-bypass-BIXLORHU.mjs";
3
+ import { n as normalizeCompatibilityConfig, t as legacyConfigRules } from "./doctor-contract-ttH0DCuq.mjs";
4
+ import { n as collectRuntimeConfigAssignments, r as secretTargetRegistryEntries } from "./secret-contract-Cx0LUNXy.mjs";
6
5
  import { normalizeLowercaseStringOrEmpty, normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
7
- import { buildPassiveProbedChannelStatusSummary } from "openclaw/plugin-sdk/extension-shared";
8
- import { isPrivateNetworkOptInEnabled } from "openclaw/plugin-sdk/ssrf-runtime";
9
- import { z } from "zod";
10
6
  import { formatNormalizedAllowFromEntries } from "openclaw/plugin-sdk/allow-from";
11
7
  import { createLoggedPairingApprovalNotifier } from "openclaw/plugin-sdk/channel-pairing";
12
8
  import { createAccountStatusSink, createChannelMessageAdapterFromOutbound } from "openclaw/plugin-sdk/channel-outbound";
13
9
  import { DEFAULT_ACCOUNT_ID as DEFAULT_ACCOUNT_ID$1, buildChannelOutboundSessionRoute, buildThreadAwareOutboundSessionRoute, stripChannelTargetPrefix, stripTargetKindPrefix } from "openclaw/plugin-sdk/core";
14
- import { createChannelConfigUiHints, createChatChannelPlugin } from "openclaw/plugin-sdk/channel-core";
15
- import { buildChannelGroupsScopeTree, buildMutableAllowEntryDetector, collectStandardAllowlistLists, createDangerousNameMatchingMutableAllowlistWarningCollector, createRestrictSendersChannelSecurity, resolveScopeRequireMention } from "openclaw/plugin-sdk/channel-policy";
10
+ import { createChatChannelPlugin } from "openclaw/plugin-sdk/channel-core";
11
+ import { createDangerousNameMatchingMutableAllowlistWarningCollector, createRestrictSendersChannelSecurity, resolveChannelGroupRequireMention } from "openclaw/plugin-sdk/channel-policy";
16
12
  import { attachChannelToResult, createAttachedChannelResultAdapter } from "openclaw/plugin-sdk/channel-send-result";
17
13
  import { createChannelDirectoryAdapter } from "openclaw/plugin-sdk/directory-runtime";
18
- import { normalizeMessagePresentation, renderMessagePresentationFallbackText, resolveMessagePresentationButtonAction, resolveMessagePresentationControlValue } from "openclaw/plugin-sdk/interactive-runtime";
14
+ import { buildPassiveProbedChannelStatusSummary } from "openclaw/plugin-sdk/extension-shared";
15
+ import { normalizeMessagePresentation, renderMessagePresentationFallbackText, resolveMessagePresentationControlValue } from "openclaw/plugin-sdk/interactive-runtime";
19
16
  import { createLazyRuntimeModule } from "openclaw/plugin-sdk/lazy-runtime";
20
17
  import { resolvePayloadMediaUrls, sendTextMediaPayload } from "openclaw/plugin-sdk/reply-payload";
18
+ import { isPrivateNetworkOptInEnabled } from "openclaw/plugin-sdk/ssrf-runtime";
21
19
  import { createComputedAccountStatusAdapter, createDefaultChannelRuntimeState } from "openclaw/plugin-sdk/status-helpers";
22
20
  import { chunkTextForOutbound, sanitizeAssistantVisibleText } from "openclaw/plugin-sdk/text-chunking";
23
- import { createChannelApprovalAuth } from "openclaw/plugin-sdk/approval-auth-runtime";
21
+ import { createResolvedApproverActionAuthAdapter, resolveApprovalApprovers } from "openclaw/plugin-sdk/approval-auth-runtime";
24
22
  import { describeAccountSnapshot } from "openclaw/plugin-sdk/account-helpers";
25
23
  import { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "openclaw/plugin-sdk/account-id";
24
+ import { z } from "zod";
26
25
  import { adaptScopedAccountAccessor, createScopedChannelConfigAdapter } from "openclaw/plugin-sdk/channel-config-helpers";
27
- import { BlockStreamingCoalesceSchema, ChannelImplicitMentionsSchema, DmPolicySchema, GroupPolicySchema, MarkdownConfigSchema, buildChannelConfigSchema, buildGroupEntrySchema, buildMultiAccountChannelSchema, requireOpenAllowFrom } from "openclaw/plugin-sdk/channel-config-schema";
28
- import { defineChannelSetupContract } from "openclaw/plugin-sdk/channel-setup";
29
- import { applyAccountNameToChannelSection, applySetupAccountConfigPatch, baseUrlTextInput, createSetupTranslator, createStandardChannelSetupStatus, defineTokenCredential, formatDocsLink, migrateBaseNameToDefaultAccount, setSetupChannelEnabled } from "openclaw/plugin-sdk/setup";
26
+ import { BlockStreamingCoalesceSchema, DmPolicySchema, GroupPolicySchema, MarkdownConfigSchema, buildChannelConfigSchema, requireOpenAllowFrom } from "openclaw/plugin-sdk/channel-config-primitives";
27
+ import { applyAccountNameToChannelSection, applySetupAccountConfigPatch, createSetupTranslator, createStandardChannelSetupStatus, formatDocsLink, migrateBaseNameToDefaultAccount } from "openclaw/plugin-sdk/setup";
30
28
  import { createSetupInputPresenceValidator } from "openclaw/plugin-sdk/setup-runtime";
31
29
  //#region extensions/mattermost/src/approval-auth.ts
32
30
  const MATTERMOST_USER_ID_RE = /^[a-z0-9]{26}$/;
33
31
  function normalizeMattermostApproverId(value) {
34
- const lowered = normalizeLowercaseStringOrEmpty(String(value).trim().replace(/^(mattermost|user):/i, "").replace(/^@/, "").trim());
32
+ const normalized = String(value).trim().replace(/^(mattermost|user):/i, "").replace(/^@/, "").trim();
33
+ const lowered = normalizeLowercaseStringOrEmpty(normalized);
35
34
  return MATTERMOST_USER_ID_RE.test(lowered) ? lowered : void 0;
36
35
  }
37
- const mattermostApprovalAuth = createChannelApprovalAuth({
36
+ const mattermostApprovalAuth = createResolvedApproverActionAuthAdapter({
38
37
  channelLabel: "Mattermost",
39
- resolveInputs: ({ cfg, accountId }) => {
40
- return { allowFrom: resolveMattermostAccount({
38
+ resolveApprovers: ({ cfg, accountId }) => {
39
+ const account = resolveMattermostAccount({
41
40
  cfg,
42
41
  accountId
43
- }).config.allowFrom };
42
+ }).config;
43
+ return resolveApprovalApprovers({
44
+ allowFrom: account.allowFrom,
45
+ normalizeApprover: normalizeMattermostApproverId
46
+ });
44
47
  },
45
- normalizeApprover: normalizeMattermostApproverId
46
- }).approvalAuth;
48
+ normalizeSenderId: (value) => normalizeMattermostApproverId(value)
49
+ });
47
50
  //#endregion
48
51
  //#region extensions/mattermost/src/channel-config-shared.ts
49
52
  const mattermostMeta = {
@@ -101,14 +104,9 @@ function describeMattermostAccount(account) {
101
104
  }
102
105
  //#endregion
103
106
  //#region extensions/mattermost/src/config-schema-core.ts
104
- const MattermostGroupSchema = buildGroupEntrySchema().omit({
105
- tools: true,
106
- toolsBySender: true,
107
- skills: true,
108
- enabled: true,
109
- allowFrom: true,
110
- systemPrompt: true
111
- });
107
+ const MattermostGroupSchema = z.object({
108
+ /** Whether mentions are required to trigger the bot in this group. */
109
+ requireMention: z.boolean().optional() }).strict();
112
110
  function requireMattermostOpenAllowFrom(params) {
113
111
  requireOpenAllowFrom({
114
112
  policy: params.policy,
@@ -158,38 +156,25 @@ const MattermostStreamingProgressSchema = z.object({
158
156
  labels: z.array(z.string()).optional(),
159
157
  maxLines: z.number().int().positive().optional(),
160
158
  maxLineChars: z.number().int().positive().optional(),
161
- toolProgress: z.boolean().optional(),
162
- commandText: z.enum(["raw", "status"]).optional()
163
- }).strict();
164
- const MattermostStreamingPreviewSchema = z.object({
165
- toolProgress: z.boolean().optional(),
166
- commandText: z.enum(["raw", "status"]).optional()
159
+ toolProgress: z.boolean().optional()
167
160
  }).strict();
161
+ const MattermostStreamingPreviewSchema = z.object({ toolProgress: z.boolean().optional() }).strict();
168
162
  const MattermostStreamingBlockSchema = z.object({
169
163
  enabled: z.boolean().optional(),
170
164
  coalesce: BlockStreamingCoalesceSchema.optional()
171
165
  }).strict();
172
- const MattermostStreamingSchema = z.object({
173
- mode: MattermostStreamingModeSchema.optional(),
174
- chunkMode: z.enum(["length", "newline"]).optional(),
175
- preview: MattermostStreamingPreviewSchema.optional(),
176
- progress: MattermostStreamingProgressSchema.optional(),
177
- block: MattermostStreamingBlockSchema.optional()
178
- }).strict();
179
- const MattermostReplyToModeSchema = z.enum([
180
- "off",
181
- "first",
182
- "all",
183
- "batched"
166
+ const MattermostStreamingSchema = z.union([
167
+ MattermostStreamingModeSchema,
168
+ z.boolean(),
169
+ z.object({
170
+ mode: MattermostStreamingModeSchema.optional(),
171
+ chunkMode: z.enum(["length", "newline"]).optional(),
172
+ preview: MattermostStreamingPreviewSchema.optional(),
173
+ progress: MattermostStreamingProgressSchema.optional(),
174
+ block: MattermostStreamingBlockSchema.optional()
175
+ }).strict()
184
176
  ]);
185
- const MattermostReplyToModeByChatTypeSchema = z.object({
186
- direct: MattermostReplyToModeSchema.optional(),
187
- group: MattermostReplyToModeSchema.optional(),
188
- channel: MattermostReplyToModeSchema.optional()
189
- }).strict();
190
- //#endregion
191
- //#region extensions/mattermost/src/config-surface.ts
192
- const MattermostChannelConfigSchema = buildChannelConfigSchema(buildMultiAccountChannelSchema(z.object({
177
+ const MattermostAccountSchemaBase = z.object({
193
178
  name: z.string().optional(),
194
179
  capabilities: z.array(z.string()).optional(),
195
180
  dangerouslyAllowNameMatching: z.boolean().optional(),
@@ -205,15 +190,21 @@ const MattermostChannelConfigSchema = buildChannelConfigSchema(buildMultiAccount
205
190
  ]).optional(),
206
191
  oncharPrefixes: z.array(z.string()).optional(),
207
192
  requireMention: z.boolean().optional(),
208
- implicitMentions: ChannelImplicitMentionsSchema.optional(),
209
193
  dmPolicy: DmPolicySchema.optional().default("pairing"),
210
194
  allowFrom: z.array(z.union([z.string(), z.number()])).optional(),
211
195
  groupAllowFrom: z.array(z.union([z.string(), z.number()])).optional(),
212
196
  groupPolicy: GroupPolicySchema.optional().default("allowlist"),
213
197
  textChunkLimit: z.number().int().positive().optional(),
198
+ chunkMode: z.enum(["length", "newline"]).optional(),
214
199
  streaming: MattermostStreamingSchema.optional(),
215
- replyToMode: MattermostReplyToModeSchema.optional(),
216
- replyToModeByChatType: MattermostReplyToModeByChatTypeSchema.optional(),
200
+ blockStreaming: z.boolean().optional(),
201
+ blockStreamingCoalesce: BlockStreamingCoalesceSchema.optional(),
202
+ replyToMode: z.enum([
203
+ "off",
204
+ "first",
205
+ "all",
206
+ "batched"
207
+ ]).optional(),
217
208
  responsePrefix: z.string().optional(),
218
209
  actions: z.object({ reactions: z.boolean().optional() }).optional(),
219
210
  commands: MattermostSlashCommandsSchema,
@@ -227,25 +218,35 @@ const MattermostChannelConfigSchema = buildChannelConfigSchema(buildMultiAccount
227
218
  network: MattermostNetworkSchema,
228
219
  /** Retry configuration for DM channel creation */
229
220
  dmChannelRetry: DmChannelRetrySchema
230
- }).strict(), {
231
- optionalAccount: true,
232
- refine: (value, ctx) => {
233
- requireMattermostOpenAllowFrom({
234
- policy: value.dmPolicy,
235
- allowFrom: value.allowFrom,
236
- ctx
237
- });
238
- }
239
- }), { uiHints: {
221
+ }).strict();
222
+ const MattermostAccountSchema = MattermostAccountSchemaBase.superRefine((value, ctx) => {
223
+ requireMattermostOpenAllowFrom({
224
+ policy: value.dmPolicy,
225
+ allowFrom: value.allowFrom,
226
+ ctx
227
+ });
228
+ });
229
+ const MattermostConfigSchema = MattermostAccountSchemaBase.extend({
230
+ accounts: z.record(z.string(), MattermostAccountSchema.optional()).optional(),
231
+ defaultAccount: z.string().optional()
232
+ }).superRefine((value, ctx) => {
233
+ requireMattermostOpenAllowFrom({
234
+ policy: value.dmPolicy,
235
+ allowFrom: value.allowFrom,
236
+ ctx
237
+ });
238
+ });
239
+ //#endregion
240
+ //#region extensions/mattermost/src/config-surface.ts
241
+ const MattermostChannelConfigSchema = buildChannelConfigSchema(MattermostConfigSchema, { uiHints: {
240
242
  "": {
241
243
  label: "Mattermost",
242
244
  help: "Mattermost channel provider configuration for bot auth, access policy, slash commands, and preview streaming."
243
245
  },
244
- ...createChannelConfigUiHints({
245
- channelLabel: "Mattermost",
246
- dmPolicy: { channelKey: "mattermost" },
247
- implicitMentions: true
248
- }),
246
+ dmPolicy: {
247
+ label: "Mattermost DM Policy",
248
+ help: "Direct message access control (\"pairing\" recommended). \"open\" requires channels.mattermost.allowFrom=[\"*\"]."
249
+ },
249
250
  streaming: {
250
251
  label: "Mattermost Streaming Mode",
251
252
  help: "Unified Mattermost stream preview mode: \"off\" | \"partial\" | \"block\" | \"progress\". \"progress\" keeps a single editable progress draft until final delivery."
@@ -254,10 +255,30 @@ const MattermostChannelConfigSchema = buildChannelConfigSchema(buildMultiAccount
254
255
  label: "Mattermost Streaming Mode",
255
256
  help: "Canonical Mattermost preview mode: \"off\" | \"partial\" | \"block\" | \"progress\"."
256
257
  },
257
- ...createChannelConfigUiHints({
258
- channelLabel: "Mattermost",
259
- progress: {}
260
- }),
258
+ "streaming.progress.label": {
259
+ label: "Mattermost Progress Label",
260
+ help: "Initial progress draft title. Use \"auto\" for built-in single-word labels, a custom string, or false to hide the title."
261
+ },
262
+ "streaming.progress.labels": {
263
+ label: "Mattermost Progress Label Pool",
264
+ help: "Candidate labels for streaming.progress.label=\"auto\". Leave unset to use OpenClaw built-in progress labels."
265
+ },
266
+ "streaming.progress.maxLines": {
267
+ label: "Mattermost Progress Max Lines",
268
+ help: "Maximum number of compact progress lines to keep below the draft label (default: 8)."
269
+ },
270
+ "streaming.progress.maxLineChars": {
271
+ label: "Mattermost Progress Max Line Chars",
272
+ help: "Maximum characters per compact progress line before truncation (default: 120). Prose cuts at word boundaries; commands and paths keep useful suffixes."
273
+ },
274
+ "streaming.progress.toolProgress": {
275
+ label: "Mattermost Progress Tool Lines",
276
+ help: "Show compact tool/progress lines in progress draft mode (default: true). Set false to keep only the label until final delivery."
277
+ },
278
+ "streaming.progress.commandText": {
279
+ label: "Mattermost Progress Command Text",
280
+ help: "Command/exec detail in progress draft lines: \"raw\" preserves released behavior; \"status\" shows only the tool label."
281
+ },
261
282
  "streaming.preview.toolProgress": {
262
283
  label: "Mattermost Draft Tool Progress",
263
284
  help: "Show tool/progress activity in the live draft preview post (default: true). Set false to hide interim tool updates while the draft preview stays active."
@@ -275,14 +296,31 @@ const MattermostChannelConfigSchema = buildChannelConfigSchema(buildMultiAccount
275
296
  help: "Merge streamed Mattermost block replies before final delivery."
276
297
  }
277
298
  } });
299
+ //#endregion
300
+ //#region extensions/mattermost/src/doctor.ts
301
+ function isMattermostMutableAllowEntry(raw) {
302
+ const text = raw.trim();
303
+ if (!text || text === "*") return false;
304
+ const normalized = text.replace(/^(mattermost|user):/i, "").replace(/^@/, "").trim();
305
+ const lowered = normalizeLowercaseStringOrEmpty(normalized);
306
+ if (/^[a-z0-9]{26}$/.test(lowered)) return false;
307
+ return true;
308
+ }
309
+ const collectMattermostMutableAllowlistWarnings = createDangerousNameMatchingMutableAllowlistWarningCollector({
310
+ channel: "mattermost",
311
+ detector: isMattermostMutableAllowEntry,
312
+ collectLists: (scope) => [{
313
+ pathLabel: `${scope.prefix}.allowFrom`,
314
+ list: scope.account.allowFrom
315
+ }, {
316
+ pathLabel: `${scope.prefix}.groupAllowFrom`,
317
+ list: scope.account.groupAllowFrom
318
+ }]
319
+ });
278
320
  const mattermostDoctor = {
279
321
  legacyConfigRules,
280
322
  normalizeCompatibilityConfig,
281
- collectMutableAllowlistWarnings: createDangerousNameMatchingMutableAllowlistWarningCollector({
282
- channel: "mattermost",
283
- detector: buildMutableAllowEntryDetector({ stableIdPattern: /^(?:(?:mattermost|user):)?@?[a-z0-9]{26}$/i }),
284
- collectLists: (scope) => collectStandardAllowlistLists(scope)
285
- })
323
+ collectMutableAllowlistWarnings: collectMattermostMutableAllowlistWarnings
286
324
  };
287
325
  //#endregion
288
326
  //#region extensions/mattermost/src/group-mentions.ts
@@ -291,11 +329,13 @@ function resolveMattermostGroupRequireMention(params) {
291
329
  cfg: params.cfg,
292
330
  accountId: params.accountId
293
331
  });
294
- return resolveScopeRequireMention({
295
- tree: buildChannelGroupsScopeTree(params.cfg, "mattermost", params.accountId),
296
- path: params.groupId ? [params.groupId] : [],
297
- requireMentionOverride: params.requireMentionOverride ?? account.requireMention,
298
- overrideOrder: "after-config"
332
+ const requireMentionOverride = typeof params.requireMentionOverride === "boolean" ? params.requireMentionOverride : account.requireMention;
333
+ return resolveChannelGroupRequireMention({
334
+ cfg: params.cfg,
335
+ channel: "mattermost",
336
+ groupId: params.groupId,
337
+ accountId: params.accountId,
338
+ requireMentionOverride
299
339
  });
300
340
  }
301
341
  //#endregion
@@ -346,21 +386,22 @@ function resolveMattermostOutboundSessionRoute(params) {
346
386
  if (!rawId) return null;
347
387
  const hasExplicitUserKind = resolvedKind === "user" || lower.startsWith("user:");
348
388
  const recipientSessionExact = isUser && hasExplicitUserKind && /^[a-z0-9]{26}$/.test(rawId);
389
+ const baseRoute = buildChannelOutboundSessionRoute({
390
+ cfg: params.cfg,
391
+ agentId: params.agentId,
392
+ channel: "mattermost",
393
+ accountId: params.accountId,
394
+ recipientSessionExact,
395
+ peer: {
396
+ kind: isUser ? "direct" : "channel",
397
+ id: rawId
398
+ },
399
+ chatType: isUser ? "direct" : "channel",
400
+ from: isUser ? `mattermost:${rawId}` : `mattermost:channel:${rawId}`,
401
+ to: isUser ? `user:${rawId}` : `channel:${rawId}`
402
+ });
349
403
  return buildThreadAwareOutboundSessionRoute({
350
- route: buildChannelOutboundSessionRoute({
351
- cfg: params.cfg,
352
- agentId: params.agentId,
353
- channel: "mattermost",
354
- accountId: params.accountId,
355
- recipientSessionExact,
356
- peer: {
357
- kind: isUser ? "direct" : "channel",
358
- id: rawId
359
- },
360
- chatType: isUser ? "direct" : "channel",
361
- from: isUser ? `mattermost:${rawId}` : `mattermost:channel:${rawId}`,
362
- to: isUser ? `user:${rawId}` : `channel:${rawId}`
363
- }),
404
+ route: baseRoute,
364
405
  replyToId: params.replyToId,
365
406
  threadId: params.threadId,
366
407
  currentSessionKey: params.currentSessionKey,
@@ -387,11 +428,12 @@ function applyMattermostSetupConfigPatch(params) {
387
428
  accountId: params.accountId,
388
429
  name: params.name
389
430
  });
431
+ const next = params.accountId !== DEFAULT_ACCOUNT_ID ? migrateBaseNameToDefaultAccount({
432
+ cfg: namedConfig,
433
+ channelKey: channel$1
434
+ }) : namedConfig;
390
435
  return applySetupAccountConfigPatch({
391
- cfg: params.accountId !== DEFAULT_ACCOUNT_ID ? migrateBaseNameToDefaultAccount({
392
- cfg: namedConfig,
393
- channelKey: channel$1
394
- }) : namedConfig,
436
+ cfg: next,
395
437
  channelKey: channel$1,
396
438
  accountId: params.accountId,
397
439
  patch: params.patch
@@ -415,64 +457,27 @@ const mattermostSetupAdapter = {
415
457
  message: "Mattermost requires --bot-token and --http-url (or --use-env)."
416
458
  }],
417
459
  validate: ({ input }) => {
418
- const setupInput = input;
419
- const token = setupInput.botToken ?? setupInput.token;
420
- const baseUrl = normalizeMattermostBaseUrl(setupInput.httpUrl);
421
- if (!setupInput.useEnv && (!token || !baseUrl)) return "Mattermost requires --bot-token and --http-url (or --use-env).";
422
- if (setupInput.httpUrl && !baseUrl) return "Mattermost --http-url must include a valid base URL.";
460
+ const token = input.botToken ?? input.token;
461
+ const baseUrl = normalizeMattermostBaseUrl(input.httpUrl);
462
+ if (!input.useEnv && (!token || !baseUrl)) return "Mattermost requires --bot-token and --http-url (or --use-env).";
463
+ if (input.httpUrl && !baseUrl) return "Mattermost --http-url must include a valid base URL.";
423
464
  return null;
424
465
  }
425
466
  }),
426
467
  applyAccountConfig: ({ cfg, accountId, input }) => {
427
- const setupInput = input;
428
- const token = setupInput.botToken ?? setupInput.token;
429
- const baseUrl = normalizeMattermostBaseUrl(setupInput.httpUrl);
468
+ const token = input.botToken ?? input.token;
469
+ const baseUrl = normalizeMattermostBaseUrl(input.httpUrl);
430
470
  return applyMattermostSetupConfigPatch({
431
471
  cfg,
432
472
  accountId,
433
- name: setupInput.name,
434
- patch: setupInput.useEnv ? {} : {
473
+ name: input.name,
474
+ patch: input.useEnv ? {} : {
435
475
  ...token ? { botToken: token } : {},
436
476
  ...baseUrl ? { baseUrl } : {}
437
477
  }
438
478
  });
439
479
  }
440
480
  };
441
- const mattermostSetupContract = defineChannelSetupContract({
442
- fields: {
443
- token: {
444
- kind: "string",
445
- sensitive: true,
446
- cli: {
447
- flags: "--token <token>",
448
- description: "Mattermost bot token"
449
- }
450
- },
451
- botToken: {
452
- kind: "string",
453
- sensitive: true,
454
- cli: {
455
- flags: "--bot-token <token>",
456
- description: "Mattermost bot token"
457
- }
458
- },
459
- httpUrl: {
460
- kind: "string",
461
- cli: {
462
- flags: "--http-url <url>",
463
- description: "Mattermost server URL"
464
- }
465
- },
466
- useEnv: {
467
- kind: "boolean",
468
- cli: {
469
- flags: "--use-env",
470
- description: "Use Mattermost environment credentials"
471
- }
472
- }
473
- },
474
- legacyAdapter: mattermostSetupAdapter
475
- });
476
481
  //#endregion
477
482
  //#region extensions/mattermost/src/setup-surface.ts
478
483
  const t = createSetupTranslator();
@@ -516,50 +521,60 @@ const mattermostSetupWizard = {
516
521
  patch: {}
517
522
  })
518
523
  },
519
- credentials: [defineTokenCredential({
524
+ credentials: [{
520
525
  inputKey: "botToken",
521
- configKey: "botToken",
522
526
  providerHint: channel,
523
527
  credentialLabel: t("wizard.mattermost.botToken"),
524
528
  preferredEnvVar: "MATTERMOST_BOT_TOKEN",
525
529
  envPrompt: t("wizard.mattermost.envPrompt"),
526
530
  keepPrompt: t("wizard.mattermost.botTokenKeep"),
527
531
  inputPrompt: t("wizard.mattermost.botTokenInput"),
528
- resolveAccount: ({ cfg, accountId }) => resolveMattermostAccountWithSecrets(cfg, accountId),
529
- accountConfigured: isMattermostConfigured,
530
- patchAccount: ({ cfg, accountId, patch }) => applyMattermostSetupConfigPatch({
532
+ inspect: ({ cfg, accountId }) => {
533
+ const resolvedAccount = resolveMattermostAccountWithSecrets(cfg, accountId);
534
+ return {
535
+ accountConfigured: isMattermostConfigured(resolvedAccount),
536
+ hasConfiguredValue: hasConfiguredSecretInput(resolvedAccount.config.botToken)
537
+ };
538
+ },
539
+ applySet: async ({ cfg, accountId, value }) => applyMattermostSetupConfigPatch({
531
540
  cfg,
532
541
  accountId,
533
- patch
534
- }),
535
- set: {}
536
- })],
537
- textInputs: [baseUrlTextInput({
542
+ patch: { botToken: value }
543
+ })
544
+ }],
545
+ textInputs: [{
538
546
  inputKey: "httpUrl",
539
- configKey: "baseUrl",
540
547
  message: t("wizard.mattermost.baseUrlPrompt"),
541
548
  confirmCurrentValue: false,
542
- resolveAccount: ({ cfg, accountId }) => resolveMattermostAccountWithSecrets(cfg, accountId),
543
- currentValue: (account) => account.baseUrl ?? process.env.MATTERMOST_URL?.trim(),
544
- includeInitialValue: true,
549
+ currentValue: ({ cfg, accountId }) => resolveMattermostAccountWithSecrets(cfg, accountId).baseUrl ?? process.env.MATTERMOST_URL?.trim(),
550
+ initialValue: ({ cfg, accountId }) => resolveMattermostAccountWithSecrets(cfg, accountId).baseUrl ?? process.env.MATTERMOST_URL?.trim(),
545
551
  shouldPrompt: ({ cfg, accountId, credentialValues, currentValue }) => {
546
552
  const resolvedAccount = resolveMattermostAccountWithSecrets(cfg, accountId);
547
553
  const tokenConfigured = Boolean(resolvedAccount.botToken?.trim()) || hasConfiguredSecretInput(resolvedAccount.config.botToken);
548
554
  return Boolean(credentialValues.botToken) || !tokenConfigured || !currentValue;
549
555
  },
550
- validate: (value) => normalizeMattermostBaseUrl(value) ? void 0 : "Mattermost base URL must include a valid base URL.",
551
- normalize: (value) => normalizeMattermostBaseUrl(value) ?? value.trim(),
552
- patchAccount: ({ cfg, accountId, patch }) => applyMattermostSetupConfigPatch({
556
+ validate: ({ value }) => normalizeMattermostBaseUrl(value) ? void 0 : "Mattermost base URL must include a valid base URL.",
557
+ normalizeValue: ({ value }) => normalizeMattermostBaseUrl(value) ?? value.trim(),
558
+ applySet: async ({ cfg, accountId, value }) => applyMattermostSetupConfigPatch({
553
559
  cfg,
554
560
  accountId,
555
- patch
561
+ patch: { baseUrl: value }
556
562
  })
557
- })],
558
- disable: (cfg) => setSetupChannelEnabled(cfg, channel, false)
563
+ }],
564
+ disable: (cfg) => ({
565
+ ...cfg,
566
+ channels: {
567
+ ...cfg.channels,
568
+ mattermost: {
569
+ ...cfg.channels?.mattermost,
570
+ enabled: false
571
+ }
572
+ }
573
+ })
559
574
  };
560
575
  //#endregion
561
576
  //#region extensions/mattermost/src/channel.ts
562
- const loadMattermostChannelRuntime = createLazyRuntimeModule(() => import("./channel.runtime-CR1V5M8l.js"));
577
+ const loadMattermostChannelRuntime = createLazyRuntimeModule(() => import("./channel.runtime-CK6s04r7.mjs"));
563
578
  function buildMattermostPresentationButtons(presentation) {
564
579
  return presentation.blocks.filter((block) => block.type === "buttons").map((block) => block.buttons.flatMap((button) => {
565
580
  if (button.action) return [];
@@ -581,11 +596,8 @@ const MATTERMOST_PRESENTATION_CAPABILITIES = {
581
596
  divider: false,
582
597
  limits: { text: { markdownDialect: "markdown" } }
583
598
  };
584
- function hasMattermostPresentationNavigation(presentation) {
585
- return presentation.blocks.some((block) => block.type === "buttons" && block.buttons.some((button) => {
586
- const action = resolveMessagePresentationButtonAction(button);
587
- return action?.type === "url" || action?.type === "web-app" && Boolean(action.url);
588
- }));
599
+ function hasMattermostPresentationButtons(presentation) {
600
+ return buildMattermostPresentationButtons(presentation).some((row) => row.length > 0);
589
601
  }
590
602
  function readMattermostPresentationButtons(payload) {
591
603
  const buttons = (payload.channelData?.mattermost)?.presentationButtons;
@@ -691,10 +703,12 @@ function normalizeMattermostThreadId(value) {
691
703
  return typeof value === "number" ? String(value) : normalizeOptionalString(value);
692
704
  }
693
705
  function buildMattermostThreadingToolContext(params) {
694
- const configuredReplyToMode = resolveMattermostReplyToMode(resolveMattermostAccount({
706
+ const account = resolveMattermostAccount({
695
707
  cfg: params.cfg,
696
708
  accountId: params.accountId ?? resolveDefaultMattermostAccountId(params.cfg)
697
- }), params.context.ChatType === "direct" || params.context.ChatType === "group" || params.context.ChatType === "channel" ? params.context.ChatType : "channel");
709
+ });
710
+ const chatType = params.context.ChatType === "direct" || params.context.ChatType === "group" || params.context.ChatType === "channel" ? params.context.ChatType : "channel";
711
+ const configuredReplyToMode = resolveMattermostReplyToMode(account, chatType);
698
712
  const currentThreadTs = normalizeMattermostThreadId(params.context.MessageThreadId) ?? normalizeMattermostThreadId(params.context.TransportThreadId) ?? normalizeOptionalString(params.context.ReplyToId);
699
713
  const currentMessageId = normalizeMattermostThreadId(params.context.CurrentMessageId);
700
714
  const hasExistingThread = Boolean(currentThreadTs) && (!currentMessageId || currentThreadTs !== currentMessageId);
@@ -722,26 +736,21 @@ const mattermostMessageActions = {
722
736
  supportsAction: ({ action }) => {
723
737
  return action === "send" || action === "react";
724
738
  },
725
- handleAction: async ({ action, params, cfg, accountId, mediaAccess, mediaLocalRoots, mediaReadFile, conversationReadOrigin }) => {
739
+ handleAction: async ({ action, params, cfg, accountId, mediaAccess, mediaLocalRoots, mediaReadFile }) => {
726
740
  if (action === "react") {
727
741
  const resolvedAccountId = accountId ?? resolveDefaultMattermostAccountId(cfg);
728
742
  const mattermostConfig = cfg.channels?.mattermost;
729
- const account = resolveMattermostAccount({
743
+ if (!(resolveMattermostAccount({
730
744
  cfg,
731
745
  accountId: resolvedAccountId
732
- });
733
- if (!account.enabled) throw new Error(`Mattermost account "${resolvedAccountId}" is disabled`);
734
- if (!(account.config.actions?.reactions ?? mattermostConfig?.actions?.reactions ?? true)) throw new Error("Mattermost reactions are disabled in config");
746
+ }).config.actions?.reactions ?? mattermostConfig?.actions?.reactions ?? true)) throw new Error("Mattermost reactions are disabled in config");
735
747
  const { postId, emojiName, remove } = parseMattermostReactActionParams(params);
736
- const authorizedTarget = normalizeOptionalString(params.to);
737
748
  if (remove) {
738
749
  const result = await (await loadMattermostChannelRuntime()).removeMattermostReaction({
739
750
  cfg,
740
751
  postId,
741
752
  emojiName,
742
- accountId: resolvedAccountId,
743
- authorizedTarget,
744
- conversationReadOrigin
753
+ accountId: resolvedAccountId
745
754
  });
746
755
  if (!result.ok) throw new Error(result.error);
747
756
  return {
@@ -756,9 +765,7 @@ const mattermostMessageActions = {
756
765
  cfg,
757
766
  postId,
758
767
  emojiName,
759
- accountId: resolvedAccountId,
760
- authorizedTarget,
761
- conversationReadOrigin
768
+ accountId: resolvedAccountId
762
769
  });
763
770
  if (!result.ok) throw new Error(result.error);
764
771
  return {
@@ -872,12 +879,13 @@ function collectMattermostAttachmentMedia(params) {
872
879
  readMattermostStringParam(params, "fileUrl")
873
880
  ];
874
881
  mediaUrlCandidates.push(...readMattermostStringArrayParam(params, "mediaUrls"));
875
- let hasUnsupportedAttachmentPayload = Boolean(readMattermostStringParam(params, "buffer") ?? readMattermostStringParam(params, "base64"));
882
+ let hasUnsupportedAttachmentPayload = typeof params.buffer === "string" || typeof params.base64 === "string";
876
883
  if (Array.isArray(params.attachments)) for (const attachment of params.attachments) {
877
884
  if (!attachment || typeof attachment !== "object" || Array.isArray(attachment)) continue;
878
885
  const record = attachment;
879
886
  mediaUrlCandidates.push(readMattermostStringParam(record, "media"), readMattermostStringParam(record, "mediaUrl"), readMattermostStringParam(record, "path"), readMattermostStringParam(record, "filePath"), readMattermostStringParam(record, "fileUrl"), readMattermostStringParam(record, "url"));
880
- hasUnsupportedAttachmentPayload ||= Boolean(readMattermostStringParam(record, "buffer") ?? readMattermostStringParam(record, "base64"));
887
+ hasUnsupportedAttachmentPayload ||= typeof record.buffer === "string";
888
+ hasUnsupportedAttachmentPayload ||= typeof record.base64 === "string";
881
889
  }
882
890
  return {
883
891
  mediaUrls: collectNonBlankStrings(mediaUrlCandidates),
@@ -902,21 +910,20 @@ const mattermostOutbound = {
902
910
  renderPresentation: ({ payload, presentation }) => {
903
911
  if (payload.mediaUrls && payload.mediaUrls.length > 1) return null;
904
912
  const buttons = buildMattermostPresentationButtons(presentation);
905
- const hasButtons = buttons.some((row) => row.length > 0);
906
- if (!hasButtons && !hasMattermostPresentationNavigation(presentation)) return null;
913
+ if (!hasMattermostPresentationButtons(presentation)) return null;
907
914
  return {
908
915
  ...payload,
909
916
  text: renderMessagePresentationFallbackText({
910
917
  text: payload.text,
911
918
  presentation
912
919
  }),
913
- ...hasButtons ? { channelData: {
920
+ channelData: {
914
921
  ...payload.channelData,
915
922
  mattermost: {
916
923
  ...payload.channelData?.mattermost,
917
924
  presentationButtons: buttons
918
925
  }
919
- } } : {}
926
+ }
920
927
  };
921
928
  },
922
929
  sendPayload: async (ctx) => {
@@ -926,7 +933,7 @@ const mattermostOutbound = {
926
933
  ...ctx.payload,
927
934
  mediaUrl: ctx.payload.mediaUrl ?? ctx.mediaUrl
928
935
  }).map((url) => url.trim()).find(Boolean);
929
- return attachChannelToResult("mattermost", await (await loadMattermostChannelRuntime()).sendMessageMattermost(ctx.to, ctx.payload.text ?? ctx.text, {
936
+ const result = await (await loadMattermostChannelRuntime()).sendMessageMattermost(ctx.to, ctx.payload.text ?? ctx.text, {
930
937
  cfg: ctx.cfg,
931
938
  accountId: ctx.accountId ?? void 0,
932
939
  mediaUrl,
@@ -936,7 +943,8 @@ const mattermostOutbound = {
936
943
  requireMediaUpload: requiresMattermostMediaUpload(mediaUrl) ? true : void 0,
937
944
  replyToId: ctx.replyToId ?? (ctx.threadId != null ? String(ctx.threadId) : void 0),
938
945
  buttons
939
- }));
946
+ });
947
+ return attachChannelToResult("mattermost", result);
940
948
  }
941
949
  return await sendTextMediaPayload({
942
950
  channel: "mattermost",
@@ -995,7 +1003,6 @@ const mattermostPlugin = createChatChannelPlugin({
995
1003
  id: "mattermost",
996
1004
  meta: { ...mattermostMeta },
997
1005
  setup: mattermostSetupAdapter,
998
- setupContract: mattermostSetupContract,
999
1006
  setupWizard: mattermostSetupWizard,
1000
1007
  capabilities: {
1001
1008
  chatTypes: [
@@ -1013,14 +1020,7 @@ const mattermostPlugin = createChatChannelPlugin({
1013
1020
  minChars: 1500,
1014
1021
  idleMs: 1e3
1015
1022
  } },
1016
- reload: {
1017
- configPrefixes: ["channels.mattermost"],
1018
- /**
1019
- * accounts.default is promoted; named resolution merges only channel-wide fields
1020
- * plus the selected account. Monitor debounce and durable ingress use accountId.
1021
- */
1022
- accountScopedRestart: true
1023
- },
1023
+ reload: { configPrefixes: ["channels.mattermost"] },
1024
1024
  configSchema: MattermostChannelConfigSchema,
1025
1025
  config: {
1026
1026
  ...mattermostConfigAdapter,
@@ -1044,8 +1044,6 @@ const mattermostPlugin = createChatChannelPlugin({
1044
1044
  }),
1045
1045
  messaging: {
1046
1046
  targetPrefixes: ["mattermost"],
1047
- directTargetStyle: "user-prefixed",
1048
- targetIdComparison: "case-sensitive",
1049
1047
  defaultMarkdownTableMode: "off",
1050
1048
  normalizeTarget: normalizeMattermostMessagingTarget,
1051
1049
  resolveDeliveryTarget: ({ conversationId, parentConversationId }) => {
@@ -1111,7 +1109,7 @@ const mattermostPlugin = createChatChannelPlugin({
1111
1109
  })
1112
1110
  }),
1113
1111
  gateway: {
1114
- resolveGatewayAuthBypassPaths: resolveMattermostGatewayAuthBypassPaths,
1112
+ resolveGatewayAuthBypassPaths: ({ cfg }) => resolveMattermostGatewayAuthBypassPaths(cfg),
1115
1113
  startAccount: async (ctx) => {
1116
1114
  const account = ctx.account;
1117
1115
  const statusSink = createAccountStatusSink({
@@ -1161,10 +1159,9 @@ const mattermostPlugin = createChatChannelPlugin({
1161
1159
  }),
1162
1160
  resolveReplyTransport: ({ threadId, replyToId, replyToIsExplicit, replyDelivery }) => {
1163
1161
  const ambientThreadId = threadId != null ? String(threadId) : void 0;
1164
- const isFlatDirect = replyDelivery?.chatType === "direct" && replyDelivery.replyToMode === "off";
1165
- const resolvedThreadId = isFlatDirect ? void 0 : replyDelivery ? replyToIsExplicit ? replyToId ?? ambientThreadId : ambientThreadId ?? replyToId ?? void 0 : ambientThreadId ?? replyToId;
1162
+ const resolvedThreadId = replyDelivery?.chatType === "direct" ? void 0 : replyDelivery ? replyToIsExplicit ? replyToId ?? ambientThreadId : ambientThreadId ?? replyToId ?? void 0 : ambientThreadId ?? replyToId;
1166
1163
  return {
1167
- replyToId: isFlatDirect ? null : resolvedThreadId,
1164
+ replyToId: replyDelivery?.chatType === "direct" ? null : resolvedThreadId,
1168
1165
  threadId: resolvedThreadId ?? null
1169
1166
  };
1170
1167
  }
@@ -1173,4 +1170,4 @@ const mattermostPlugin = createChatChannelPlugin({
1173
1170
  outbound: mattermostOutbound
1174
1171
  });
1175
1172
  //#endregion
1176
- export { normalizeMattermostMessagingTarget as a, isMattermostConfigured$1 as c, mattermostSetupContract as i, mattermostConfigAdapter as l, mattermostSetupWizard as n, MattermostChannelConfigSchema as o, mattermostSetupAdapter as r, describeMattermostAccount as s, mattermostPlugin as t, mattermostMeta as u };
1173
+ export { describeMattermostAccount as a, mattermostMeta as c, MattermostChannelConfigSchema as i, mattermostSetupWizard as n, isMattermostConfigured$1 as o, mattermostSetupAdapter as r, mattermostConfigAdapter as s, mattermostPlugin as t };