@openclaw/mattermost 2026.7.2-beta.7 → 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-CqqzTcno.js → .setup/accounts-CkvUBI7I.mjs} +101 -55
  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-DlrMaSIu.js → .setup/channel-plugin-runtime-BLOKRsgT.mjs} +260 -344
  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-rctDliGZ.js → .setup/monitor-auth-CeakcTAO.mjs} +13 -14
  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-DM8qmFJR.js → .setup/slash-state-D1e1_KaK.mjs} +572 -311
  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 +231 -277
  25. package/package.json +6 -52
  26. package/dist/accounts-NaMdx9yF.js +0 -86
  27. package/dist/channel.runtime-DndW9G7T.js +0 -3207
  28. package/dist/doctor-contract-BaUvVh8e.js +0 -19
  29. package/dist/interactions-BQXY_48h.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,15 +1,20 @@
1
1
  import { normalizeLowercaseStringOrEmpty, normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
2
- import { buildTimeoutAbortSignal } from "openclaw/plugin-sdk/extension-shared";
2
+ import { resolveChannelPreviewStreamMode, resolveChannelStreamingBlockCoalesce, resolveChannelStreamingBlockEnabled, resolveChannelStreamingChunkMode } from "openclaw/plugin-sdk/channel-outbound";
3
3
  import { resolveTimerTimeoutMs } from "openclaw/plugin-sdk/number-runtime";
4
+ import { buildTimeoutAbortSignal } from "openclaw/plugin-sdk/extension-shared";
5
+ import { fetchWithSsrFGuard, ssrfPolicyFromPrivateNetworkOptIn } from "openclaw/plugin-sdk/ssrf-runtime";
6
+ import { createAccountListHelpers, hasConfiguredAccountValue } from "openclaw/plugin-sdk/account-helpers";
7
+ import { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "openclaw/plugin-sdk/account-id";
8
+ import { resolveMergedAccountConfig } from "openclaw/plugin-sdk/account-resolution";
9
+ import { buildSecretInputSchema, hasConfiguredSecretInput, normalizeResolvedSecretInputString, normalizeSecretInputString } from "openclaw/plugin-sdk/secret-input";
4
10
  import { readProviderJsonResponse, readResponseTextLimited } from "openclaw/plugin-sdk/provider-http";
5
11
  import { readResponseWithLimit } from "openclaw/plugin-sdk/response-limit-runtime";
6
- import { retryAsync } from "openclaw/plugin-sdk/retry-runtime";
7
- import { fetchWithSsrFGuard, ssrfPolicyFromPrivateNetworkOptIn } from "openclaw/plugin-sdk/ssrf-runtime";
12
+ import { sleep } from "openclaw/plugin-sdk/runtime-env";
8
13
  import { z } from "zod";
9
14
  //#region extensions/mattermost/src/mattermost/client.ts
10
- const MATTERMOST_ERROR_BODY_LIMIT_BYTES = 8 * 1024;
15
+ const MATTERMOST_ERROR_BODY_LIMIT_BYTES = 8192;
11
16
  const MATTERMOST_REQUEST_TIMEOUT_MS = 3e4;
12
- const MATTERMOST_TEXT_RESPONSE_LIMIT_BYTES = 64 * 1024;
17
+ const MATTERMOST_TEXT_RESPONSE_LIMIT_BYTES = 65536;
13
18
  const NULL_BODY_STATUSES = /* @__PURE__ */ new Set([
14
19
  101,
15
20
  204,
@@ -27,12 +32,6 @@ const MattermostPostSchema = z.object({
27
32
  create_at: z.number().nullable().optional(),
28
33
  props: z.record(z.string(), z.unknown()).nullable().optional()
29
34
  }).passthrough();
30
- const MattermostPostListSchema = z.object({
31
- order: z.array(z.string()),
32
- posts: z.record(z.string(), MattermostPostSchema),
33
- next_post_id: z.string().nullable().optional(),
34
- prev_post_id: z.string().nullable().optional()
35
- }).passthrough();
36
35
  function normalizeMattermostBaseUrl(raw) {
37
36
  const trimmed = raw?.trim();
38
37
  if (!trimmed) return;
@@ -41,16 +40,6 @@ function normalizeMattermostBaseUrl(raw) {
41
40
  function buildMattermostApiUrl(baseUrl, path) {
42
41
  const normalized = normalizeMattermostBaseUrl(baseUrl);
43
42
  if (!normalized) throw new Error("Mattermost baseUrl is required");
44
- const pathname = (path.split(/[?#]/, 1)[0] ?? "").replace(/[\t\r\n]/g, "").replace(/\\/g, "/");
45
- for (const segment of pathname.split("/")) {
46
- let decoded;
47
- try {
48
- decoded = decodeURIComponent(segment).replace(/[\t\r\n]/g, "");
49
- } catch {
50
- throw new Error("Mattermost API path must not contain unsafe path segments");
51
- }
52
- if (decoded.split(/[\\/]/).some((part) => part === "." || part === "..")) throw new Error("Mattermost API path must not contain unsafe path segments");
53
- }
54
43
  return `${normalized}/api/v4${path.startsWith("/") ? path : `/${path}`}`;
55
44
  }
56
45
  async function readMattermostSuccessText(res, path) {
@@ -135,8 +124,9 @@ function createMattermostClient(params) {
135
124
  const fetchImpl = (externalFetchImpl ? async (input, init) => {
136
125
  const url = typeof input === "string" ? input : input instanceof URL ? input.toString() : input.url;
137
126
  const { timeoutMs: initTimeoutMs, ...requestInit } = init ?? {};
127
+ const timeoutMs = resolveTimerTimeoutMs(initTimeoutMs, requestTimeoutMs);
138
128
  const { signal: timeoutSignal, cleanup } = buildTimeoutAbortSignal({
139
- timeoutMs: resolveTimerTimeoutMs(initTimeoutMs, requestTimeoutMs),
129
+ timeoutMs,
140
130
  operation: "mattermost-api",
141
131
  url
142
132
  });
@@ -187,24 +177,7 @@ async function fetchMattermostUserByUsername(client, username) {
187
177
  return await client.request(`/users/username/${encodeURIComponent(username)}`);
188
178
  }
189
179
  async function fetchMattermostChannel(client, channelId) {
190
- return await client.request(`/channels/${encodeURIComponent(channelId)}`);
191
- }
192
- async function fetchMattermostChannelPosts(client, channelId, options = {}) {
193
- const before = normalizeOptionalString(options.before);
194
- const after = normalizeOptionalString(options.after);
195
- if (before && after) throw new Error("Mattermost read accepts either before or after, not both.");
196
- if (options.limit !== void 0 && (!Number.isSafeInteger(options.limit) || options.limit <= 0)) throw new Error("Mattermost read limit must be a positive integer.");
197
- const perPage = Math.min(options.limit ?? 60, 200);
198
- const query = new URLSearchParams({ per_page: String(perPage) });
199
- if (before) query.set("before", before);
200
- if (after) query.set("after", after);
201
- const response = await client.request(`/channels/${encodeURIComponent(channelId)}/posts?${query.toString()}`);
202
- const parsed = MattermostPostListSchema.safeParse(response);
203
- if (!parsed.success || parsed.data.order.some((postId) => !parsed.data.posts[postId])) throw new Error("Unexpected Mattermost channel posts response.");
204
- return {
205
- messages: parsed.data.order.map((postId) => parsed.data.posts[postId]),
206
- hasMore: Boolean(after ? parsed.data.next_post_id : parsed.data.prev_post_id)
207
- };
180
+ return await client.request(`/channels/${channelId}`);
208
181
  }
209
182
  async function fetchMattermostChannelByName(client, teamId, channelName) {
210
183
  return await client.request(`/teams/${teamId}/channels/name/${encodeURIComponent(channelName)}`);
@@ -285,24 +258,26 @@ const RETRYABLE_NETWORK_MESSAGE_SNIPPETS = [
285
258
  async function createMattermostDirectChannelWithRetry(client, userIds, options = {}) {
286
259
  const { maxRetries = 3, initialDelayMs = 1e3, maxDelayMs = 1e4, timeoutMs: rawTimeoutMs = 3e4, onRetry } = options;
287
260
  const timeoutMs = resolveTimerTimeoutMs(rawTimeoutMs, 3e4);
288
- return await retryAsync(async () => {
261
+ let lastError;
262
+ for (let attempt = 0; attempt <= maxRetries; attempt++) try {
289
263
  const controller = new AbortController();
290
264
  const timeoutId = setTimeout(() => controller.abort(), timeoutMs);
291
265
  try {
292
266
  return await createMattermostDirectChannel(client, userIds, controller.signal, timeoutMs);
293
- } catch (err) {
294
- throw err instanceof Error ? err : new Error(String(err));
295
267
  } finally {
296
268
  clearTimeout(timeoutId);
297
269
  }
298
- }, {
299
- attempts: maxRetries + 1,
300
- minDelayMs: Math.min(initialDelayMs, maxDelayMs),
301
- maxDelayMs,
302
- jitter: "full",
303
- shouldRetry: (err) => isRetryableError(err),
304
- onRetry: (info) => onRetry?.(info.attempt, info.delayMs, info.err)
305
- });
270
+ } catch (err) {
271
+ lastError = err instanceof Error ? err : new Error(String(err));
272
+ if (attempt >= maxRetries) break;
273
+ if (!isRetryableError(lastError)) throw lastError;
274
+ const exponentialDelay = initialDelayMs * 2 ** attempt;
275
+ const jitter = Math.random() * exponentialDelay;
276
+ const delayMs = Math.min(exponentialDelay + jitter, maxDelayMs);
277
+ if (onRetry) onRetry(attempt + 1, delayMs, lastError);
278
+ await sleep(delayMs);
279
+ }
280
+ throw lastError ?? /* @__PURE__ */ new Error("Failed to create DM channel after retries");
306
281
  }
307
282
  function isRetryableError(error) {
308
283
  const candidates = collectErrorCandidates(error);
@@ -312,9 +287,7 @@ function isRetryableError(error) {
312
287
  for (const message of messages) {
313
288
  const clientErrorMatch = message.match(/mattermost api (4\d{2})\b/);
314
289
  if (!clientErrorMatch) continue;
315
- const statusCodeText = clientErrorMatch[1];
316
- if (!statusCodeText) continue;
317
- const statusCode = Number.parseInt(statusCodeText, 10);
290
+ const statusCode = Number.parseInt(clientErrorMatch[1], 10);
318
291
  if (statusCode >= 400 && statusCode < 500) return false;
319
292
  }
320
293
  if (messages.some((message) => /mattermost api \d{3}\b/.test(message))) return false;
@@ -416,4 +389,77 @@ async function uploadMattermostFile(client, params) {
416
389
  return info;
417
390
  }
418
391
  //#endregion
419
- export { sendMattermostTyping as _, createMattermostPost as a, fetchMattermostChannelByName as c, fetchMattermostUser as d, fetchMattermostUserByUsername as f, resolveMattermostReplyDeliveryBarrierTimeoutMs as g, readMattermostError as h, createMattermostDirectChannelWithRetry as i, fetchMattermostChannelPosts as l, normalizeMattermostBaseUrl as m, buildMattermostApiUrl as n, deleteMattermostPost as o, fetchMattermostUserTeams as p, createMattermostClient as r, fetchMattermostChannel as s, MattermostPostSchema as t, fetchMattermostMe as u, updateMattermostPost as v, uploadMattermostFile as y };
392
+ //#region extensions/mattermost/src/mattermost/accounts.ts
393
+ const mattermostAccountHelpers = createAccountListHelpers("mattermost", { hasImplicitDefaultAccount: (cfg) => {
394
+ const mattermost = cfg.channels?.mattermost;
395
+ return Boolean(mattermost?.baseUrl?.trim() && (hasConfiguredAccountValue(mattermost.botToken) || process.env.MATTERMOST_BOT_TOKEN?.trim()));
396
+ } });
397
+ function listMattermostAccountIds(cfg) {
398
+ return mattermostAccountHelpers.listAccountIds(cfg);
399
+ }
400
+ function resolveDefaultMattermostAccountId(cfg) {
401
+ return mattermostAccountHelpers.resolveDefaultAccountId(cfg);
402
+ }
403
+ function mergeMattermostAccountConfig(cfg, accountId) {
404
+ return resolveMergedAccountConfig({
405
+ channelConfig: cfg.channels?.mattermost,
406
+ accounts: cfg.channels?.mattermost?.accounts,
407
+ accountId,
408
+ omitKeys: ["defaultAccount"],
409
+ nestedObjectKeys: ["commands"]
410
+ });
411
+ }
412
+ function resolveMattermostRequireMention(config) {
413
+ if (config.chatmode === "oncall") return true;
414
+ if (config.chatmode === "onmessage") return false;
415
+ if (config.chatmode === "onchar") return true;
416
+ return config.requireMention;
417
+ }
418
+ function resolveMattermostAccount(params) {
419
+ const accountId = normalizeAccountId(params.accountId ?? resolveDefaultMattermostAccountId(params.cfg));
420
+ const baseEnabled = params.cfg.channels?.mattermost?.enabled !== false;
421
+ const merged = mergeMattermostAccountConfig(params.cfg, accountId);
422
+ const accountEnabled = merged.enabled !== false;
423
+ const enabled = baseEnabled && accountEnabled;
424
+ const allowEnv = accountId === DEFAULT_ACCOUNT_ID;
425
+ const envToken = allowEnv ? process.env.MATTERMOST_BOT_TOKEN?.trim() : void 0;
426
+ const envUrl = allowEnv ? process.env.MATTERMOST_URL?.trim() : void 0;
427
+ const configToken = params.allowUnresolvedSecretRef ? normalizeSecretInputString(merged.botToken) : normalizeResolvedSecretInputString({
428
+ value: merged.botToken,
429
+ path: `channels.mattermost.accounts.${accountId}.botToken`
430
+ });
431
+ const configUrl = merged.baseUrl?.trim();
432
+ const botToken = configToken || envToken;
433
+ const baseUrl = normalizeMattermostBaseUrl(configUrl || envUrl);
434
+ const requireMention = resolveMattermostRequireMention(merged);
435
+ const botTokenSource = configToken ? "config" : envToken ? "env" : "none";
436
+ const baseUrlSource = configUrl ? "config" : envUrl ? "env" : "none";
437
+ return {
438
+ accountId,
439
+ enabled,
440
+ name: normalizeOptionalString(merged.name),
441
+ botToken,
442
+ baseUrl,
443
+ botTokenSource,
444
+ baseUrlSource,
445
+ config: merged,
446
+ chatmode: merged.chatmode,
447
+ oncharPrefixes: merged.oncharPrefixes,
448
+ requireMention,
449
+ textChunkLimit: merged.textChunkLimit,
450
+ chunkMode: resolveChannelStreamingChunkMode(merged) ?? merged.chunkMode,
451
+ streamingMode: resolveChannelPreviewStreamMode(merged, "partial"),
452
+ blockStreaming: resolveChannelStreamingBlockEnabled(merged) ?? merged.blockStreaming,
453
+ blockStreamingCoalesce: resolveChannelStreamingBlockCoalesce(merged) ?? merged.blockStreamingCoalesce
454
+ };
455
+ }
456
+ /**
457
+ * Resolve the effective replyToMode for a given chat type.
458
+ * Mattermost auto-threading only applies to channel and group messages.
459
+ */
460
+ function resolveMattermostReplyToMode(account, kind) {
461
+ if (kind === "direct") return "off";
462
+ return account.config.replyToMode ?? "off";
463
+ }
464
+ //#endregion
465
+ export { hasConfiguredSecretInput as C, buildSecretInputSchema as S, readMattermostError as _, MattermostPostSchema as a, updateMattermostPost as b, createMattermostPost as c, fetchMattermostChannelByName as d, fetchMattermostMe as f, normalizeMattermostBaseUrl as g, fetchMattermostUserTeams as h, resolveMattermostReplyToMode as i, deleteMattermostPost as l, fetchMattermostUserByUsername as m, resolveDefaultMattermostAccountId as n, createMattermostClient as o, fetchMattermostUser as p, resolveMattermostAccount as r, createMattermostDirectChannelWithRetry as s, listMattermostAccountIds as t, fetchMattermostChannel as u, resolveMattermostReplyDeliveryBarrierTimeoutMs as v, uploadMattermostFile as x, sendMattermostTyping as y };
@@ -0,0 +1,31 @@
1
+ import { a as describeMattermostAccount, c as mattermostMeta, i as MattermostChannelConfigSchema, n as mattermostSetupWizard, o as isMattermostConfigured, r as mattermostSetupAdapter, s as mattermostConfigAdapter } from "./channel-plugin-runtime-BLOKRsgT.mjs";
2
+ import { t as resolveMattermostGatewayAuthBypassPaths } from "./gateway-auth-bypass-BIXLORHU.mjs";
3
+ //#region extensions/mattermost/src/channel.setup.ts
4
+ const mattermostSetupPlugin = {
5
+ id: "mattermost",
6
+ meta: { ...mattermostMeta },
7
+ capabilities: {
8
+ chatTypes: [
9
+ "direct",
10
+ "channel",
11
+ "group",
12
+ "thread"
13
+ ],
14
+ reactions: true,
15
+ threads: true,
16
+ media: true,
17
+ nativeCommands: true
18
+ },
19
+ reload: { configPrefixes: ["channels.mattermost"] },
20
+ configSchema: MattermostChannelConfigSchema,
21
+ config: {
22
+ ...mattermostConfigAdapter,
23
+ isConfigured: isMattermostConfigured,
24
+ describeAccount: describeMattermostAccount
25
+ },
26
+ gateway: { resolveGatewayAuthBypassPaths: ({ cfg }) => resolveMattermostGatewayAuthBypassPaths(cfg) },
27
+ setup: mattermostSetupAdapter,
28
+ setupWizard: mattermostSetupWizard
29
+ };
30
+ //#endregion
31
+ export { mattermostSetupPlugin as t };
@@ -0,0 +1,3 @@
1
+ import { t as mattermostPlugin } from "./channel-plugin-runtime-BLOKRsgT.mjs";
2
+ import { t as mattermostSetupPlugin } from "./channel-plugin-api-DQ6gNcH0.mjs";
3
+ export { mattermostPlugin, mattermostSetupPlugin };