@openclaw/mattermost 2026.9.1-beta.1 → 2026.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api.js +2 -2
- package/dist/channel-plugin-api.js +3 -1
- package/dist/{channel-plugin-runtime-Bh8hcegp.js → channel-plugin-runtime-Bq86sS1N.js} +107 -141
- package/dist/channel-plugin-runtime.js +1 -1
- package/dist/{channel.runtime-DLTjcasQ.js → channel.runtime-B454n78J.js} +80 -32
- package/dist/{client-DAIry9-2.js → client-Dt7Q-j5B.js} +9 -7
- package/dist/ingress-identity-DNl4yQSc.js +27 -0
- package/dist/{interactions-k47k-7SP.js → interactions-DF1FH27_.js} +28 -15
- package/dist/{monitor-auth-CVd_4FPD.js → monitor-auth-C6RGYyn-.js} +12 -31
- package/dist/{normalize-bBDFEiyJ.js → normalize-R-ATEEHC.js} +12 -4
- package/dist/policy-api.js +1 -1
- package/dist/runtime-api.js +5 -4
- package/dist/slash-route-api.js +1 -1
- package/dist/{slash-state-CfsJU7WW.js → slash-state-njvQCdwt.js} +49 -52
- package/openclaw.plugin.json +27 -2
- package/package.json +4 -4
package/dist/runtime-api.js
CHANGED
|
@@ -1,23 +1,24 @@
|
|
|
1
1
|
import { r as setMattermostRuntime } from "./runtime-CNB4YGqJ.js";
|
|
2
|
-
import { DEFAULT_ACCOUNT_ID, buildChannelConfigSchema, createDedupeCache, isTrustedProxyAddress, parseStrictPositiveInteger, resolveClientIp } from "openclaw/plugin-sdk/core";
|
|
3
2
|
import { formatInboundFromLabel, logInboundDrop } from "openclaw/plugin-sdk/channel-inbound";
|
|
4
3
|
import { resolveAllowlistMatchSimple } from "openclaw/plugin-sdk/allow-from";
|
|
5
4
|
import { createChannelPairingController } from "openclaw/plugin-sdk/channel-pairing";
|
|
6
5
|
import { createAccountStatusSink, createChannelMessageReplyPipeline } from "openclaw/plugin-sdk/channel-outbound";
|
|
7
6
|
import { logTypingFailure } from "openclaw/plugin-sdk/channel-feedback";
|
|
8
7
|
import { listSkillCommandsForAgents, resolveControlCommandGate, resolveStoredModelOverride } from "openclaw/plugin-sdk/command-auth-native";
|
|
9
|
-
import {
|
|
8
|
+
import { buildPreparedModelsProviderData } from "openclaw/plugin-sdk/models-provider-runtime";
|
|
10
9
|
import { isDangerousNameMatchingEnabled } from "openclaw/plugin-sdk/dangerous-name-runtime";
|
|
11
10
|
import { GROUP_POLICY_BLOCKED_LABEL, resolveAllowlistProviderRuntimeGroupPolicy, resolveDefaultGroupPolicy, warnMissingProviderGroupPolicyFallbackOnce } from "openclaw/plugin-sdk/runtime-group-policy";
|
|
12
|
-
import {
|
|
11
|
+
import { resolveChannelMediaMaxBytes } from "openclaw/plugin-sdk/account-helpers";
|
|
13
12
|
import { loadOutboundMediaFromUrl } from "openclaw/plugin-sdk/outbound-media";
|
|
14
13
|
import { DEFAULT_GROUP_HISTORY_LIMIT, buildPendingHistoryContextFromMap, clearHistoryEntriesIfEnabled, createChannelHistoryWindow, recordPendingHistoryEntryIfEnabled } from "openclaw/plugin-sdk/reply-history";
|
|
15
14
|
import { registerPluginHttpRoute } from "openclaw/plugin-sdk/webhook-targets";
|
|
16
15
|
import { isRequestBodyLimitError, rawDataToString, readRequestBodyWithLimit } from "openclaw/plugin-sdk/webhook-ingress";
|
|
16
|
+
import { DEFAULT_ACCOUNT_ID, buildChannelConfigSchema, createDedupeCache, isTrustedProxyAddress, parseStrictPositiveInteger, resolveClientIp } from "openclaw/plugin-sdk/core";
|
|
17
17
|
import { chunkTextForOutbound } from "openclaw/plugin-sdk/text-chunking";
|
|
18
18
|
import { applyAccountNameToChannelSection, applySetupAccountConfigPatch, migrateBaseNameToDefaultAccount } from "openclaw/plugin-sdk/setup";
|
|
19
19
|
import { buildComputedAccountStatusSnapshot } from "openclaw/plugin-sdk/channel-status";
|
|
20
20
|
import { resolveStorePath } from "openclaw/plugin-sdk/session-store-runtime";
|
|
21
21
|
import { normalizeAccountId, resolveThreadSessionKeys } from "openclaw/plugin-sdk/routing";
|
|
22
|
+
import { getAgentScopedMediaLocalRoots } from "openclaw/plugin-sdk/media-runtime";
|
|
22
23
|
import { normalizeProviderId } from "openclaw/plugin-sdk/provider-model-shared";
|
|
23
|
-
export { DEFAULT_ACCOUNT_ID, DEFAULT_GROUP_HISTORY_LIMIT, GROUP_POLICY_BLOCKED_LABEL, applyAccountNameToChannelSection, applySetupAccountConfigPatch, buildChannelConfigSchema, buildComputedAccountStatusSnapshot,
|
|
24
|
+
export { DEFAULT_ACCOUNT_ID, DEFAULT_GROUP_HISTORY_LIMIT, GROUP_POLICY_BLOCKED_LABEL, applyAccountNameToChannelSection, applySetupAccountConfigPatch, buildChannelConfigSchema, buildComputedAccountStatusSnapshot, buildPendingHistoryContextFromMap, buildPreparedModelsProviderData, chunkTextForOutbound, clearHistoryEntriesIfEnabled, createAccountStatusSink, createChannelHistoryWindow, createChannelMessageReplyPipeline, createChannelPairingController, createDedupeCache, formatInboundFromLabel, getAgentScopedMediaLocalRoots, isDangerousNameMatchingEnabled, isRequestBodyLimitError, isTrustedProxyAddress, listSkillCommandsForAgents, loadOutboundMediaFromUrl, logInboundDrop, logTypingFailure, migrateBaseNameToDefaultAccount, normalizeAccountId, normalizeProviderId, parseStrictPositiveInteger, rawDataToString, readRequestBodyWithLimit, recordPendingHistoryEntryIfEnabled, registerPluginHttpRoute, resolveAllowlistMatchSimple, resolveAllowlistProviderRuntimeGroupPolicy, resolveChannelMediaMaxBytes, resolveClientIp, resolveControlCommandGate, resolveDefaultGroupPolicy, resolveStorePath, resolveStoredModelOverride, resolveThreadSessionKeys, setMattermostRuntime, warnMissingProviderGroupPolicyFallbackOnce };
|
package/dist/slash-route-api.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { i as registerSlashCommandRoute } from "./slash-state-
|
|
1
|
+
import { i as registerSlashCommandRoute } from "./slash-state-njvQCdwt.js";
|
|
2
2
|
export { registerSlashCommandRoute };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { t as getMattermostRuntime } from "./runtime-CNB4YGqJ.js";
|
|
2
|
-
import {
|
|
3
|
-
import { a as
|
|
4
|
-
import { c as
|
|
5
|
-
import {
|
|
2
|
+
import { c as setInteractionSecret, l as isWildcardBindHost, n as buildButtonProps, o as resolveInteractionCallbackUrl } from "./interactions-DF1FH27_.js";
|
|
3
|
+
import { _ as sendMattermostTyping, a as createMattermostPost, c as fetchMattermostChannelByName, d as fetchMattermostUser, f as fetchMattermostUserByUsername, h as parseMattermostApiStatus, i as createMattermostDirectChannelWithRetry, m as normalizeMattermostBaseUrl, p as fetchMattermostUserTeams, r as createMattermostClient, s as fetchMattermostChannel, u as fetchMattermostMe, y as uploadMattermostFile } from "./client-Dt7Q-j5B.js";
|
|
4
|
+
import { _ as logTypingFailure, c as buildPreparedModelsProviderData, f as isRequestBodyLimitError, h as loadOutboundMediaFromUrl, i as normalizeMattermostAllowList, o as resolveMattermostTrustedChatKind, t as authorizeMattermostCommandInvocation, v as readRequestBodyWithLimit, w as sendHttpRequestRejection } from "./monitor-auth-C6RGYyn-.js";
|
|
5
|
+
import { i as resolveMattermostPresentation, l as resolveMattermostAccount, r as requiresMattermostMediaUpload } from "./normalize-R-ATEEHC.js";
|
|
6
6
|
import { createHash } from "node:crypto";
|
|
7
7
|
import { safeEqualSecret } from "openclaw/plugin-sdk/security-runtime";
|
|
8
8
|
import { asFiniteNumber, normalizeLowercaseStringOrEmpty, normalizeOptionalString, normalizeStringifiedOptionalString, readStringField } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
@@ -11,12 +11,12 @@ import { asDateTimestampMs, parseStrictInteger, resolveExpiresAtMsFromDurationMs
|
|
|
11
11
|
import { isPrivateNetworkOptInEnabled } from "openclaw/plugin-sdk/ssrf-runtime";
|
|
12
12
|
import { createMessageReceiptFromOutboundResults, listMessageReceiptPlatformIds } from "openclaw/plugin-sdk/channel-outbound";
|
|
13
13
|
import { resolveStoredModelOverride } from "openclaw/plugin-sdk/command-auth-native";
|
|
14
|
-
import {
|
|
14
|
+
import { resolveChannelMediaMaxBytes } from "openclaw/plugin-sdk/account-helpers";
|
|
15
15
|
import { deliverTextOrMediaReply, isReasoningReplyPayload, resolveSendableOutboundReplyParts } from "openclaw/plugin-sdk/reply-payload";
|
|
16
16
|
import { FormatCapabilityProfile, convertMarkdownTables } from "openclaw/plugin-sdk/text-chunking";
|
|
17
17
|
import { getSessionEntry, resolveStorePath } from "openclaw/plugin-sdk/session-store-runtime";
|
|
18
|
+
import { getAgentScopedMediaLocalRoots } from "openclaw/plugin-sdk/media-runtime";
|
|
18
19
|
import { normalizeProviderId } from "openclaw/plugin-sdk/provider-model-shared";
|
|
19
|
-
import { Readable } from "node:stream";
|
|
20
20
|
import { truncateUtf16Safe, truncateUtf8Prefix } from "openclaw/plugin-sdk/text-utility-runtime";
|
|
21
21
|
import { resolveHumanDelayConfig } from "openclaw/plugin-sdk/agent-runtime";
|
|
22
22
|
import { finalizeInboundContext } from "openclaw/plugin-sdk/reply-runtime";
|
|
@@ -341,12 +341,6 @@ function isSlashCommandsEnabled(config) {
|
|
|
341
341
|
*/
|
|
342
342
|
function resolveCallbackUrl(params) {
|
|
343
343
|
if (params.config.callbackUrl) return params.config.callbackUrl;
|
|
344
|
-
const isWildcardBindHost = (rawHost) => {
|
|
345
|
-
const trimmed = rawHost.trim();
|
|
346
|
-
if (!trimmed) return false;
|
|
347
|
-
const host = trimmed.startsWith("[") && trimmed.endsWith("]") ? trimmed.slice(1, -1) : trimmed;
|
|
348
|
-
return host === "0.0.0.0" || host === "::" || host === "0:0:0:0:0:0:0:0" || host === "::0";
|
|
349
|
-
};
|
|
350
344
|
let host = params.gatewayHost && !isWildcardBindHost(params.gatewayHost) ? params.gatewayHost : "localhost";
|
|
351
345
|
const path = normalizeCallbackPath(params.config.callbackPath);
|
|
352
346
|
if (host.includes(":") && !(host.startsWith("[") && host.endsWith("]"))) host = `[${host}]`;
|
|
@@ -689,7 +683,7 @@ async function deliverMattermostReplyPayload(params) {
|
|
|
689
683
|
//#endregion
|
|
690
684
|
//#region extensions/mattermost/src/mattermost/target-resolution.ts
|
|
691
685
|
const MATTERMOST_OPAQUE_TARGET_CACHE_MAX_ENTRIES = 1024;
|
|
692
|
-
const MATTERMOST_OPAQUE_TARGET_CACHE_TTL_MS =
|
|
686
|
+
const MATTERMOST_OPAQUE_TARGET_CACHE_TTL_MS = 3e5;
|
|
693
687
|
const mattermostOpaqueTargetCache = /* @__PURE__ */ new Map();
|
|
694
688
|
function cacheMattermostOpaqueTarget(key, kind) {
|
|
695
689
|
mattermostOpaqueTargetCache.set(key, {
|
|
@@ -823,7 +817,8 @@ async function resolveMattermostOpaqueTarget(params) {
|
|
|
823
817
|
};
|
|
824
818
|
}
|
|
825
819
|
try {
|
|
826
|
-
const
|
|
820
|
+
const channel = await fetchMattermostChannel(client, input);
|
|
821
|
+
const channelKind = resolveMattermostTrustedChatKind({ channelType: channel.type }) === "group" ? "group" : "channel";
|
|
827
822
|
cacheMattermostOpaqueTarget(key, channelKind);
|
|
828
823
|
return {
|
|
829
824
|
kind: channelKind,
|
|
@@ -902,11 +897,12 @@ async function resolveBotUser(baseUrl, token, allowPrivateNetwork) {
|
|
|
902
897
|
const key = cacheKey(baseUrl, token);
|
|
903
898
|
const cached = botUserCache.get(key);
|
|
904
899
|
if (cached) return cached;
|
|
905
|
-
const
|
|
900
|
+
const client = createMattermostClient({
|
|
906
901
|
baseUrl,
|
|
907
902
|
botToken: token,
|
|
908
903
|
allowPrivateNetwork
|
|
909
|
-
})
|
|
904
|
+
});
|
|
905
|
+
const user = await fetchMattermostMe(client);
|
|
910
906
|
cacheOutboundEntry(botUserCache, key, user, MATTERMOST_BOT_USER_CACHE_MAX_ENTRIES);
|
|
911
907
|
return user;
|
|
912
908
|
}
|
|
@@ -915,11 +911,12 @@ async function resolveUserIdByUsername(params) {
|
|
|
915
911
|
const key = `${cacheKey(baseUrl, token)}::${normalizeLowercaseStringOrEmpty(username)}`;
|
|
916
912
|
const cached = userByNameCache.get(key);
|
|
917
913
|
if (cached?.id) return cached.id;
|
|
918
|
-
const
|
|
914
|
+
const client = createMattermostClient({
|
|
919
915
|
baseUrl,
|
|
920
916
|
botToken: token,
|
|
921
917
|
allowPrivateNetwork: params.allowPrivateNetwork
|
|
922
|
-
})
|
|
918
|
+
});
|
|
919
|
+
const user = await fetchMattermostUserByUsername(client, username);
|
|
923
920
|
cacheOutboundEntry(userByNameCache, key, user, MATTERMOST_TARGET_CACHE_MAX_ENTRIES);
|
|
924
921
|
return user.id;
|
|
925
922
|
}
|
|
@@ -933,7 +930,8 @@ async function resolveChannelIdByName(params) {
|
|
|
933
930
|
botToken: token,
|
|
934
931
|
allowPrivateNetwork: params.allowPrivateNetwork
|
|
935
932
|
});
|
|
936
|
-
const
|
|
933
|
+
const me = await fetchMattermostMe(client);
|
|
934
|
+
const teams = await fetchMattermostUserTeams(client, me.id);
|
|
937
935
|
for (const team of teams) try {
|
|
938
936
|
const channel = await fetchMattermostChannelByName(client, team.id, name);
|
|
939
937
|
if (channel?.id) {
|
|
@@ -974,11 +972,12 @@ async function resolveTargetChannelId(params) {
|
|
|
974
972
|
const cachedDm = dmChannelCache.get(dmKey);
|
|
975
973
|
if (cachedDm) return cachedDm;
|
|
976
974
|
const botUser = await resolveBotUser(params.baseUrl, params.token, params.allowPrivateNetwork);
|
|
977
|
-
const
|
|
975
|
+
const client = createMattermostClient({
|
|
978
976
|
baseUrl: params.baseUrl,
|
|
979
977
|
botToken: params.token,
|
|
980
978
|
allowPrivateNetwork: params.allowPrivateNetwork
|
|
981
|
-
})
|
|
979
|
+
});
|
|
980
|
+
const channel = await createMattermostDirectChannelWithRetry(client, [botUser.id, userId], {
|
|
982
981
|
...params.dmRetryOptions,
|
|
983
982
|
onRetry: (attempt, delayMs, error) => {
|
|
984
983
|
params.dmRetryOptions?.onRetry?.(attempt, delayMs, error);
|
|
@@ -1035,13 +1034,18 @@ async function resolveMattermostSendContext(to, opts) {
|
|
|
1035
1034
|
token,
|
|
1036
1035
|
baseUrl,
|
|
1037
1036
|
channelId,
|
|
1038
|
-
allowPrivateNetwork
|
|
1037
|
+
allowPrivateNetwork,
|
|
1038
|
+
mediaMaxBytes: resolveChannelMediaMaxBytes({
|
|
1039
|
+
cfg,
|
|
1040
|
+
accountId: account.accountId,
|
|
1041
|
+
resolveChannelLimitMb: () => account.config.mediaMaxMb
|
|
1042
|
+
})
|
|
1039
1043
|
};
|
|
1040
1044
|
}
|
|
1041
1045
|
async function sendMessageMattermost(to, text, opts) {
|
|
1042
1046
|
const core = getCore();
|
|
1043
1047
|
const logger = core.logging.getChildLogger({ module: "mattermost" });
|
|
1044
|
-
const { cfg, accountId, token, baseUrl, channelId, allowPrivateNetwork } = await resolveMattermostSendContext(to, opts);
|
|
1048
|
+
const { cfg, accountId, token, baseUrl, channelId, allowPrivateNetwork, mediaMaxBytes } = await resolveMattermostSendContext(to, opts);
|
|
1045
1049
|
const client = createMattermostClient({
|
|
1046
1050
|
baseUrl,
|
|
1047
1051
|
botToken: token,
|
|
@@ -1070,6 +1074,7 @@ async function sendMessageMattermost(to, text, opts) {
|
|
|
1070
1074
|
const mediaUrl = opts.mediaUrl?.trim();
|
|
1071
1075
|
if (mediaUrl) try {
|
|
1072
1076
|
const media = await loadOutboundMediaFromUrl(mediaUrl, {
|
|
1077
|
+
maxBytes: mediaMaxBytes,
|
|
1073
1078
|
mediaLocalRoots: opts.mediaLocalRoots,
|
|
1074
1079
|
mediaReadFile: opts.mediaReadFile,
|
|
1075
1080
|
workspaceDir: opts.workspaceDir
|
|
@@ -1082,7 +1087,7 @@ async function sendMessageMattermost(to, text, opts) {
|
|
|
1082
1087
|
})).id];
|
|
1083
1088
|
} catch (err) {
|
|
1084
1089
|
uploadError = err instanceof Error ? err : new Error(String(err));
|
|
1085
|
-
if (opts.requireMediaUpload) throw new Error(`Mattermost media upload failed: ${uploadError.message}`, { cause: err });
|
|
1090
|
+
if (opts.requireMediaUpload || mediaMaxBytes !== void 0) throw new Error(`Mattermost media upload failed: ${uploadError.message}`, { cause: err });
|
|
1086
1091
|
if (core.logging.shouldLogVerbose()) logger.debug?.(`mattermost send: media upload failed, falling back to URL text: ${String(err)}`);
|
|
1087
1092
|
message = normalizeMessage(message, isHttpUrl(mediaUrl) ? mediaUrl : "");
|
|
1088
1093
|
}
|
|
@@ -1137,7 +1142,7 @@ async function sendMessageMattermost(to, text, opts) {
|
|
|
1137
1142
|
}
|
|
1138
1143
|
//#endregion
|
|
1139
1144
|
//#region extensions/mattermost/src/mattermost/slash-http.ts
|
|
1140
|
-
const MAX_BODY_BYTES =
|
|
1145
|
+
const MAX_BODY_BYTES = 65536;
|
|
1141
1146
|
const BODY_READ_TIMEOUT_MS = 5e3;
|
|
1142
1147
|
const COMMAND_LOOKUP_TIMEOUT_MS = 1e3;
|
|
1143
1148
|
const COMMAND_VALIDATION_FAILURE_CACHE_MS = 5e3;
|
|
@@ -1163,7 +1168,8 @@ const SECRET_LOG_KEYS = /* @__PURE__ */ new Set([
|
|
|
1163
1168
|
function readBody(req, maxBytes, timeoutMs = BODY_READ_TIMEOUT_MS) {
|
|
1164
1169
|
return readRequestBodyWithLimit(req, {
|
|
1165
1170
|
maxBytes,
|
|
1166
|
-
timeoutMs
|
|
1171
|
+
timeoutMs,
|
|
1172
|
+
destroyOnLimit: false
|
|
1167
1173
|
});
|
|
1168
1174
|
}
|
|
1169
1175
|
function sendJsonResponse(res, status, body) {
|
|
@@ -1179,7 +1185,7 @@ function isDeletedMattermostCommand(command) {
|
|
|
1179
1185
|
return typeof command.delete_at === "number" && command.delete_at > 0;
|
|
1180
1186
|
}
|
|
1181
1187
|
function sanitizeCommandLookupError(error) {
|
|
1182
|
-
|
|
1188
|
+
const sanitized = (error instanceof Error ? error.message : String(error)).replace(/[\r\n\t]/gu, " ").replace(/https?:\/\/[^\s)\]}]+/giu, (urlText) => {
|
|
1183
1189
|
try {
|
|
1184
1190
|
const url = new URL(urlText);
|
|
1185
1191
|
if (url.username || url.password) {
|
|
@@ -1191,7 +1197,8 @@ function sanitizeCommandLookupError(error) {
|
|
|
1191
1197
|
} catch {
|
|
1192
1198
|
return urlText;
|
|
1193
1199
|
}
|
|
1194
|
-
}).replace(/(^|[^\w-])(Bearer|Token)\s+[A-Za-z0-9._~+/=-]+/giu, "$1$2 [redacted]").replace(/\b(token|authorization|access_token|refresh_token|client_secret|botToken)\b(\s*["']?\s*(?:=|:)\s*["']?)[^"',\s;}]+/giu, "$1$2[redacted]")
|
|
1200
|
+
}).replace(/(^|[^\w-])(Bearer|Token)\s+[A-Za-z0-9._~+/=-]+/giu, "$1$2 [redacted]").replace(/\b(token|authorization|access_token|refresh_token|client_secret|botToken)\b(\s*["']?\s*(?:=|:)\s*["']?)[^"',\s;}]+/giu, "$1$2[redacted]");
|
|
1201
|
+
return truncateUtf16Safe(sanitized, 300);
|
|
1195
1202
|
}
|
|
1196
1203
|
function sanitizeMattermostLogValue(value) {
|
|
1197
1204
|
return truncateUtf16Safe(value.replace(/[\r\n\t]/gu, " "), 200);
|
|
@@ -1271,7 +1278,8 @@ function sweepCommandValidationLookupRateLimit(now = Date.now()) {
|
|
|
1271
1278
|
}
|
|
1272
1279
|
}
|
|
1273
1280
|
function reserveCommandValidationLookup(params) {
|
|
1274
|
-
const
|
|
1281
|
+
const rawNow = params.now ?? Date.now();
|
|
1282
|
+
const now = asDateTimestampMs(rawNow);
|
|
1275
1283
|
if (now === void 0) {
|
|
1276
1284
|
commandValidationLookupRateLimit.clear();
|
|
1277
1285
|
return { allowed: true };
|
|
@@ -1281,7 +1289,7 @@ function reserveCommandValidationLookup(params) {
|
|
|
1281
1289
|
if (!existing) {
|
|
1282
1290
|
commandValidationLookupRateLimit.set(params.key, {
|
|
1283
1291
|
accountId: params.accountId,
|
|
1284
|
-
tokens:
|
|
1292
|
+
tokens: 19,
|
|
1285
1293
|
updatedAt: now,
|
|
1286
1294
|
lastLimitedLogAt: 0
|
|
1287
1295
|
});
|
|
@@ -1457,7 +1465,7 @@ async function authorizeSlashInvocation(params) {
|
|
|
1457
1465
|
*/
|
|
1458
1466
|
function createSlashCommandHttpHandler(params) {
|
|
1459
1467
|
const { account, cfg, runtime, registeredCommands, triggerMap, log, bodyTimeoutMs } = params;
|
|
1460
|
-
return async (req, res) => {
|
|
1468
|
+
return async (req, res, bufferedBody) => {
|
|
1461
1469
|
if (req.method !== "POST") {
|
|
1462
1470
|
res.statusCode = 405;
|
|
1463
1471
|
res.setHeader("Allow", "POST");
|
|
@@ -1466,15 +1474,13 @@ function createSlashCommandHttpHandler(params) {
|
|
|
1466
1474
|
}
|
|
1467
1475
|
let body;
|
|
1468
1476
|
try {
|
|
1469
|
-
body = await readBody(req, MAX_BODY_BYTES, bodyTimeoutMs);
|
|
1477
|
+
body = bufferedBody ?? await readBody(req, MAX_BODY_BYTES, bodyTimeoutMs);
|
|
1470
1478
|
} catch (error) {
|
|
1471
1479
|
if (isRequestBodyLimitError(error, "REQUEST_BODY_TIMEOUT")) {
|
|
1472
|
-
res
|
|
1473
|
-
res.end("Request body timeout");
|
|
1480
|
+
await sendHttpRequestRejection(req, res, 408, "Request body timeout");
|
|
1474
1481
|
return;
|
|
1475
1482
|
}
|
|
1476
|
-
res
|
|
1477
|
-
res.end("Payload Too Large");
|
|
1483
|
+
await sendHttpRequestRejection(req, res, 413, "Payload Too Large");
|
|
1478
1484
|
return;
|
|
1479
1485
|
}
|
|
1480
1486
|
const contentType = req.headers["content-type"] ?? "";
|
|
@@ -1590,7 +1596,7 @@ async function handleSlashCommandAsync(params) {
|
|
|
1590
1596
|
const to = kind === "direct" ? `user:${senderId}` : `channel:${channelId}`;
|
|
1591
1597
|
const pickerEntry = resolveMattermostModelPickerEntry(commandText);
|
|
1592
1598
|
if (pickerEntry) {
|
|
1593
|
-
const data = await
|
|
1599
|
+
const data = await buildPreparedModelsProviderData(cfg, route.agentId);
|
|
1594
1600
|
if (data.providers.length === 0) {
|
|
1595
1601
|
await sendMessageMattermost(`channel:${channelId}`, "No models available.", {
|
|
1596
1602
|
cfg,
|
|
@@ -1708,7 +1714,7 @@ async function handleSlashCommandAsync(params) {
|
|
|
1708
1714
|
}
|
|
1709
1715
|
//#endregion
|
|
1710
1716
|
//#region extensions/mattermost/src/mattermost/slash-state.ts
|
|
1711
|
-
const MULTI_ACCOUNT_BODY_MAX_BYTES =
|
|
1717
|
+
const MULTI_ACCOUNT_BODY_MAX_BYTES = 65536;
|
|
1712
1718
|
const MULTI_ACCOUNT_BODY_TIMEOUT_MS = 5e3;
|
|
1713
1719
|
/**
|
|
1714
1720
|
* Map from accountId → per-account slash command state.
|
|
@@ -1886,16 +1892,15 @@ function registerSlashCommandRoute(api) {
|
|
|
1886
1892
|
try {
|
|
1887
1893
|
bodyStr = await readRequestBodyWithLimit(req, {
|
|
1888
1894
|
maxBytes: MULTI_ACCOUNT_BODY_MAX_BYTES,
|
|
1889
|
-
timeoutMs: MULTI_ACCOUNT_BODY_TIMEOUT_MS
|
|
1895
|
+
timeoutMs: MULTI_ACCOUNT_BODY_TIMEOUT_MS,
|
|
1896
|
+
destroyOnLimit: false
|
|
1890
1897
|
});
|
|
1891
1898
|
} catch (error) {
|
|
1892
1899
|
if (isRequestBodyLimitError(error, "REQUEST_BODY_TIMEOUT")) {
|
|
1893
|
-
res
|
|
1894
|
-
res.end("Request body timeout");
|
|
1900
|
+
await sendHttpRequestRejection(req, res, 408, "Request body timeout");
|
|
1895
1901
|
return;
|
|
1896
1902
|
}
|
|
1897
|
-
res
|
|
1898
|
-
res.end("Payload Too Large");
|
|
1903
|
+
await sendHttpRequestRejection(req, res, 413, "Payload Too Large");
|
|
1899
1904
|
return;
|
|
1900
1905
|
}
|
|
1901
1906
|
let token = null;
|
|
@@ -1932,15 +1937,7 @@ function registerSlashCommandRoute(api) {
|
|
|
1932
1937
|
}));
|
|
1933
1938
|
return;
|
|
1934
1939
|
}
|
|
1935
|
-
|
|
1936
|
-
const syntheticReq = new Readable({ read() {
|
|
1937
|
-
this.push(Buffer.from(bodyStr, "utf8"));
|
|
1938
|
-
this.push(null);
|
|
1939
|
-
} });
|
|
1940
|
-
syntheticReq.method = req.method;
|
|
1941
|
-
syntheticReq.url = req.url;
|
|
1942
|
-
syntheticReq.headers = req.headers;
|
|
1943
|
-
await matchedHandler(syntheticReq, res);
|
|
1940
|
+
await match.handler(req, res, bodyStr);
|
|
1944
1941
|
};
|
|
1945
1942
|
for (const callbackPath of callbackPaths) api.registerHttpRoute({
|
|
1946
1943
|
path: callbackPath,
|
package/openclaw.plugin.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"id": "mattermost",
|
|
3
|
+
"name": "Mattermost",
|
|
4
|
+
"description": "OpenClaw Mattermost channel plugin.",
|
|
3
5
|
"doctorContract": {
|
|
4
6
|
"configRepair": true
|
|
5
7
|
},
|
|
6
|
-
"icon": "https://cdn.simpleicons.org/mattermost",
|
|
7
8
|
"activation": {
|
|
8
9
|
"onStartup": false
|
|
9
10
|
},
|
|
@@ -54,11 +55,23 @@
|
|
|
54
55
|
"configWrites": {
|
|
55
56
|
"type": "boolean"
|
|
56
57
|
},
|
|
58
|
+
"contextVisibility": {
|
|
59
|
+
"type": "string",
|
|
60
|
+
"enum": [
|
|
61
|
+
"all",
|
|
62
|
+
"allowlist",
|
|
63
|
+
"allowlist_quote"
|
|
64
|
+
]
|
|
65
|
+
},
|
|
57
66
|
"historyLimit": {
|
|
58
67
|
"type": "integer",
|
|
59
68
|
"minimum": 0,
|
|
60
69
|
"maximum": 9007199254740991
|
|
61
70
|
},
|
|
71
|
+
"mediaMaxMb": {
|
|
72
|
+
"type": "number",
|
|
73
|
+
"exclusiveMinimum": 0
|
|
74
|
+
},
|
|
62
75
|
"botToken": {
|
|
63
76
|
"anyOf": [
|
|
64
77
|
{
|
|
@@ -553,11 +566,23 @@
|
|
|
553
566
|
"configWrites": {
|
|
554
567
|
"type": "boolean"
|
|
555
568
|
},
|
|
569
|
+
"contextVisibility": {
|
|
570
|
+
"type": "string",
|
|
571
|
+
"enum": [
|
|
572
|
+
"all",
|
|
573
|
+
"allowlist",
|
|
574
|
+
"allowlist_quote"
|
|
575
|
+
]
|
|
576
|
+
},
|
|
556
577
|
"historyLimit": {
|
|
557
578
|
"type": "integer",
|
|
558
579
|
"minimum": 0,
|
|
559
580
|
"maximum": 9007199254740991
|
|
560
581
|
},
|
|
582
|
+
"mediaMaxMb": {
|
|
583
|
+
"type": "number",
|
|
584
|
+
"exclusiveMinimum": 0
|
|
585
|
+
},
|
|
561
586
|
"botToken": {
|
|
562
587
|
"anyOf": [
|
|
563
588
|
{
|
|
@@ -1098,7 +1123,7 @@
|
|
|
1098
1123
|
},
|
|
1099
1124
|
"streaming.progress.toolProgress": {
|
|
1100
1125
|
"label": "Mattermost Progress Tool Lines",
|
|
1101
|
-
"help": "Show
|
|
1126
|
+
"help": "Show individual tool activity in progress drafts (default: false). Quiet drafts retain plans, approval requests, failures, and authored progress text."
|
|
1102
1127
|
},
|
|
1103
1128
|
"streaming.progress.commandText": {
|
|
1104
1129
|
"label": "Mattermost Progress Command Text",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openclaw/mattermost",
|
|
3
|
-
"version": "2026.9.
|
|
3
|
+
"version": "2026.9.2",
|
|
4
4
|
"description": "OpenClaw Mattermost channel plugin",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"zod": "4.4.3"
|
|
13
13
|
},
|
|
14
14
|
"peerDependencies": {
|
|
15
|
-
"openclaw": ">=2026.9.
|
|
15
|
+
"openclaw": ">=2026.9.2"
|
|
16
16
|
},
|
|
17
17
|
"peerDependenciesMeta": {
|
|
18
18
|
"openclaw": {
|
|
@@ -91,10 +91,10 @@
|
|
|
91
91
|
"allowInvalidConfigRecovery": true
|
|
92
92
|
},
|
|
93
93
|
"compat": {
|
|
94
|
-
"pluginApi": ">=2026.9.
|
|
94
|
+
"pluginApi": ">=2026.9.2"
|
|
95
95
|
},
|
|
96
96
|
"build": {
|
|
97
|
-
"openclawVersion": "2026.9.
|
|
97
|
+
"openclawVersion": "2026.9.2",
|
|
98
98
|
"bundledDist": false
|
|
99
99
|
},
|
|
100
100
|
"release": {
|