@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.
- package/dist/{client-w0lkxuKh.js → .setup/accounts-CkvUBI7I.mjs} +100 -31
- package/dist/.setup/channel-plugin-api-DQ6gNcH0.mjs +31 -0
- package/dist/.setup/channel-plugin-api-jFFWYXht.mjs +3 -0
- package/dist/{channel-plugin-runtime-DLBTUlbh.js → .setup/channel-plugin-runtime-BLOKRsgT.mjs} +212 -215
- package/dist/.setup/channel.runtime-CK6s04r7.mjs +2653 -0
- package/dist/.setup/doctor-contract-ttH0DCuq.mjs +7 -0
- package/dist/{gateway-auth-bypass-CL1PxV3z.js → .setup/gateway-auth-bypass-BIXLORHU.mjs} +2 -3
- package/dist/{monitor-auth-BOh6zLW9.js → .setup/monitor-auth-CeakcTAO.mjs} +12 -13
- package/dist/.setup/secret-contract-Cx0LUNXy.mjs +44 -0
- package/dist/.setup/secret-contract-api-BLTnjVCZ.mjs +3 -0
- package/dist/{slash-state-VCRdqj5F.js → .setup/slash-state-D1e1_KaK.mjs} +534 -189
- package/dist/api.js +2 -3
- package/dist/channel-plugin-api.js +2 -38
- package/dist/channel-plugin-runtime.js +1 -1
- package/dist/doctor-contract-api.js +1 -1
- package/dist/gateway-auth-api.js +1 -1
- package/dist/policy-api.js +1 -1
- package/dist/runtime-api.js +3 -2
- package/dist/secret-contract-api.js +1 -1
- package/dist/setup-entry.js +3 -2
- package/dist/slash-route-api.js +1 -1
- package/node_modules/ws/lib/permessage-deflate.js +3 -1
- package/node_modules/ws/package.json +1 -1
- package/openclaw.plugin.json +215 -255
- package/package.json +6 -52
- package/dist/accounts-BR6Nl5Qf.js +0 -71
- package/dist/channel.runtime-CR1V5M8l.js +0 -2873
- package/dist/doctor-contract-BaUvVh8e.js +0 -19
- package/dist/interactions-B4gg-KRm.js +0 -375
- package/dist/secret-contract-B4R5Bmhv.js +0 -28
- /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 {
|
|
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 {
|
|
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 =
|
|
15
|
+
const MATTERMOST_ERROR_BODY_LIMIT_BYTES = 8192;
|
|
11
16
|
const MATTERMOST_REQUEST_TIMEOUT_MS = 3e4;
|
|
12
|
-
const MATTERMOST_TEXT_RESPONSE_LIMIT_BYTES =
|
|
17
|
+
const MATTERMOST_TEXT_RESPONSE_LIMIT_BYTES = 65536;
|
|
13
18
|
const NULL_BODY_STATUSES = /* @__PURE__ */ new Set([
|
|
14
19
|
101,
|
|
15
20
|
204,
|
|
@@ -35,16 +40,6 @@ function normalizeMattermostBaseUrl(raw) {
|
|
|
35
40
|
function buildMattermostApiUrl(baseUrl, path) {
|
|
36
41
|
const normalized = normalizeMattermostBaseUrl(baseUrl);
|
|
37
42
|
if (!normalized) throw new Error("Mattermost baseUrl is required");
|
|
38
|
-
const pathname = (path.split(/[?#]/, 1)[0] ?? "").replace(/[\t\r\n]/g, "").replace(/\\/g, "/");
|
|
39
|
-
for (const segment of pathname.split("/")) {
|
|
40
|
-
let decoded;
|
|
41
|
-
try {
|
|
42
|
-
decoded = decodeURIComponent(segment).replace(/[\t\r\n]/g, "");
|
|
43
|
-
} catch {
|
|
44
|
-
throw new Error("Mattermost API path must not contain unsafe path segments");
|
|
45
|
-
}
|
|
46
|
-
if (decoded.split(/[\\/]/).some((part) => part === "." || part === "..")) throw new Error("Mattermost API path must not contain unsafe path segments");
|
|
47
|
-
}
|
|
48
43
|
return `${normalized}/api/v4${path.startsWith("/") ? path : `/${path}`}`;
|
|
49
44
|
}
|
|
50
45
|
async function readMattermostSuccessText(res, path) {
|
|
@@ -129,8 +124,9 @@ function createMattermostClient(params) {
|
|
|
129
124
|
const fetchImpl = (externalFetchImpl ? async (input, init) => {
|
|
130
125
|
const url = typeof input === "string" ? input : input instanceof URL ? input.toString() : input.url;
|
|
131
126
|
const { timeoutMs: initTimeoutMs, ...requestInit } = init ?? {};
|
|
127
|
+
const timeoutMs = resolveTimerTimeoutMs(initTimeoutMs, requestTimeoutMs);
|
|
132
128
|
const { signal: timeoutSignal, cleanup } = buildTimeoutAbortSignal({
|
|
133
|
-
timeoutMs
|
|
129
|
+
timeoutMs,
|
|
134
130
|
operation: "mattermost-api",
|
|
135
131
|
url
|
|
136
132
|
});
|
|
@@ -262,24 +258,26 @@ const RETRYABLE_NETWORK_MESSAGE_SNIPPETS = [
|
|
|
262
258
|
async function createMattermostDirectChannelWithRetry(client, userIds, options = {}) {
|
|
263
259
|
const { maxRetries = 3, initialDelayMs = 1e3, maxDelayMs = 1e4, timeoutMs: rawTimeoutMs = 3e4, onRetry } = options;
|
|
264
260
|
const timeoutMs = resolveTimerTimeoutMs(rawTimeoutMs, 3e4);
|
|
265
|
-
|
|
261
|
+
let lastError;
|
|
262
|
+
for (let attempt = 0; attempt <= maxRetries; attempt++) try {
|
|
266
263
|
const controller = new AbortController();
|
|
267
264
|
const timeoutId = setTimeout(() => controller.abort(), timeoutMs);
|
|
268
265
|
try {
|
|
269
266
|
return await createMattermostDirectChannel(client, userIds, controller.signal, timeoutMs);
|
|
270
|
-
} catch (err) {
|
|
271
|
-
throw err instanceof Error ? err : new Error(String(err));
|
|
272
267
|
} finally {
|
|
273
268
|
clearTimeout(timeoutId);
|
|
274
269
|
}
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
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");
|
|
283
281
|
}
|
|
284
282
|
function isRetryableError(error) {
|
|
285
283
|
const candidates = collectErrorCandidates(error);
|
|
@@ -289,9 +287,7 @@ function isRetryableError(error) {
|
|
|
289
287
|
for (const message of messages) {
|
|
290
288
|
const clientErrorMatch = message.match(/mattermost api (4\d{2})\b/);
|
|
291
289
|
if (!clientErrorMatch) continue;
|
|
292
|
-
const
|
|
293
|
-
if (!statusCodeText) continue;
|
|
294
|
-
const statusCode = Number.parseInt(statusCodeText, 10);
|
|
290
|
+
const statusCode = Number.parseInt(clientErrorMatch[1], 10);
|
|
295
291
|
if (statusCode >= 400 && statusCode < 500) return false;
|
|
296
292
|
}
|
|
297
293
|
if (messages.some((message) => /mattermost api \d{3}\b/.test(message))) return false;
|
|
@@ -393,4 +389,77 @@ async function uploadMattermostFile(client, params) {
|
|
|
393
389
|
return info;
|
|
394
390
|
}
|
|
395
391
|
//#endregion
|
|
396
|
-
|
|
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 };
|