@openclaw/mattermost 2026.8.1-beta.3 → 2026.8.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 +2 -1
- package/dist/{channel-plugin-runtime-C_mWt_83.js → channel-plugin-runtime-iEa9Cv5W.js} +188 -209
- package/dist/channel-plugin-runtime.js +1 -1
- package/dist/{channel.runtime-CpQzh8-1.js → channel.runtime-tEMiKAyb.js} +112 -86
- package/dist/{client-B_hd-kwM.js → client-D3Btt1WT.js} +8 -19
- package/dist/ingress-identity-DNl4yQSc.js +27 -0
- package/dist/{interactions-Du_EJMeN.js → interactions-DN1Dzzc_.js} +9 -7
- package/dist/{monitor-auth-CVd_4FPD.js → monitor-auth-DvyW7bpd.js} +10 -30
- package/dist/{accounts-DspH-NMT.js → normalize-BtFTWPoG.js} +77 -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-BakgoSSL.js → slash-state-02qPUgGO.js} +66 -113
- package/node_modules/ws/lib/permessage-deflate.js +3 -1
- package/node_modules/ws/package.json +1 -1
- package/openclaw.plugin.json +34 -0
- package/package.json +5 -5
|
@@ -1,46 +1,25 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { n as normalizeMattermostAllowEntry, t as mattermostIngressIdentity } from "./ingress-identity-DNl4yQSc.js";
|
|
2
|
+
import { uniqueStrings } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
3
3
|
import { logInboundDrop } from "openclaw/plugin-sdk/channel-inbound";
|
|
4
4
|
import { resolveAllowlistMatchSimple } from "openclaw/plugin-sdk/allow-from";
|
|
5
5
|
import { createChannelPairingController } from "openclaw/plugin-sdk/channel-pairing";
|
|
6
6
|
import { createChannelMessageReplyPipeline } from "openclaw/plugin-sdk/channel-outbound";
|
|
7
7
|
import { logTypingFailure } from "openclaw/plugin-sdk/channel-feedback";
|
|
8
8
|
import { listSkillCommandsForAgents } from "openclaw/plugin-sdk/command-auth-native";
|
|
9
|
-
import {
|
|
9
|
+
import { buildPreparedModelsProviderData } from "openclaw/plugin-sdk/models-provider-runtime";
|
|
10
10
|
import { isDangerousNameMatchingEnabled } from "openclaw/plugin-sdk/dangerous-name-runtime";
|
|
11
11
|
import { resolveAllowlistProviderRuntimeGroupPolicy as resolveAllowlistProviderRuntimeGroupPolicy$1, resolveDefaultGroupPolicy, warnMissingProviderGroupPolicyFallbackOnce } from "openclaw/plugin-sdk/runtime-group-policy";
|
|
12
|
-
import { resolveChannelMediaMaxBytes } from "openclaw/plugin-sdk/
|
|
12
|
+
import { resolveChannelMediaMaxBytes as resolveChannelMediaMaxBytes$1 } from "openclaw/plugin-sdk/account-helpers";
|
|
13
13
|
import { loadOutboundMediaFromUrl } from "openclaw/plugin-sdk/outbound-media";
|
|
14
14
|
import { DEFAULT_GROUP_HISTORY_LIMIT, createChannelHistoryWindow } from "openclaw/plugin-sdk/reply-history";
|
|
15
15
|
import { registerPluginHttpRoute } from "openclaw/plugin-sdk/webhook-targets";
|
|
16
16
|
import { isRequestBodyLimitError, readRequestBodyWithLimit } from "openclaw/plugin-sdk/webhook-ingress";
|
|
17
|
-
import {
|
|
17
|
+
import { isTrustedProxyAddress, resolveClientIp } from "openclaw/plugin-sdk/core";
|
|
18
18
|
import { resolveStableChannelMessageIngress } from "openclaw/plugin-sdk/channel-ingress-runtime";
|
|
19
19
|
//#region extensions/mattermost/src/mattermost/monitor-auth.ts
|
|
20
|
-
const mattermostIngressIdentity = {
|
|
21
|
-
key: "sender-id",
|
|
22
|
-
normalize: normalizeMattermostAllowEntry,
|
|
23
|
-
aliases: [{
|
|
24
|
-
key: "sender-name",
|
|
25
|
-
kind: "plugin:mattermost-user-name",
|
|
26
|
-
normalizeEntry: normalizeMattermostAllowEntry,
|
|
27
|
-
normalizeSubject: normalizeMattermostAllowEntry,
|
|
28
|
-
dangerous: true
|
|
29
|
-
}],
|
|
30
|
-
isWildcardEntry: (entry) => normalizeMattermostAllowEntry(entry) === "*",
|
|
31
|
-
resolveEntryId: ({ entryIndex, fieldKey }) => `mattermost-entry-${entryIndex + 1}:${fieldKey === "sender-name" ? "name" : "user"}`
|
|
32
|
-
};
|
|
33
|
-
function normalizeMattermostAllowEntry(entry) {
|
|
34
|
-
const trimmed = entry.trim();
|
|
35
|
-
if (!trimmed) return "";
|
|
36
|
-
if (trimmed === "*") return "*";
|
|
37
|
-
const accessGroupName = parseAccessGroupAllowFromEntry(trimmed);
|
|
38
|
-
if (accessGroupName) return `accessGroup:${accessGroupName}`;
|
|
39
|
-
const normalized = trimmed.replace(/^(mattermost|user):/i, "").replace(/^@/, "").trim();
|
|
40
|
-
return normalized ? normalizeLowercaseStringOrEmpty(normalized) : "";
|
|
41
|
-
}
|
|
42
20
|
function normalizeMattermostAllowList(entries) {
|
|
43
|
-
|
|
21
|
+
const normalized = entries.map((entry) => normalizeMattermostAllowEntry(String(entry))).filter(Boolean);
|
|
22
|
+
return uniqueStrings(normalized);
|
|
44
23
|
}
|
|
45
24
|
function formatMattermostDirectMessageDropLog(params) {
|
|
46
25
|
const reason = params.reasonCode ? ` reason=${params.reasonCode}` : "";
|
|
@@ -48,8 +27,9 @@ function formatMattermostDirectMessageDropLog(params) {
|
|
|
48
27
|
return `mattermost: drop dm sender=${params.senderId} (dmPolicy=${params.dmPolicy}${reason}${hint})`;
|
|
49
28
|
}
|
|
50
29
|
function isMattermostSenderAllowed(params) {
|
|
30
|
+
const allowFrom = normalizeMattermostAllowList(params.allowFrom);
|
|
51
31
|
return resolveAllowlistMatchSimple({
|
|
52
|
-
allowFrom
|
|
32
|
+
allowFrom,
|
|
53
33
|
senderId: normalizeMattermostAllowEntry(params.senderId),
|
|
54
34
|
senderName: params.senderName ? normalizeMattermostAllowEntry(params.senderName) : void 0,
|
|
55
35
|
allowNameMatching: params.allowNameMatching
|
|
@@ -181,4 +161,4 @@ async function authorizeMattermostCommandInvocation(params) {
|
|
|
181
161
|
};
|
|
182
162
|
}
|
|
183
163
|
//#endregion
|
|
184
|
-
export {
|
|
164
|
+
export { resolveDefaultGroupPolicy as C, resolveClientIp as S, logTypingFailure as _, resolveMattermostMonitorInboundAccess as a, resolveAllowlistProviderRuntimeGroupPolicy$1 as b, buildPreparedModelsProviderData as c, createChannelPairingController as d, isRequestBodyLimitError as f, logInboundDrop as g, loadOutboundMediaFromUrl as h, normalizeMattermostAllowList as i, createChannelHistoryWindow as l, listSkillCommandsForAgents as m, formatMattermostDirectMessageDropLog as n, resolveMattermostTrustedChatKind as o, isTrustedProxyAddress as p, isMattermostSenderAllowed as r, DEFAULT_GROUP_HISTORY_LIMIT as s, authorizeMattermostCommandInvocation as t, createChannelMessageReplyPipeline as u, readRequestBodyWithLimit as v, warnMissingProviderGroupPolicyFallbackOnce as w, resolveChannelMediaMaxBytes$1 as x, registerPluginHttpRoute as y };
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { m as normalizeMattermostBaseUrl } from "./client-
|
|
2
|
-
import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
1
|
+
import { m as normalizeMattermostBaseUrl } from "./client-D3Btt1WT.js";
|
|
2
|
+
import { normalizeLowercaseStringOrEmpty, normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
3
3
|
import { resolveChannelPreviewStreamMode, resolveChannelStreamingBlockCoalesce, resolveChannelStreamingBlockEnabled, resolveChannelStreamingChunkMode } from "openclaw/plugin-sdk/channel-outbound";
|
|
4
4
|
import { createAccountListHelpers, hasConfiguredAccountValue } from "openclaw/plugin-sdk/account-helpers";
|
|
5
|
+
import { normalizeMessagePresentation, renderMessagePresentationFallbackText, resolveMessagePresentationControlValue } from "openclaw/plugin-sdk/interactive-runtime";
|
|
5
6
|
import { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "openclaw/plugin-sdk/account-id";
|
|
6
7
|
import { buildSecretInputSchema, hasConfiguredSecretInput, resolveSecretInputString } from "openclaw/plugin-sdk/secret-input";
|
|
7
8
|
//#region extensions/mattermost/src/mattermost/accounts.ts
|
|
@@ -67,10 +68,18 @@ function resolveMattermostAccount(params) {
|
|
|
67
68
|
});
|
|
68
69
|
}
|
|
69
70
|
function inspectMattermostAccount(params) {
|
|
70
|
-
|
|
71
|
+
const account = resolveMattermostAccountWithMode({
|
|
71
72
|
...params,
|
|
72
73
|
mode: "inspect"
|
|
73
74
|
});
|
|
75
|
+
return {
|
|
76
|
+
...account,
|
|
77
|
+
configured: isMattermostConfigured(account),
|
|
78
|
+
dmPolicy: account.config.dmPolicy ?? "pairing"
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
function isMattermostConfigured(account) {
|
|
82
|
+
return (account.botTokenStatus ? account.botTokenStatus !== "missing" : Boolean(account.botToken)) && Boolean(account.baseUrl);
|
|
74
83
|
}
|
|
75
84
|
/**
|
|
76
85
|
* Resolve the effective replyToMode for a given chat type.
|
|
@@ -83,4 +92,68 @@ function resolveMattermostReplyToMode(account, kind) {
|
|
|
83
92
|
return account.config.replyToMode ?? "off";
|
|
84
93
|
}
|
|
85
94
|
//#endregion
|
|
86
|
-
|
|
95
|
+
//#region extensions/mattermost/src/normalize.ts
|
|
96
|
+
function resolveMattermostPresentation(params) {
|
|
97
|
+
const presentation = normalizeMessagePresentation(params.presentation);
|
|
98
|
+
return {
|
|
99
|
+
text: !presentation || params.presentationTextMode === "fallback" && params.text !== void 0 ? params.text ?? "" : renderMessagePresentationFallbackText({
|
|
100
|
+
text: params.text,
|
|
101
|
+
presentation
|
|
102
|
+
}),
|
|
103
|
+
buttons: presentation ? presentation.blocks.filter((block) => block.type === "buttons").map((block) => block.buttons.flatMap((button) => {
|
|
104
|
+
if (button.action) return [];
|
|
105
|
+
const value = resolveMessagePresentationControlValue(button);
|
|
106
|
+
return value ? [{
|
|
107
|
+
id: value,
|
|
108
|
+
text: button.label,
|
|
109
|
+
callback_data: value,
|
|
110
|
+
context: { callback_data: value },
|
|
111
|
+
style: button.style
|
|
112
|
+
}] : [];
|
|
113
|
+
})).filter((row) => row.length > 0) : []
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
function normalizeMattermostMessagingTarget(raw) {
|
|
117
|
+
const trimmed = raw.trim();
|
|
118
|
+
if (!trimmed) return;
|
|
119
|
+
const lower = normalizeLowercaseStringOrEmpty(trimmed);
|
|
120
|
+
if (lower.startsWith("channel:")) {
|
|
121
|
+
const id = trimmed.slice(8).trim();
|
|
122
|
+
return id ? `channel:${id}` : void 0;
|
|
123
|
+
}
|
|
124
|
+
if (lower.startsWith("group:")) {
|
|
125
|
+
const id = trimmed.slice(6).trim();
|
|
126
|
+
return id ? `channel:${id}` : void 0;
|
|
127
|
+
}
|
|
128
|
+
if (lower.startsWith("user:")) {
|
|
129
|
+
const id = trimmed.slice(5).trim();
|
|
130
|
+
return id ? `user:${id}` : void 0;
|
|
131
|
+
}
|
|
132
|
+
if (lower.startsWith("mattermost:")) {
|
|
133
|
+
const id = trimmed.slice(11).trim();
|
|
134
|
+
return id ? `user:${id}` : void 0;
|
|
135
|
+
}
|
|
136
|
+
if (trimmed.startsWith("@")) {
|
|
137
|
+
const id = trimmed.slice(1).trim();
|
|
138
|
+
return id ? `@${id}` : void 0;
|
|
139
|
+
}
|
|
140
|
+
if (trimmed.startsWith("#")) return;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* True when media must be uploaded as a file: any non-empty, non-http(s) value
|
|
144
|
+
* (e.g. a local workspace path) has no address the server can fetch, so the
|
|
145
|
+
* send must require a successful upload rather than degrade to caption text.
|
|
146
|
+
*/
|
|
147
|
+
function requiresMattermostMediaUpload(mediaUrl) {
|
|
148
|
+
const trimmed = mediaUrl?.trim();
|
|
149
|
+
return Boolean(trimmed && !/^https?:\/\//i.test(trimmed));
|
|
150
|
+
}
|
|
151
|
+
function looksLikeMattermostTargetId(raw, _normalized) {
|
|
152
|
+
const trimmed = raw.trim();
|
|
153
|
+
if (!trimmed) return false;
|
|
154
|
+
if (/^(user|channel|group|mattermost):/i.test(trimmed)) return true;
|
|
155
|
+
if (trimmed.startsWith("@")) return true;
|
|
156
|
+
return /^[a-z0-9]{26}$/i.test(trimmed) || /^[a-z0-9]{26}__[a-z0-9]{26}$/i.test(trimmed);
|
|
157
|
+
}
|
|
158
|
+
//#endregion
|
|
159
|
+
export { inspectMattermostAccount as a, resolveDefaultMattermostAccountId as c, buildSecretInputSchema as d, hasConfiguredSecretInput as f, resolveMattermostPresentation as i, resolveMattermostAccount as l, normalizeMattermostMessagingTarget as n, isMattermostConfigured as o, requiresMattermostMediaUpload as r, listMattermostAccountIds as s, looksLikeMattermostTargetId as t, resolveMattermostReplyToMode as u };
|
package/dist/policy-api.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { r as isMattermostSenderAllowed } from "./monitor-auth-
|
|
1
|
+
import { r as isMattermostSenderAllowed } from "./monitor-auth-DvyW7bpd.js";
|
|
2
2
|
export { isMattermostSenderAllowed };
|
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-02qPUgGO.js";
|
|
2
2
|
export { registerSlashCommandRoute };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { t as getMattermostRuntime } from "./runtime-CNB4YGqJ.js";
|
|
2
|
-
import { _ as
|
|
3
|
-
import {
|
|
4
|
-
import { c as setInteractionSecret, n as buildButtonProps, o as resolveInteractionCallbackUrl } from "./interactions-
|
|
5
|
-
import { i as resolveMattermostAccount } from "./
|
|
2
|
+
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-D3Btt1WT.js";
|
|
3
|
+
import { _ as logTypingFailure, c as buildPreparedModelsProviderData, f as isRequestBodyLimitError, h as loadOutboundMediaFromUrl, i as normalizeMattermostAllowList, o as resolveMattermostTrustedChatKind, t as authorizeMattermostCommandInvocation, v as readRequestBodyWithLimit } from "./monitor-auth-DvyW7bpd.js";
|
|
4
|
+
import { c as setInteractionSecret, n as buildButtonProps, o as resolveInteractionCallbackUrl } from "./interactions-DN1Dzzc_.js";
|
|
5
|
+
import { i as resolveMattermostPresentation, l as resolveMattermostAccount, r as requiresMattermostMediaUpload } from "./normalize-BtFTWPoG.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";
|
|
@@ -613,42 +613,6 @@ function renderMattermostModelsPickerView(params) {
|
|
|
613
613
|
}
|
|
614
614
|
//#endregion
|
|
615
615
|
//#region extensions/mattermost/src/mattermost/reply-delivery.ts
|
|
616
|
-
function createMattermostReplyDeliveryBarrier(params) {
|
|
617
|
-
let activeDmChannelResolutions = 0;
|
|
618
|
-
let queuedDeliveryCount = 0;
|
|
619
|
-
let settledDeliveryCount = 0;
|
|
620
|
-
const trackDmChannelResolution = (resolution) => {
|
|
621
|
-
activeDmChannelResolutions += 1;
|
|
622
|
-
Promise.resolve(resolution).then(() => {
|
|
623
|
-
activeDmChannelResolutions -= 1;
|
|
624
|
-
}, () => {
|
|
625
|
-
activeDmChannelResolutions -= 1;
|
|
626
|
-
});
|
|
627
|
-
};
|
|
628
|
-
const markDeliverySettled = () => {
|
|
629
|
-
settledDeliveryCount += 1;
|
|
630
|
-
};
|
|
631
|
-
const resolveTimeoutPolicy = (context) => {
|
|
632
|
-
const { queuedCounts } = context;
|
|
633
|
-
queuedDeliveryCount = Object.values(queuedCounts).reduce((sum, count) => sum + count, 0);
|
|
634
|
-
const maxTimeoutMs = resolveMattermostReplyDeliveryBarrierTimeoutMs({
|
|
635
|
-
isDirect: params.isDirect,
|
|
636
|
-
dmRetryOptions: params.dmRetryOptions,
|
|
637
|
-
queuedCounts,
|
|
638
|
-
humanDelayBudgetMs: context.humanDelayBudgetMs
|
|
639
|
-
});
|
|
640
|
-
if (maxTimeoutMs === void 0) return;
|
|
641
|
-
return {
|
|
642
|
-
maxTimeoutMs,
|
|
643
|
-
shouldExtend: () => activeDmChannelResolutions > 0 || settledDeliveryCount < queuedDeliveryCount
|
|
644
|
-
};
|
|
645
|
-
};
|
|
646
|
-
return {
|
|
647
|
-
trackDmChannelResolution,
|
|
648
|
-
markDeliverySettled,
|
|
649
|
-
resolveTimeoutPolicy
|
|
650
|
-
};
|
|
651
|
-
}
|
|
652
616
|
/** Represents distinct provider posts without collapsing their visible boundary. */
|
|
653
617
|
function joinMattermostVisibleContent(contents) {
|
|
654
618
|
return contents.filter((content) => Boolean(content)).join("\n");
|
|
@@ -659,39 +623,35 @@ async function deliverMattermostReplyPayload(params) {
|
|
|
659
623
|
visibleReplySent: false,
|
|
660
624
|
suppression: { reason: "no_visible_result" }
|
|
661
625
|
};
|
|
662
|
-
const
|
|
626
|
+
const presentation = resolveMattermostPresentation(params.payload);
|
|
627
|
+
const reply = resolveSendableOutboundReplyParts(params.payload, { text: params.core.channel.text.convertMarkdownTables(presentation.text, params.tableMode) });
|
|
663
628
|
const mediaLocalRoots = getAgentScopedMediaLocalRoots(params.cfg, params.agentId);
|
|
664
629
|
const chunkMode = params.core.channel.text.resolveChunkMode(params.cfg, "mattermost", params.accountId);
|
|
665
630
|
const results = [];
|
|
666
631
|
const acceptedContents = [];
|
|
632
|
+
const sendAccepted = async (text, mediaUrl) => {
|
|
633
|
+
const result = await params.sendMessage(`channel:${params.channelId}`, text, {
|
|
634
|
+
cfg: params.cfg,
|
|
635
|
+
accountId: params.accountId,
|
|
636
|
+
...mediaUrl ? {
|
|
637
|
+
mediaUrl,
|
|
638
|
+
mediaLocalRoots
|
|
639
|
+
} : {},
|
|
640
|
+
...requiresMattermostMediaUpload(mediaUrl) ? { requireMediaUpload: true } : {},
|
|
641
|
+
...results.length === 0 && reply.mediaUrls.length < 2 && presentation.buttons.length ? { buttons: presentation.buttons } : {},
|
|
642
|
+
replyToId: params.replyToId
|
|
643
|
+
});
|
|
644
|
+
results.push(result);
|
|
645
|
+
acceptedContents.push(result.content);
|
|
646
|
+
};
|
|
667
647
|
let outcome;
|
|
668
648
|
try {
|
|
669
649
|
outcome = await deliverTextOrMediaReply({
|
|
670
650
|
payload: params.payload,
|
|
671
651
|
text: reply.text,
|
|
672
652
|
chunkText: (value) => params.core.channel.text.chunkMarkdownTextWithMode(value, params.textLimit, chunkMode),
|
|
673
|
-
sendText:
|
|
674
|
-
|
|
675
|
-
cfg: params.cfg,
|
|
676
|
-
accountId: params.accountId,
|
|
677
|
-
replyToId: params.replyToId,
|
|
678
|
-
...params.onDmChannelResolution ? { onDmChannelResolution: params.onDmChannelResolution } : {}
|
|
679
|
-
});
|
|
680
|
-
results.push(result);
|
|
681
|
-
acceptedContents.push(result.content);
|
|
682
|
-
},
|
|
683
|
-
sendMedia: async ({ mediaUrl, caption }) => {
|
|
684
|
-
const result = await params.sendMessage(params.to, caption ?? "", {
|
|
685
|
-
cfg: params.cfg,
|
|
686
|
-
accountId: params.accountId,
|
|
687
|
-
mediaUrl,
|
|
688
|
-
mediaLocalRoots,
|
|
689
|
-
replyToId: params.replyToId,
|
|
690
|
-
...params.onDmChannelResolution ? { onDmChannelResolution: params.onDmChannelResolution } : {}
|
|
691
|
-
});
|
|
692
|
-
results.push(result);
|
|
693
|
-
acceptedContents.push(result.content);
|
|
694
|
-
}
|
|
653
|
+
sendText: sendAccepted,
|
|
654
|
+
sendMedia: ({ mediaUrl, caption }) => sendAccepted(caption ?? "", mediaUrl)
|
|
695
655
|
});
|
|
696
656
|
} catch (error) {
|
|
697
657
|
const failedPartial = isChannelPartialDeliveryError(error) ? error.deliveryResult : void 0;
|
|
@@ -729,7 +689,7 @@ async function deliverMattermostReplyPayload(params) {
|
|
|
729
689
|
//#endregion
|
|
730
690
|
//#region extensions/mattermost/src/mattermost/target-resolution.ts
|
|
731
691
|
const MATTERMOST_OPAQUE_TARGET_CACHE_MAX_ENTRIES = 1024;
|
|
732
|
-
const MATTERMOST_OPAQUE_TARGET_CACHE_TTL_MS =
|
|
692
|
+
const MATTERMOST_OPAQUE_TARGET_CACHE_TTL_MS = 3e5;
|
|
733
693
|
const mattermostOpaqueTargetCache = /* @__PURE__ */ new Map();
|
|
734
694
|
function cacheMattermostOpaqueTarget(key, kind) {
|
|
735
695
|
mattermostOpaqueTargetCache.set(key, {
|
|
@@ -863,7 +823,8 @@ async function resolveMattermostOpaqueTarget(params) {
|
|
|
863
823
|
};
|
|
864
824
|
}
|
|
865
825
|
try {
|
|
866
|
-
const
|
|
826
|
+
const channel = await fetchMattermostChannel(client, input);
|
|
827
|
+
const channelKind = resolveMattermostTrustedChatKind({ channelType: channel.type }) === "group" ? "group" : "channel";
|
|
867
828
|
cacheMattermostOpaqueTarget(key, channelKind);
|
|
868
829
|
return {
|
|
869
830
|
kind: channelKind,
|
|
@@ -942,11 +903,12 @@ async function resolveBotUser(baseUrl, token, allowPrivateNetwork) {
|
|
|
942
903
|
const key = cacheKey(baseUrl, token);
|
|
943
904
|
const cached = botUserCache.get(key);
|
|
944
905
|
if (cached) return cached;
|
|
945
|
-
const
|
|
906
|
+
const client = createMattermostClient({
|
|
946
907
|
baseUrl,
|
|
947
908
|
botToken: token,
|
|
948
909
|
allowPrivateNetwork
|
|
949
|
-
})
|
|
910
|
+
});
|
|
911
|
+
const user = await fetchMattermostMe(client);
|
|
950
912
|
cacheOutboundEntry(botUserCache, key, user, MATTERMOST_BOT_USER_CACHE_MAX_ENTRIES);
|
|
951
913
|
return user;
|
|
952
914
|
}
|
|
@@ -955,11 +917,12 @@ async function resolveUserIdByUsername(params) {
|
|
|
955
917
|
const key = `${cacheKey(baseUrl, token)}::${normalizeLowercaseStringOrEmpty(username)}`;
|
|
956
918
|
const cached = userByNameCache.get(key);
|
|
957
919
|
if (cached?.id) return cached.id;
|
|
958
|
-
const
|
|
920
|
+
const client = createMattermostClient({
|
|
959
921
|
baseUrl,
|
|
960
922
|
botToken: token,
|
|
961
923
|
allowPrivateNetwork: params.allowPrivateNetwork
|
|
962
|
-
})
|
|
924
|
+
});
|
|
925
|
+
const user = await fetchMattermostUserByUsername(client, username);
|
|
963
926
|
cacheOutboundEntry(userByNameCache, key, user, MATTERMOST_TARGET_CACHE_MAX_ENTRIES);
|
|
964
927
|
return user.id;
|
|
965
928
|
}
|
|
@@ -973,7 +936,8 @@ async function resolveChannelIdByName(params) {
|
|
|
973
936
|
botToken: token,
|
|
974
937
|
allowPrivateNetwork: params.allowPrivateNetwork
|
|
975
938
|
});
|
|
976
|
-
const
|
|
939
|
+
const me = await fetchMattermostMe(client);
|
|
940
|
+
const teams = await fetchMattermostUserTeams(client, me.id);
|
|
977
941
|
for (const team of teams) try {
|
|
978
942
|
const channel = await fetchMattermostChannelByName(client, team.id, name);
|
|
979
943
|
if (channel?.id) {
|
|
@@ -1014,19 +978,18 @@ async function resolveTargetChannelId(params) {
|
|
|
1014
978
|
const cachedDm = dmChannelCache.get(dmKey);
|
|
1015
979
|
if (cachedDm) return cachedDm;
|
|
1016
980
|
const botUser = await resolveBotUser(params.baseUrl, params.token, params.allowPrivateNetwork);
|
|
1017
|
-
const
|
|
981
|
+
const client = createMattermostClient({
|
|
1018
982
|
baseUrl: params.baseUrl,
|
|
1019
983
|
botToken: params.token,
|
|
1020
984
|
allowPrivateNetwork: params.allowPrivateNetwork
|
|
1021
|
-
})
|
|
985
|
+
});
|
|
986
|
+
const channel = await createMattermostDirectChannelWithRetry(client, [botUser.id, userId], {
|
|
1022
987
|
...params.dmRetryOptions,
|
|
1023
988
|
onRetry: (attempt, delayMs, error) => {
|
|
1024
989
|
params.dmRetryOptions?.onRetry?.(attempt, delayMs, error);
|
|
1025
990
|
if (params.logger) params.logger.warn?.(`DM channel creation retry ${attempt} after ${delayMs}ms: ${error.message}`);
|
|
1026
991
|
}
|
|
1027
992
|
});
|
|
1028
|
-
params.onDmChannelResolution?.(resolution);
|
|
1029
|
-
const channel = await resolution;
|
|
1030
993
|
cacheOutboundEntry(dmChannelCache, dmKey, channel.id, MATTERMOST_TARGET_CACHE_MAX_ENTRIES);
|
|
1031
994
|
return channel.id;
|
|
1032
995
|
}
|
|
@@ -1069,7 +1032,6 @@ async function resolveMattermostSendContext(to, opts) {
|
|
|
1069
1032
|
token,
|
|
1070
1033
|
allowPrivateNetwork,
|
|
1071
1034
|
dmRetryOptions,
|
|
1072
|
-
onDmChannelResolution: opts.onDmChannelResolution,
|
|
1073
1035
|
logger: core.logging.shouldLogVerbose() ? logger : void 0
|
|
1074
1036
|
});
|
|
1075
1037
|
return {
|
|
@@ -1078,13 +1040,18 @@ async function resolveMattermostSendContext(to, opts) {
|
|
|
1078
1040
|
token,
|
|
1079
1041
|
baseUrl,
|
|
1080
1042
|
channelId,
|
|
1081
|
-
allowPrivateNetwork
|
|
1043
|
+
allowPrivateNetwork,
|
|
1044
|
+
mediaMaxBytes: resolveChannelMediaMaxBytes({
|
|
1045
|
+
cfg,
|
|
1046
|
+
accountId: account.accountId,
|
|
1047
|
+
resolveChannelLimitMb: () => account.config.mediaMaxMb
|
|
1048
|
+
})
|
|
1082
1049
|
};
|
|
1083
1050
|
}
|
|
1084
1051
|
async function sendMessageMattermost(to, text, opts) {
|
|
1085
1052
|
const core = getCore();
|
|
1086
1053
|
const logger = core.logging.getChildLogger({ module: "mattermost" });
|
|
1087
|
-
const { cfg, accountId, token, baseUrl, channelId, allowPrivateNetwork } = await resolveMattermostSendContext(to, opts);
|
|
1054
|
+
const { cfg, accountId, token, baseUrl, channelId, allowPrivateNetwork, mediaMaxBytes } = await resolveMattermostSendContext(to, opts);
|
|
1088
1055
|
const client = createMattermostClient({
|
|
1089
1056
|
baseUrl,
|
|
1090
1057
|
botToken: token,
|
|
@@ -1113,6 +1080,7 @@ async function sendMessageMattermost(to, text, opts) {
|
|
|
1113
1080
|
const mediaUrl = opts.mediaUrl?.trim();
|
|
1114
1081
|
if (mediaUrl) try {
|
|
1115
1082
|
const media = await loadOutboundMediaFromUrl(mediaUrl, {
|
|
1083
|
+
maxBytes: mediaMaxBytes,
|
|
1116
1084
|
mediaLocalRoots: opts.mediaLocalRoots,
|
|
1117
1085
|
mediaReadFile: opts.mediaReadFile,
|
|
1118
1086
|
workspaceDir: opts.workspaceDir
|
|
@@ -1125,7 +1093,7 @@ async function sendMessageMattermost(to, text, opts) {
|
|
|
1125
1093
|
})).id];
|
|
1126
1094
|
} catch (err) {
|
|
1127
1095
|
uploadError = err instanceof Error ? err : new Error(String(err));
|
|
1128
|
-
if (opts.requireMediaUpload) throw new Error(`Mattermost media upload failed: ${uploadError.message}`, { cause: err });
|
|
1096
|
+
if (opts.requireMediaUpload || mediaMaxBytes !== void 0) throw new Error(`Mattermost media upload failed: ${uploadError.message}`, { cause: err });
|
|
1129
1097
|
if (core.logging.shouldLogVerbose()) logger.debug?.(`mattermost send: media upload failed, falling back to URL text: ${String(err)}`);
|
|
1130
1098
|
message = normalizeMessage(message, isHttpUrl(mediaUrl) ? mediaUrl : "");
|
|
1131
1099
|
}
|
|
@@ -1180,7 +1148,7 @@ async function sendMessageMattermost(to, text, opts) {
|
|
|
1180
1148
|
}
|
|
1181
1149
|
//#endregion
|
|
1182
1150
|
//#region extensions/mattermost/src/mattermost/slash-http.ts
|
|
1183
|
-
const MAX_BODY_BYTES =
|
|
1151
|
+
const MAX_BODY_BYTES = 65536;
|
|
1184
1152
|
const BODY_READ_TIMEOUT_MS = 5e3;
|
|
1185
1153
|
const COMMAND_LOOKUP_TIMEOUT_MS = 1e3;
|
|
1186
1154
|
const COMMAND_VALIDATION_FAILURE_CACHE_MS = 5e3;
|
|
@@ -1222,7 +1190,7 @@ function isDeletedMattermostCommand(command) {
|
|
|
1222
1190
|
return typeof command.delete_at === "number" && command.delete_at > 0;
|
|
1223
1191
|
}
|
|
1224
1192
|
function sanitizeCommandLookupError(error) {
|
|
1225
|
-
|
|
1193
|
+
const sanitized = (error instanceof Error ? error.message : String(error)).replace(/[\r\n\t]/gu, " ").replace(/https?:\/\/[^\s)\]}]+/giu, (urlText) => {
|
|
1226
1194
|
try {
|
|
1227
1195
|
const url = new URL(urlText);
|
|
1228
1196
|
if (url.username || url.password) {
|
|
@@ -1234,7 +1202,8 @@ function sanitizeCommandLookupError(error) {
|
|
|
1234
1202
|
} catch {
|
|
1235
1203
|
return urlText;
|
|
1236
1204
|
}
|
|
1237
|
-
}).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]")
|
|
1205
|
+
}).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]");
|
|
1206
|
+
return truncateUtf16Safe(sanitized, 300);
|
|
1238
1207
|
}
|
|
1239
1208
|
function sanitizeMattermostLogValue(value) {
|
|
1240
1209
|
return truncateUtf16Safe(value.replace(/[\r\n\t]/gu, " "), 200);
|
|
@@ -1314,7 +1283,8 @@ function sweepCommandValidationLookupRateLimit(now = Date.now()) {
|
|
|
1314
1283
|
}
|
|
1315
1284
|
}
|
|
1316
1285
|
function reserveCommandValidationLookup(params) {
|
|
1317
|
-
const
|
|
1286
|
+
const rawNow = params.now ?? Date.now();
|
|
1287
|
+
const now = asDateTimestampMs(rawNow);
|
|
1318
1288
|
if (now === void 0) {
|
|
1319
1289
|
commandValidationLookupRateLimit.clear();
|
|
1320
1290
|
return { allowed: true };
|
|
@@ -1324,7 +1294,7 @@ function reserveCommandValidationLookup(params) {
|
|
|
1324
1294
|
if (!existing) {
|
|
1325
1295
|
commandValidationLookupRateLimit.set(params.key, {
|
|
1326
1296
|
accountId: params.accountId,
|
|
1327
|
-
tokens:
|
|
1297
|
+
tokens: 19,
|
|
1328
1298
|
updatedAt: now,
|
|
1329
1299
|
lastLimitedLogAt: 0
|
|
1330
1300
|
});
|
|
@@ -1500,7 +1470,7 @@ async function authorizeSlashInvocation(params) {
|
|
|
1500
1470
|
*/
|
|
1501
1471
|
function createSlashCommandHttpHandler(params) {
|
|
1502
1472
|
const { account, cfg, runtime, registeredCommands, triggerMap, log, bodyTimeoutMs } = params;
|
|
1503
|
-
return async (req, res) => {
|
|
1473
|
+
return async (req, res, bufferedBody) => {
|
|
1504
1474
|
if (req.method !== "POST") {
|
|
1505
1475
|
res.statusCode = 405;
|
|
1506
1476
|
res.setHeader("Allow", "POST");
|
|
@@ -1509,7 +1479,7 @@ function createSlashCommandHttpHandler(params) {
|
|
|
1509
1479
|
}
|
|
1510
1480
|
let body;
|
|
1511
1481
|
try {
|
|
1512
|
-
body = await readBody(req, MAX_BODY_BYTES, bodyTimeoutMs);
|
|
1482
|
+
body = bufferedBody ?? await readBody(req, MAX_BODY_BYTES, bodyTimeoutMs);
|
|
1513
1483
|
} catch (error) {
|
|
1514
1484
|
if (isRequestBodyLimitError(error, "REQUEST_BODY_TIMEOUT")) {
|
|
1515
1485
|
res.statusCode = 408;
|
|
@@ -1633,9 +1603,9 @@ async function handleSlashCommandAsync(params) {
|
|
|
1633
1603
|
const to = kind === "direct" ? `user:${senderId}` : `channel:${channelId}`;
|
|
1634
1604
|
const pickerEntry = resolveMattermostModelPickerEntry(commandText);
|
|
1635
1605
|
if (pickerEntry) {
|
|
1636
|
-
const data = await
|
|
1606
|
+
const data = await buildPreparedModelsProviderData(cfg, route.agentId);
|
|
1637
1607
|
if (data.providers.length === 0) {
|
|
1638
|
-
await sendMessageMattermost(
|
|
1608
|
+
await sendMessageMattermost(`channel:${channelId}`, "No models available.", {
|
|
1639
1609
|
cfg,
|
|
1640
1610
|
accountId: account.accountId
|
|
1641
1611
|
});
|
|
@@ -1660,7 +1630,7 @@ async function handleSlashCommandAsync(params) {
|
|
|
1660
1630
|
page: 1,
|
|
1661
1631
|
currentModel
|
|
1662
1632
|
});
|
|
1663
|
-
await sendMessageMattermost(
|
|
1633
|
+
await sendMessageMattermost(`channel:${channelId}`, view.text, {
|
|
1664
1634
|
cfg,
|
|
1665
1635
|
accountId: account.accountId,
|
|
1666
1636
|
buttons: view.buttons
|
|
@@ -1703,10 +1673,6 @@ async function handleSlashCommandAsync(params) {
|
|
|
1703
1673
|
accountId: account.accountId
|
|
1704
1674
|
});
|
|
1705
1675
|
const humanDelay = resolveHumanDelayConfig(cfg, route.agentId);
|
|
1706
|
-
const deliveryBarrier = createMattermostReplyDeliveryBarrier({
|
|
1707
|
-
isDirect: kind === "direct",
|
|
1708
|
-
dmRetryOptions: account.config.dmChannelRetry
|
|
1709
|
-
});
|
|
1710
1676
|
await core.channel.inbound.dispatch({
|
|
1711
1677
|
cfg,
|
|
1712
1678
|
channel: "mattermost",
|
|
@@ -1724,13 +1690,12 @@ async function handleSlashCommandAsync(params) {
|
|
|
1724
1690
|
core,
|
|
1725
1691
|
cfg,
|
|
1726
1692
|
payload,
|
|
1727
|
-
|
|
1693
|
+
channelId,
|
|
1728
1694
|
accountId: account.accountId,
|
|
1729
1695
|
agentId: route.agentId,
|
|
1730
1696
|
textLimit,
|
|
1731
1697
|
tableMode,
|
|
1732
|
-
sendMessage: sendMessageMattermost
|
|
1733
|
-
onDmChannelResolution: deliveryBarrier.trackDmChannelResolution
|
|
1698
|
+
sendMessage: sendMessageMattermost
|
|
1734
1699
|
});
|
|
1735
1700
|
if (result.visibleReplySent) runtime.log?.(`delivered slash reply to ${to}`);
|
|
1736
1701
|
return result;
|
|
@@ -1750,17 +1715,13 @@ async function handleSlashCommandAsync(params) {
|
|
|
1750
1715
|
});
|
|
1751
1716
|
}
|
|
1752
1717
|
} },
|
|
1753
|
-
dispatcherOptions: {
|
|
1754
|
-
resolveFollowupAdmissionBarrierTimeoutPolicy: deliveryBarrier.resolveTimeoutPolicy,
|
|
1755
|
-
onDeliverySettled: deliveryBarrier.markDeliverySettled,
|
|
1756
|
-
humanDelay
|
|
1757
|
-
},
|
|
1718
|
+
dispatcherOptions: { humanDelay },
|
|
1758
1719
|
replyOptions: { disableBlockStreaming: typeof account.blockStreaming === "boolean" ? !account.blockStreaming : void 0 }
|
|
1759
1720
|
});
|
|
1760
1721
|
}
|
|
1761
1722
|
//#endregion
|
|
1762
1723
|
//#region extensions/mattermost/src/mattermost/slash-state.ts
|
|
1763
|
-
const MULTI_ACCOUNT_BODY_MAX_BYTES =
|
|
1724
|
+
const MULTI_ACCOUNT_BODY_MAX_BYTES = 65536;
|
|
1764
1725
|
const MULTI_ACCOUNT_BODY_TIMEOUT_MS = 5e3;
|
|
1765
1726
|
/**
|
|
1766
1727
|
* Map from accountId → per-account slash command state.
|
|
@@ -1984,15 +1945,7 @@ function registerSlashCommandRoute(api) {
|
|
|
1984
1945
|
}));
|
|
1985
1946
|
return;
|
|
1986
1947
|
}
|
|
1987
|
-
|
|
1988
|
-
const syntheticReq = new Readable({ read() {
|
|
1989
|
-
this.push(Buffer.from(bodyStr, "utf8"));
|
|
1990
|
-
this.push(null);
|
|
1991
|
-
} });
|
|
1992
|
-
syntheticReq.method = req.method;
|
|
1993
|
-
syntheticReq.url = req.url;
|
|
1994
|
-
syntheticReq.headers = req.headers;
|
|
1995
|
-
await matchedHandler(syntheticReq, res);
|
|
1948
|
+
await match.handler(req, res, bodyStr);
|
|
1996
1949
|
};
|
|
1997
1950
|
for (const callbackPath of callbackPaths) api.registerHttpRoute({
|
|
1998
1951
|
path: callbackPath,
|
|
@@ -2001,4 +1954,4 @@ function registerSlashCommandRoute(api) {
|
|
|
2001
1954
|
});
|
|
2002
1955
|
}
|
|
2003
1956
|
//#endregion
|
|
2004
|
-
export {
|
|
1957
|
+
export { registerSlashCommands as _, sendMessageMattermost as a, joinMattermostVisibleContent as c, renderMattermostModelsPickerView as d, renderMattermostProviderPickerView as f, isSlashCommandsEnabled as g, cleanupSlashCommands as h, registerSlashCommandRoute as i, buildMattermostAllowedModelRefs as l, DEFAULT_COMMAND_SPECS as m, deactivateSlashCommands as n, resolveMattermostOpaqueTarget as o, resolveMattermostModelPickerCurrentModel as p, getSlashCommandState as r, deliverMattermostReplyPayload as s, activateSlashCommands as t, parseMattermostModelPickerContext as u, resolveCallbackUrl as v, resolveSlashCommandConfig as y };
|
|
@@ -167,7 +167,9 @@ class PerMessageDeflate {
|
|
|
167
167
|
(typeof opts.serverMaxWindowBits === 'number' &&
|
|
168
168
|
opts.serverMaxWindowBits > params.server_max_window_bits))) ||
|
|
169
169
|
(typeof opts.clientMaxWindowBits === 'number' &&
|
|
170
|
-
|
|
170
|
+
(typeof params.client_max_window_bits === 'number'
|
|
171
|
+
? opts.clientMaxWindowBits > params.client_max_window_bits
|
|
172
|
+
: !params.client_max_window_bits))
|
|
171
173
|
) {
|
|
172
174
|
return false;
|
|
173
175
|
}
|