@openclaw/mattermost 2026.10.2 → 2026.10.5-beta.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/.setup/{callback-host-CBsPjVAZ.mjs → callback-host-Bu2cmtfI.mjs} +3 -3
- package/dist/.setup/{channel-plugin-api-Cg4FPSIP.mjs → channel-plugin-api-DHjqj_yu.mjs} +1 -1
- package/dist/.setup/{channel-plugin-runtime-BsHE7a2R.mjs → channel-plugin-runtime-D-I6TTe4.mjs} +7 -7
- package/dist/.setup/{channel.runtime-B_P0FgP2.mjs → channel.runtime-Bz8jKJUb.mjs} +26 -41
- package/dist/.setup/{client-f2qstbX3.mjs → client-tv20cXIL.mjs} +25 -14
- package/dist/.setup/{gateway-auth-bypass-CfqoieHq.mjs → gateway-auth-bypass-Lf99Gilr.mjs} +1 -1
- package/dist/.setup/{ingress-identity-DNl4yQSc.mjs → ingress-identity-D6hxfxvo.mjs} +1 -2
- package/dist/.setup/{interactions-CfOLvzca.mjs → interactions-AdorvrsQ.mjs} +6 -13
- package/dist/.setup/{monitor-mV676oDI.mjs → monitor-CdOgleQo.mjs} +113 -202
- package/dist/.setup/{monitor-auth-aZ0b1gqx.mjs → monitor-auth-ChM45AzT.mjs} +1 -1
- package/dist/.setup/{normalize-DhF6_2lt.mjs → normalize-B0VHjEFE.mjs} +1 -1
- package/dist/.setup/{send-BI4525Fd.mjs → send-BAUVI-1U.mjs} +11 -16
- package/dist/.setup/{slash-state-BtvU3GNd.mjs → slash-state-CaHXPR0j.mjs} +26 -57
- package/dist/api.js +2 -2
- package/dist/channel-plugin-api.js +1 -1
- package/dist/channel-plugin-runtime.js +1 -1
- package/dist/gateway-auth-api.js +1 -1
- package/dist/policy-api.js +1 -1
- package/dist/setup-entry.js +1 -1
- package/dist/slash-route-api.js +1 -1
- package/package.json +4 -4
|
@@ -13,10 +13,10 @@ function collectMattermostCallbackPaths(config) {
|
|
|
13
13
|
const commands = asOptionalRecord(asOptionalRecord(account)?.commands);
|
|
14
14
|
paths.add(normalizeCallbackPath(commands?.callbackPath));
|
|
15
15
|
const callbackUrl = normalizeOptionalString(commands?.callbackUrl);
|
|
16
|
-
if (callbackUrl)
|
|
17
|
-
const path =
|
|
16
|
+
if (callbackUrl) {
|
|
17
|
+
const path = URL.parse(callbackUrl)?.pathname;
|
|
18
18
|
if (path) paths.add(path);
|
|
19
|
-
}
|
|
19
|
+
}
|
|
20
20
|
}
|
|
21
21
|
return [...paths];
|
|
22
22
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { n as mattermostSetupPlugin, t as mattermostPlugin } from "./channel-plugin-runtime-
|
|
1
|
+
import { n as mattermostSetupPlugin, t as mattermostPlugin } from "./channel-plugin-runtime-D-I6TTe4.mjs";
|
|
2
2
|
import "../channel-plugin-api.js";
|
|
3
3
|
export { mattermostPlugin, mattermostSetupPlugin };
|
package/dist/.setup/{channel-plugin-runtime-BsHE7a2R.mjs → channel-plugin-runtime-D-I6TTe4.mjs}
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { h as normalizeMattermostBaseUrl } from "./client-
|
|
2
|
-
import { t as mattermostIngressIdentity } from "./ingress-identity-
|
|
3
|
-
import { a as resolveMattermostPresentation, c as listMattermostAccountIds, d as resolveMattermostReplyToMode, i as requiresMattermostMediaUpload, l as resolveDefaultMattermostAccountId, n as normalizeMattermostMessagingTarget, o as inspectMattermostAccount, s as isMattermostConfigured$1, t as looksLikeMattermostTargetId, u as resolveMattermostAccount } from "./normalize-
|
|
4
|
-
import { t as resolveMattermostGatewayAuthBypassPaths } from "./gateway-auth-bypass-
|
|
1
|
+
import { h as normalizeMattermostBaseUrl } from "./client-tv20cXIL.mjs";
|
|
2
|
+
import { t as mattermostIngressIdentity } from "./ingress-identity-D6hxfxvo.mjs";
|
|
3
|
+
import { a as resolveMattermostPresentation, c as listMattermostAccountIds, d as resolveMattermostReplyToMode, i as requiresMattermostMediaUpload, l as resolveDefaultMattermostAccountId, n as normalizeMattermostMessagingTarget, o as inspectMattermostAccount, s as isMattermostConfigured$1, t as looksLikeMattermostTargetId, u as resolveMattermostAccount } from "./normalize-B0VHjEFE.mjs";
|
|
4
|
+
import { t as resolveMattermostGatewayAuthBypassPaths } from "./gateway-auth-bypass-Lf99Gilr.mjs";
|
|
5
5
|
import { n as normalizeCompatibilityConfig, t as legacyConfigRules } from "./doctor-contract-CjgZkyPm.mjs";
|
|
6
6
|
import { n as collectRuntimeConfigAssignments, r as secretTargetRegistryEntries } from "./secret-contract-qg3NXRlS.mjs";
|
|
7
7
|
import { asOptionalRecord, normalizeLowercaseStringOrEmpty, normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
@@ -35,7 +35,7 @@ import { createSetupInputPresenceValidator } from "openclaw/plugin-sdk/setup-run
|
|
|
35
35
|
//#region extensions/mattermost/src/approval-auth.ts
|
|
36
36
|
const MATTERMOST_USER_ID_RE = /^[a-z0-9]{26}$/;
|
|
37
37
|
function normalizeMattermostApproverId(value) {
|
|
38
|
-
const normalized = String(value).trim().replace(/^(mattermost|user):/i, "").replace(/^@/, "")
|
|
38
|
+
const normalized = String(value).trim().replace(/^(mattermost|user):/i, "").replace(/^@/, "");
|
|
39
39
|
const lowered = normalizeLowercaseStringOrEmpty(normalized);
|
|
40
40
|
return MATTERMOST_USER_ID_RE.test(lowered) ? lowered : void 0;
|
|
41
41
|
}
|
|
@@ -638,7 +638,7 @@ function resolveMattermostOutboundSessionRoute(params) {
|
|
|
638
638
|
}
|
|
639
639
|
//#endregion
|
|
640
640
|
//#region extensions/mattermost/src/channel.ts
|
|
641
|
-
const loadMattermostChannelRuntime = createLazyRuntimeModule(() => import("./channel.runtime-
|
|
641
|
+
const loadMattermostChannelRuntime = createLazyRuntimeModule(() => import("./channel.runtime-Bz8jKJUb.mjs"));
|
|
642
642
|
const MATTERMOST_PRESENTATION_CAPABILITIES = {
|
|
643
643
|
supported: true,
|
|
644
644
|
buttons: true,
|
|
@@ -1103,7 +1103,7 @@ const mattermostPlugin = createChatChannelPlugin({
|
|
|
1103
1103
|
botTokenSource: account.botTokenSource
|
|
1104
1104
|
});
|
|
1105
1105
|
ctx.log?.info(`[${account.accountId}] starting channel`);
|
|
1106
|
-
return (await import("./monitor-
|
|
1106
|
+
return (await import("./monitor-CdOgleQo.mjs")).monitorMattermostProvider({
|
|
1107
1107
|
botToken: account.botToken ?? void 0,
|
|
1108
1108
|
baseUrl: account.baseUrl ?? void 0,
|
|
1109
1109
|
accountId: account.accountId,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { _ as readMattermostError, h as normalizeMattermostBaseUrl, l as fetchMattermostChannelPosts, r as createMattermostClient, s as fetchMattermostChannel, u as fetchMattermostMe } from "./client-
|
|
2
|
-
import { o as resolveMattermostTrustedChatKind } from "./monitor-auth-
|
|
3
|
-
import { c as listMattermostAccountIds, n as normalizeMattermostMessagingTarget, o as inspectMattermostAccount, u as resolveMattermostAccount } from "./normalize-
|
|
4
|
-
import { n as resolveMattermostOpaqueTarget, t as sendMessageMattermost } from "./send-
|
|
1
|
+
import { _ as readMattermostError, h as normalizeMattermostBaseUrl, l as fetchMattermostChannelPosts, r as createMattermostClient, s as fetchMattermostChannel, u as fetchMattermostMe } from "./client-tv20cXIL.mjs";
|
|
2
|
+
import { o as resolveMattermostTrustedChatKind } from "./monitor-auth-ChM45AzT.mjs";
|
|
3
|
+
import { c as listMattermostAccountIds, n as normalizeMattermostMessagingTarget, o as inspectMattermostAccount, u as resolveMattermostAccount } from "./normalize-B0VHjEFE.mjs";
|
|
4
|
+
import { n as resolveMattermostOpaqueTarget, t as sendMessageMattermost } from "./send-BAUVI-1U.mjs";
|
|
5
5
|
import { normalizeLowercaseStringOrEmpty } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
6
6
|
import { runChannelProbe } from "openclaw/plugin-sdk/text-utility-runtime";
|
|
7
7
|
import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
|
|
@@ -131,7 +131,7 @@ async function listMattermostDirectoryPeers(params) {
|
|
|
131
131
|
}
|
|
132
132
|
//#endregion
|
|
133
133
|
//#region extensions/mattermost/src/mattermost/probe.ts
|
|
134
|
-
async function probeMattermost(baseUrl, botToken, timeoutMs = 2500, allowPrivateNetwork = false
|
|
134
|
+
async function probeMattermost(baseUrl, botToken, timeoutMs = 2500, allowPrivateNetwork = false) {
|
|
135
135
|
const normalized = normalizeMattermostBaseUrl(baseUrl);
|
|
136
136
|
if (!normalized) return {
|
|
137
137
|
ok: false,
|
|
@@ -146,9 +146,7 @@ async function probeMattermost(baseUrl, botToken, timeoutMs = 2500, allowPrivate
|
|
|
146
146
|
init: { headers },
|
|
147
147
|
auditContext: "mattermost-probe",
|
|
148
148
|
policy: ssrfPolicyFromPrivateNetworkOptIn(allowPrivateNetwork),
|
|
149
|
-
...resolvedTimeoutMs !== void 0 ? { timeoutMs: resolvedTimeoutMs } : {}
|
|
150
|
-
...deps?.fetchImpl ? { fetchImpl: deps.fetchImpl } : {},
|
|
151
|
-
...deps?.lookupFn ? { lookupFn: deps.lookupFn } : {}
|
|
149
|
+
...resolvedTimeoutMs !== void 0 ? { timeoutMs: resolvedTimeoutMs } : {}
|
|
152
150
|
});
|
|
153
151
|
const requestElapsedMs = elapsedMs();
|
|
154
152
|
try {
|
|
@@ -161,7 +159,7 @@ async function probeMattermost(baseUrl, botToken, timeoutMs = 2500, allowPrivate
|
|
|
161
159
|
elapsedMs: requestElapsedMs
|
|
162
160
|
};
|
|
163
161
|
}
|
|
164
|
-
const bot = await readProviderJsonResponse(res, "Mattermost
|
|
162
|
+
const bot = await readProviderJsonResponse(res, "Mattermost check /users/me");
|
|
165
163
|
return {
|
|
166
164
|
ok: true,
|
|
167
165
|
status: res.status,
|
|
@@ -199,16 +197,10 @@ async function resolveBotUserId(client, cacheKey) {
|
|
|
199
197
|
return userId;
|
|
200
198
|
}
|
|
201
199
|
async function addMattermostReaction(params) {
|
|
202
|
-
return runMattermostReaction(params,
|
|
203
|
-
action: "add",
|
|
204
|
-
mutation: createReaction
|
|
205
|
-
});
|
|
200
|
+
return runMattermostReaction(params, "add");
|
|
206
201
|
}
|
|
207
202
|
async function removeMattermostReaction(params) {
|
|
208
|
-
return runMattermostReaction(params,
|
|
209
|
-
action: "remove",
|
|
210
|
-
mutation: deleteReaction
|
|
211
|
-
});
|
|
203
|
+
return runMattermostReaction(params, "remove");
|
|
212
204
|
}
|
|
213
205
|
function parseAuthorizedReactionTarget(rawTarget) {
|
|
214
206
|
const normalized = rawTarget ? normalizeMattermostMessagingTarget(rawTarget) : void 0;
|
|
@@ -246,7 +238,7 @@ async function authorizeMattermostReactionResource(params) {
|
|
|
246
238
|
if (channel.type !== "D" || participants.length !== 2 || participants[0] !== authorizedParticipants[0] || participants[1] !== authorizedParticipants[1]) throw new Error("Mattermost reaction post belongs to a different direct conversation.");
|
|
247
239
|
return botUserId;
|
|
248
240
|
}
|
|
249
|
-
async function runMattermostReaction(params,
|
|
241
|
+
async function runMattermostReaction(params, action) {
|
|
250
242
|
const resolved = resolveMattermostAccount({
|
|
251
243
|
cfg: params.cfg,
|
|
252
244
|
accountId: params.accountId
|
|
@@ -275,37 +267,30 @@ async function runMattermostReaction(params, options) {
|
|
|
275
267
|
ok: false,
|
|
276
268
|
error: "Mattermost reactions failed: could not resolve bot user id."
|
|
277
269
|
};
|
|
278
|
-
await
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
270
|
+
if (action === "add") await client.request("/reactions", {
|
|
271
|
+
method: "POST",
|
|
272
|
+
body: JSON.stringify({
|
|
273
|
+
user_id: userId,
|
|
274
|
+
post_id: params.postId,
|
|
275
|
+
emoji_name: params.emojiName
|
|
276
|
+
}),
|
|
277
|
+
discardResponse: true
|
|
282
278
|
});
|
|
279
|
+
else {
|
|
280
|
+
const emoji = encodeURIComponent(params.emojiName);
|
|
281
|
+
await client.request(`/users/${userId}/posts/${params.postId}/reactions/${emoji}`, {
|
|
282
|
+
method: "DELETE",
|
|
283
|
+
discardResponse: true
|
|
284
|
+
});
|
|
285
|
+
}
|
|
283
286
|
} catch (err) {
|
|
284
287
|
return {
|
|
285
288
|
ok: false,
|
|
286
|
-
error: `Mattermost ${
|
|
289
|
+
error: `Mattermost ${action} reaction failed: ${String(err)}`
|
|
287
290
|
};
|
|
288
291
|
}
|
|
289
292
|
return { ok: true };
|
|
290
293
|
}
|
|
291
|
-
async function createReaction(client, params) {
|
|
292
|
-
await client.request("/reactions", {
|
|
293
|
-
method: "POST",
|
|
294
|
-
body: JSON.stringify({
|
|
295
|
-
user_id: params.userId,
|
|
296
|
-
post_id: params.postId,
|
|
297
|
-
emoji_name: params.emojiName
|
|
298
|
-
}),
|
|
299
|
-
discardResponse: true
|
|
300
|
-
});
|
|
301
|
-
}
|
|
302
|
-
async function deleteReaction(client, params) {
|
|
303
|
-
const emoji = encodeURIComponent(params.emojiName);
|
|
304
|
-
await client.request(`/users/${params.userId}/posts/${params.postId}/reactions/${emoji}`, {
|
|
305
|
-
method: "DELETE",
|
|
306
|
-
discardResponse: true
|
|
307
|
-
});
|
|
308
|
-
}
|
|
309
294
|
//#endregion
|
|
310
295
|
//#region extensions/mattermost/src/mattermost/read.ts
|
|
311
296
|
function parseMattermostChannelTarget(rawTarget) {
|
|
@@ -3,7 +3,7 @@ import { bufferToBlobPart } from "openclaw/plugin-sdk/blob-runtime";
|
|
|
3
3
|
import { createChannelPartialDeliveryError } from "openclaw/plugin-sdk/channel-inbound";
|
|
4
4
|
import { PlatformMessageNotDispatchedError, collectErrorGraphCandidates, readErrorName } from "openclaw/plugin-sdk/error-runtime";
|
|
5
5
|
import { buildTimeoutAbortSignal } from "openclaw/plugin-sdk/extension-shared";
|
|
6
|
-
import { captureChannelReadAuthority, responseWithRelease } from "openclaw/plugin-sdk/fetch-runtime";
|
|
6
|
+
import { captureChannelReadAuthority, captureEffectAuthority, responseWithRelease } from "openclaw/plugin-sdk/fetch-runtime";
|
|
7
7
|
import { resolveTimerTimeoutMs } from "openclaw/plugin-sdk/number-runtime";
|
|
8
8
|
import { readProviderJsonResponse, redactProviderResponseErrorText } from "openclaw/plugin-sdk/provider-http";
|
|
9
9
|
import { readResponseTextPrefix, readResponseWithLimit } from "openclaw/plugin-sdk/response-limit-runtime";
|
|
@@ -67,7 +67,10 @@ async function readMattermostError(res, requestHeaders) {
|
|
|
67
67
|
const { text, truncated } = await readResponseTextPrefix(res, MATTERMOST_ERROR_BODY_LIMIT_BYTES, {
|
|
68
68
|
chunkTimeoutMs: 1e4,
|
|
69
69
|
onIdleTimeout: ({ chunkTimeoutMs }) => /* @__PURE__ */ new Error(`error body read stalled for ${chunkTimeoutMs}ms`)
|
|
70
|
-
})
|
|
70
|
+
}).catch(() => ({
|
|
71
|
+
text: "error response body unavailable",
|
|
72
|
+
truncated: false
|
|
73
|
+
}));
|
|
71
74
|
let detail = text;
|
|
72
75
|
if (contentType.includes("application/json")) try {
|
|
73
76
|
const data = JSON.parse(text);
|
|
@@ -119,7 +122,9 @@ function createMattermostClient(params) {
|
|
|
119
122
|
return responseWithRelease(response, release);
|
|
120
123
|
};
|
|
121
124
|
const fetchImpl = (externalFetchImpl ? async (input, init) => {
|
|
122
|
-
|
|
125
|
+
const effect = captureEffectAuthority();
|
|
126
|
+
const assertReadAuthority = captureChannelReadAuthority();
|
|
127
|
+
assertReadAuthority?.();
|
|
123
128
|
const url = typeof input === "string" ? input : input instanceof URL ? input.toString() : input.url;
|
|
124
129
|
const { timeoutMs: initTimeoutMs, isMessagePost, ...requestInit } = init ?? {};
|
|
125
130
|
const timeoutMs = resolveTimerTimeoutMs(initTimeoutMs, requestTimeoutMs);
|
|
@@ -131,11 +136,15 @@ function createMattermostClient(params) {
|
|
|
131
136
|
const callerSignal = requestInit.signal ?? void 0;
|
|
132
137
|
const signal = callerSignal && timeoutSignal ? AbortSignal.any([callerSignal, timeoutSignal]) : callerSignal ?? timeoutSignal;
|
|
133
138
|
try {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
+
const response = await effect.initiate(() => {
|
|
140
|
+
assertReadAuthority?.();
|
|
141
|
+
assertRequestCurrent?.();
|
|
142
|
+
signal?.throwIfAborted();
|
|
143
|
+
if (isMessagePost) postDispatchStarted = true;
|
|
144
|
+
return externalFetchImpl(input, {
|
|
145
|
+
...requestInit,
|
|
146
|
+
signal
|
|
147
|
+
});
|
|
139
148
|
});
|
|
140
149
|
return responseWithRelease(response, async () => cleanup());
|
|
141
150
|
} catch (error) {
|
|
@@ -305,14 +314,16 @@ function isRetryableError(error) {
|
|
|
305
314
|
current.reason,
|
|
306
315
|
...Array.isArray(current.errors) ? current.errors : []
|
|
307
316
|
]);
|
|
308
|
-
const
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
if (messages.some((message) => /mattermost api \d{3}\b/.test(message))) return false;
|
|
317
|
+
for (const candidate of candidates) {
|
|
318
|
+
const status = parseMattermostApiStatus(candidate);
|
|
319
|
+
if (status !== void 0) return status === 429 || status >= 500 && status < 600;
|
|
320
|
+
}
|
|
313
321
|
if (candidates.some((candidate) => RETRYABLE_NETWORK_ERROR_CODES.has(readErrorCode(candidate) ?? ""))) return true;
|
|
314
322
|
if (candidates.some((candidate) => RETRYABLE_NETWORK_ERROR_NAMES.has(readErrorName(candidate)))) return true;
|
|
315
|
-
return
|
|
323
|
+
return candidates.some((candidate) => {
|
|
324
|
+
const message = normalizeLowercaseStringOrEmpty(readStringField(asOptionalObjectRecord(candidate), "message"));
|
|
325
|
+
return message.includes("too many requests") || RETRYABLE_NETWORK_MESSAGE_SNIPPETS.some((pattern) => message.includes(pattern));
|
|
326
|
+
});
|
|
316
327
|
}
|
|
317
328
|
function readErrorCode(error) {
|
|
318
329
|
if (!error || typeof error !== "object") return;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as collectMattermostCallbackPaths } from "./callback-host-
|
|
1
|
+
import { t as collectMattermostCallbackPaths } from "./callback-host-Bu2cmtfI.mjs";
|
|
2
2
|
//#region extensions/mattermost/src/gateway-auth-bypass.ts
|
|
3
3
|
function resolveMattermostGatewayAuthBypassPaths(params) {
|
|
4
4
|
return collectMattermostCallbackPaths(params.cfg.channels?.mattermost).filter((path) => path.startsWith("/api/channels/mattermost/"));
|
|
@@ -20,8 +20,7 @@ function normalizeMattermostAllowEntry(entry) {
|
|
|
20
20
|
if (trimmed === "*") return "*";
|
|
21
21
|
const accessGroupName = parseAccessGroupAllowFromEntry(trimmed);
|
|
22
22
|
if (accessGroupName) return `accessGroup:${accessGroupName}`;
|
|
23
|
-
|
|
24
|
-
return normalized ? normalizeLowercaseStringOrEmpty(normalized) : "";
|
|
23
|
+
return normalizeLowercaseStringOrEmpty(trimmed.replace(/^(mattermost|user):/i, "").replace(/^@/, ""));
|
|
25
24
|
}
|
|
26
25
|
//#endregion
|
|
27
26
|
export { normalizeMattermostAllowEntry as n, mattermostIngressIdentity as t };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { n as __reExport, t as __exportAll } from "./rolldown-runtime-BBjsoOtd.mjs";
|
|
2
2
|
import { t as getMattermostRuntime } from "./runtime-CNB4YGqJ.mjs";
|
|
3
|
-
import { r as resolveCallbackHost } from "./callback-host-
|
|
4
|
-
import { y as updateMattermostPost } from "./client-
|
|
5
|
-
import { D as sendHttpRequestRejection, T as resolveClientIp, g as isTrustedProxyAddress, h as isRequestBodyLimitError, x as readRequestBodyWithLimit } from "./monitor-auth-
|
|
3
|
+
import { r as resolveCallbackHost } from "./callback-host-Bu2cmtfI.mjs";
|
|
4
|
+
import { y as updateMattermostPost } from "./client-tv20cXIL.mjs";
|
|
5
|
+
import { D as sendHttpRequestRejection, T as resolveClientIp, g as isTrustedProxyAddress, h as isRequestBodyLimitError, x as readRequestBodyWithLimit } from "./monitor-auth-ChM45AzT.mjs";
|
|
6
6
|
import { createHmac } from "node:crypto";
|
|
7
7
|
import { safeEqualSecret } from "openclaw/plugin-sdk/security-runtime";
|
|
8
8
|
import { normalizeOptionalString, normalizeStringifiedOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
@@ -56,22 +56,15 @@ function normalizePathSeparators(pathname) {
|
|
|
56
56
|
if (collapsed.length <= 1) return collapsed;
|
|
57
57
|
return collapsed.replace(/\/+$/, "");
|
|
58
58
|
}
|
|
59
|
-
function resolveDotSegments(pathname) {
|
|
60
|
-
try {
|
|
61
|
-
return new URL(pathname, "http://localhost").pathname;
|
|
62
|
-
} catch {
|
|
63
|
-
return pathname;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
59
|
function normalizePathForSecurity(pathname) {
|
|
67
|
-
return normalizePathSeparators(normalizeLowercaseStringOrEmpty$1(
|
|
60
|
+
return normalizePathSeparators(normalizeLowercaseStringOrEmpty$1(URL.parse(pathname, "http://localhost")?.pathname ?? pathname)) || "/";
|
|
68
61
|
}
|
|
69
|
-
function buildCanonicalPathCandidates(pathname
|
|
62
|
+
function buildCanonicalPathCandidates(pathname) {
|
|
70
63
|
const candidates = /* @__PURE__ */ new Set([normalizePathForSecurity(pathname)]);
|
|
71
64
|
let decoded = pathname;
|
|
72
65
|
let malformedEncoding = false;
|
|
73
66
|
let decodePasses = 0;
|
|
74
|
-
for (let pass = 0; pass <
|
|
67
|
+
for (let pass = 0; pass < MAX_PATH_DECODE_PASSES; pass++) {
|
|
75
68
|
let nextDecoded;
|
|
76
69
|
try {
|
|
77
70
|
nextDecoded = decodeURIComponent(decoded);
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { a as resolveInteractionCallbackPath, c as setInteractionSecret, i as createMattermostInteractionHandler, l as gateway_config_runtime_exports, n as buildButtonProps, r as computeInteractionCallbackUrl, s as setInteractionCallbackUrl } from "./interactions-
|
|
1
|
+
import { a as resolveInteractionCallbackPath, c as setInteractionSecret, i as createMattermostInteractionHandler, l as gateway_config_runtime_exports, n as buildButtonProps, r as computeInteractionCallbackUrl, s as setInteractionCallbackUrl } from "./interactions-AdorvrsQ.mjs";
|
|
2
2
|
import { n as getOptionalMattermostRuntime, t as getMattermostRuntime } from "./runtime-CNB4YGqJ.mjs";
|
|
3
|
-
import { a as createMattermostPost, d as fetchMattermostUser, h as normalizeMattermostBaseUrl, m as isRetryableError, n as buildMattermostApiUrl, o as deleteMattermostPost, p as fetchMattermostUserTeams, r as createMattermostClient, s as fetchMattermostChannel, t as MattermostPostSchema, u as fetchMattermostMe, v as sendMattermostTyping, y as updateMattermostPost } from "./client-
|
|
4
|
-
import { C as resolveAllowlistProviderRuntimeGroupPolicy, E as resolveDefaultGroupPolicy, O as warnMissingProviderGroupPolicyFallbackOnce, S as registerPluginHttpRoute, _ as listSkillCommandsForAgents, a as resolveMattermostMonitorInboundAccess, b as logTypingFailure, c as DEFAULT_GROUP_HISTORY_LIMIT, d as createChannelMessageReplyPipeline, f as createChannelPairingController, l as buildPreparedModelsProviderData, m as isDangerousNameMatchingEnabled, n as formatMattermostDirectMessageDropLog, o as resolveMattermostTrustedChatKind, s as shouldRetainMattermostSenderHistory, t as authorizeMattermostCommandInvocation, u as createChannelHistoryWindow, w as resolveChannelMediaMaxBytes, y as logInboundDrop } from "./monitor-auth-
|
|
5
|
-
import { n as normalizeMattermostAllowEntry } from "./ingress-identity-
|
|
6
|
-
import { d as resolveMattermostReplyToMode, r as parseMattermostQuestionContext, u as resolveMattermostAccount } from "./normalize-
|
|
7
|
-
import { _ as resolveSlashCommandConfig, a as deliverMattermostReplyPayload, c as parseMattermostModelPickerContext, d as resolveMattermostModelPickerCurrentModel, f as DEFAULT_COMMAND_SPECS, g as resolveCallbackUrl, h as registerSlashCommands, l as renderMattermostModelsPickerView, m as isSlashCommandsEnabled, n as deactivateSlashCommands, o as joinMattermostVisibleContent, p as cleanupSlashCommands, r as getSlashCommandState, s as buildMattermostAllowedModelRefs, t as activateSlashCommands, u as renderMattermostProviderPickerView } from "./slash-state-
|
|
8
|
-
import { t as sendMessageMattermost } from "./send-
|
|
3
|
+
import { a as createMattermostPost, d as fetchMattermostUser, h as normalizeMattermostBaseUrl, m as isRetryableError, n as buildMattermostApiUrl, o as deleteMattermostPost, p as fetchMattermostUserTeams, r as createMattermostClient, s as fetchMattermostChannel, t as MattermostPostSchema, u as fetchMattermostMe, v as sendMattermostTyping, y as updateMattermostPost } from "./client-tv20cXIL.mjs";
|
|
4
|
+
import { C as resolveAllowlistProviderRuntimeGroupPolicy, E as resolveDefaultGroupPolicy, O as warnMissingProviderGroupPolicyFallbackOnce, S as registerPluginHttpRoute, _ as listSkillCommandsForAgents, a as resolveMattermostMonitorInboundAccess, b as logTypingFailure, c as DEFAULT_GROUP_HISTORY_LIMIT, d as createChannelMessageReplyPipeline, f as createChannelPairingController, l as buildPreparedModelsProviderData, m as isDangerousNameMatchingEnabled, n as formatMattermostDirectMessageDropLog, o as resolveMattermostTrustedChatKind, s as shouldRetainMattermostSenderHistory, t as authorizeMattermostCommandInvocation, u as createChannelHistoryWindow, w as resolveChannelMediaMaxBytes, y as logInboundDrop } from "./monitor-auth-ChM45AzT.mjs";
|
|
5
|
+
import { n as normalizeMattermostAllowEntry } from "./ingress-identity-D6hxfxvo.mjs";
|
|
6
|
+
import { d as resolveMattermostReplyToMode, r as parseMattermostQuestionContext, u as resolveMattermostAccount } from "./normalize-B0VHjEFE.mjs";
|
|
7
|
+
import { _ as resolveSlashCommandConfig, a as deliverMattermostReplyPayload, c as parseMattermostModelPickerContext, d as resolveMattermostModelPickerCurrentModel, f as DEFAULT_COMMAND_SPECS, g as resolveCallbackUrl, h as registerSlashCommands, l as renderMattermostModelsPickerView, m as isSlashCommandsEnabled, n as deactivateSlashCommands, o as joinMattermostVisibleContent, p as cleanupSlashCommands, r as getSlashCommandState, s as buildMattermostAllowedModelRefs, t as activateSlashCommands, u as renderMattermostProviderPickerView } from "./slash-state-CaHXPR0j.mjs";
|
|
8
|
+
import { t as sendMessageMattermost } from "./send-BAUVI-1U.mjs";
|
|
9
9
|
import { randomUUID } from "node:crypto";
|
|
10
10
|
import { resolvePinnedMainDmOwnerFromAllowlist, sanitizeUntrustedFileName } from "openclaw/plugin-sdk/security-runtime";
|
|
11
11
|
import { normalizeLowercaseStringOrEmpty, normalizeOptionalString, normalizeStringEntries, normalizeTrimmedStringList, uniqueStrings } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
12
12
|
import { escapeRegExp, sliceUtf16Safe, truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
|
|
13
|
-
import { createAcceptedChannelDeliveryResult, createChannelPartialDeliveryError, formatInboundEnvelope, formatInboundFromLabel, formatInboundMediaUnavailableText, formatMediaPlaceholderText, implicitMentionKindWhen, isChannelPartialDeliveryError, resolveInboundMentionDecision,
|
|
13
|
+
import { createAcceptedChannelDeliveryResult, createChannelPartialDeliveryError, formatInboundEnvelope, formatInboundFromLabel, formatInboundMediaUnavailableText, formatMediaPlaceholderText, implicitMentionKindWhen, isChannelPartialDeliveryError, resolveInboundMentionDecision, resolveInboundSessionEnvelopeContextAsync, toInboundMediaFactsWithMetadata } from "openclaw/plugin-sdk/channel-inbound";
|
|
14
14
|
import { formatErrorMessage, toErrorObject } from "openclaw/plugin-sdk/error-runtime";
|
|
15
15
|
import { safeParseJsonWithSchema, safeParseWithSchema } from "openclaw/plugin-sdk/extension-shared";
|
|
16
16
|
import { asDateTimestampMs, resolveExpiresAtMsFromDurationMs, resolvePromptHistoryLimit } from "openclaw/plugin-sdk/number-runtime";
|
|
@@ -74,9 +74,9 @@ function normalizeMention(text, mention) {
|
|
|
74
74
|
}
|
|
75
75
|
function shouldDropEmptyMattermostBody(params) {
|
|
76
76
|
if (/[^\p{White_Space}\p{Cc}\p{Cf}\p{M}]/u.test(params.bodyText)) return false;
|
|
77
|
-
const botUsername = normalizeLowercaseStringOrEmpty(params.botUsername
|
|
77
|
+
const botUsername = normalizeLowercaseStringOrEmpty(params.botUsername);
|
|
78
78
|
const bareMention = params.rawText.match(/^[ \t]*(@\S+)[ \t]*$/u)?.[1];
|
|
79
|
-
return !botUsername || normalizeLowercaseStringOrEmpty(bareMention
|
|
79
|
+
return !botUsername || normalizeLowercaseStringOrEmpty(bareMention) !== `@${botUsername}`;
|
|
80
80
|
}
|
|
81
81
|
//#endregion
|
|
82
82
|
//#region extensions/mattermost/src/mattermost/monitor-websocket.ts
|
|
@@ -496,24 +496,6 @@ function createMattermostIngressMonitor(options) {
|
|
|
496
496
|
};
|
|
497
497
|
}
|
|
498
498
|
//#endregion
|
|
499
|
-
//#region extensions/mattermost/src/mattermost/no-visible-reply-diagnostic.ts
|
|
500
|
-
/** Detect dropped substantive payloads even when the agent run succeeded (#80501). */
|
|
501
|
-
function evaluateMattermostNoVisibleReply(params) {
|
|
502
|
-
if (params.outcome !== "empty") return null;
|
|
503
|
-
const finalText = typeof params.payload.text === "string" ? params.payload.text.trim() : "";
|
|
504
|
-
const mediaUrlCount = countOutboundMedia(params.payload);
|
|
505
|
-
if (finalText.length === 0 && mediaUrlCount === 0) return null;
|
|
506
|
-
return {
|
|
507
|
-
reason: "no-visible-reply-after-final-delivery",
|
|
508
|
-
outcome: params.outcome,
|
|
509
|
-
finalTextLength: finalText.length,
|
|
510
|
-
mediaUrlCount
|
|
511
|
-
};
|
|
512
|
-
}
|
|
513
|
-
function formatMattermostNoVisibleReplyLog(params) {
|
|
514
|
-
return `mattermost no-visible-reply: ${params.violation.reason} to=${params.to} accountId=${params.accountId} agentId=${params.agentId ?? "unknown"} outcome=${params.violation.outcome} finalTextLength=${params.violation.finalTextLength} mediaUrlCount=${params.violation.mediaUrlCount}`;
|
|
515
|
-
}
|
|
516
|
-
//#endregion
|
|
517
499
|
//#region extensions/mattermost/src/mattermost/monitor-context.ts
|
|
518
500
|
function shouldUpdateMattermostDraftToolProgress(account) {
|
|
519
501
|
return account.streamingMode !== "off" && resolveChannelStreamingPreviewToolProgress(account.config, account.streamingMode !== "progress", account.streamingMode);
|
|
@@ -550,33 +532,15 @@ function canFinalizeMattermostPreviewInPlace(params) {
|
|
|
550
532
|
}) === params.previewRootId?.trim();
|
|
551
533
|
}
|
|
552
534
|
function formatMattermostFinalDeliveryOutcomeLog(params) {
|
|
553
|
-
const violation = evaluateMattermostNoVisibleReply({
|
|
554
|
-
outcome: params.outcome,
|
|
555
|
-
payload: params.payload
|
|
556
|
-
});
|
|
557
|
-
if (violation) return formatMattermostNoVisibleReplyLog({
|
|
558
|
-
violation,
|
|
559
|
-
to: params.to,
|
|
560
|
-
accountId: params.accountId,
|
|
561
|
-
agentId: params.agentId
|
|
562
|
-
});
|
|
563
535
|
if (params.outcome === "text" || params.outcome === "media") return `delivered reply to ${params.to}`;
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
const postId = normalizeOptionalString(params.postId);
|
|
570
|
-
if (!postId) return;
|
|
571
|
-
return params.replyToMode === "all" || params.replyToMode === "first" || params.replyToMode === "batched" ? postId : void 0;
|
|
536
|
+
if (params.outcome === "empty") {
|
|
537
|
+
const finalText = typeof params.payload.text === "string" ? params.payload.text.trim() : "";
|
|
538
|
+
const mediaUrlCount = countOutboundMedia(params.payload);
|
|
539
|
+
if (finalText.length > 0 || mediaUrlCount > 0) return `mattermost no-visible-reply: no-visible-reply-after-final-delivery to=${params.to} accountId=${params.accountId} agentId=${params.agentId ?? "unknown"} outcome=${params.outcome} finalTextLength=${finalText.length} mediaUrlCount=${mediaUrlCount}`;
|
|
540
|
+
}
|
|
572
541
|
}
|
|
573
542
|
function resolveMattermostThreadSessionContext(params) {
|
|
574
|
-
const effectiveReplyToId =
|
|
575
|
-
kind: params.kind,
|
|
576
|
-
postId: params.postId,
|
|
577
|
-
replyToMode: params.replyToMode,
|
|
578
|
-
threadRootId: params.threadRootId
|
|
579
|
-
});
|
|
543
|
+
const effectiveReplyToId = params.kind === "direct" && params.replyToMode === "off" ? void 0 : normalizeOptionalString(params.threadRootId) ?? (params.replyToMode !== "off" ? normalizeOptionalString(params.postId) : void 0);
|
|
580
544
|
const threadKeys = resolveThreadSessionKeys({
|
|
581
545
|
baseSessionKey: params.baseSessionKey,
|
|
582
546
|
threadId: effectiveReplyToId,
|
|
@@ -876,68 +840,6 @@ function registerMattermostInteractions(params) {
|
|
|
876
840
|
function createMattermostModelPickerInteractionHandler(monitor) {
|
|
877
841
|
const { account, cfg, core, pairing, resources, runtime } = monitor;
|
|
878
842
|
const { resolveChannelInfo, updateModelPickerPost } = resources;
|
|
879
|
-
const runModelPickerCommand = async (params) => {
|
|
880
|
-
const { channelDisplay, channelId, kind, roomLabel, route, thread } = params.eventPlan;
|
|
881
|
-
const fromLabel = kind === "direct" ? `Mattermost DM from ${params.senderName}` : `Mattermost message in ${roomLabel} from ${params.senderName}`;
|
|
882
|
-
const ctxPayload = params.eventPlan.finalizeContext({
|
|
883
|
-
Body: params.commandText,
|
|
884
|
-
BodyForAgent: params.commandText,
|
|
885
|
-
RawBody: params.commandText,
|
|
886
|
-
CommandBody: params.commandText,
|
|
887
|
-
ConversationLabel: fromLabel,
|
|
888
|
-
GroupSubject: kind !== "direct" ? channelDisplay || roomLabel : void 0,
|
|
889
|
-
SenderName: params.senderName,
|
|
890
|
-
MessageSid: params.messageSid,
|
|
891
|
-
Timestamp: Date.now(),
|
|
892
|
-
WasMentioned: true,
|
|
893
|
-
CommandAuthorized: params.commandAuthorized,
|
|
894
|
-
CommandSource: "native"
|
|
895
|
-
});
|
|
896
|
-
const { replyOptions, replyPipeline, tableMode, textLimit } = params.eventPlan.createReplyPlan();
|
|
897
|
-
await core.channel.inbound.dispatch({
|
|
898
|
-
cfg,
|
|
899
|
-
channel: "mattermost",
|
|
900
|
-
accountId: account.accountId,
|
|
901
|
-
route: {
|
|
902
|
-
agentId: route.agentId,
|
|
903
|
-
dmScope: route.dmScope,
|
|
904
|
-
sessionKey: thread.sessionKey
|
|
905
|
-
},
|
|
906
|
-
ctxPayload,
|
|
907
|
-
delivery: {
|
|
908
|
-
observeMessageSent: true,
|
|
909
|
-
deliver: async (payload) => {
|
|
910
|
-
const trimmedPayload = {
|
|
911
|
-
...payload,
|
|
912
|
-
text: core.channel.text.convertMarkdownTables(payload.text ?? "", tableMode).trim()
|
|
913
|
-
};
|
|
914
|
-
return await deliverMattermostReplyPayload({
|
|
915
|
-
core,
|
|
916
|
-
cfg,
|
|
917
|
-
payload: trimmedPayload,
|
|
918
|
-
channelId,
|
|
919
|
-
accountId: account.accountId,
|
|
920
|
-
agentId: route.agentId,
|
|
921
|
-
replyToId: resolveMattermostInteractionReplyRootId({
|
|
922
|
-
kind,
|
|
923
|
-
threadRootId: thread.effectiveReplyToId,
|
|
924
|
-
replyToId: trimmedPayload.replyToId,
|
|
925
|
-
interactionMessageSid: params.messageSid,
|
|
926
|
-
sourcePostId: params.sourcePostId
|
|
927
|
-
}),
|
|
928
|
-
textLimit,
|
|
929
|
-
tableMode: "off",
|
|
930
|
-
sendMessage: sendMessageMattermost
|
|
931
|
-
});
|
|
932
|
-
},
|
|
933
|
-
onError: (err, info) => {
|
|
934
|
-
runtime.error?.(`mattermost model picker ${info.kind} reply failed: ${String(err)}`);
|
|
935
|
-
}
|
|
936
|
-
},
|
|
937
|
-
replyPipeline,
|
|
938
|
-
replyOptions
|
|
939
|
-
});
|
|
940
|
-
};
|
|
941
843
|
return async (params) => {
|
|
942
844
|
const pickerState = parseMattermostModelPickerContext(params.context);
|
|
943
845
|
if (!pickerState) return null;
|
|
@@ -1029,13 +931,67 @@ function createMattermostModelPickerInteractionHandler(monitor) {
|
|
|
1029
931
|
model: pickerState.model
|
|
1030
932
|
});
|
|
1031
933
|
runDetachedWebhookWork(async () => {
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
934
|
+
const commandText = `/model ${targetModelRef}`;
|
|
935
|
+
const sourcePostId = params.post.id || params.payload.post_id;
|
|
936
|
+
const { channelDisplay, channelId, kind, roomLabel, route, thread } = eventPlan;
|
|
937
|
+
const fromLabel = kind === "direct" ? `Mattermost DM from ${params.userName}` : `Mattermost message in ${roomLabel} from ${params.userName}`;
|
|
938
|
+
const ctxPayload = eventPlan.finalizeContext({
|
|
939
|
+
Body: commandText,
|
|
940
|
+
BodyForAgent: commandText,
|
|
941
|
+
RawBody: commandText,
|
|
942
|
+
CommandBody: commandText,
|
|
943
|
+
ConversationLabel: fromLabel,
|
|
944
|
+
GroupSubject: kind !== "direct" ? channelDisplay || roomLabel : void 0,
|
|
945
|
+
SenderName: params.userName,
|
|
946
|
+
MessageSid: messageSid,
|
|
947
|
+
Timestamp: Date.now(),
|
|
948
|
+
WasMentioned: true,
|
|
949
|
+
CommandAuthorized: auth.commandAuthorized,
|
|
950
|
+
CommandSource: "native"
|
|
951
|
+
});
|
|
952
|
+
const { replyOptions, replyPipeline, tableMode, textLimit } = eventPlan.createReplyPlan();
|
|
953
|
+
await core.channel.inbound.dispatch({
|
|
954
|
+
cfg,
|
|
955
|
+
channel: "mattermost",
|
|
956
|
+
accountId: account.accountId,
|
|
957
|
+
route: {
|
|
958
|
+
agentId: route.agentId,
|
|
959
|
+
dmScope: route.dmScope,
|
|
960
|
+
sessionKey: thread.sessionKey
|
|
961
|
+
},
|
|
962
|
+
ctxPayload,
|
|
963
|
+
delivery: {
|
|
964
|
+
observeMessageSent: true,
|
|
965
|
+
deliver: async (payload) => {
|
|
966
|
+
const trimmedPayload = {
|
|
967
|
+
...payload,
|
|
968
|
+
text: core.channel.text.convertMarkdownTables(payload.text ?? "", tableMode).trim()
|
|
969
|
+
};
|
|
970
|
+
return await deliverMattermostReplyPayload({
|
|
971
|
+
core,
|
|
972
|
+
cfg,
|
|
973
|
+
payload: trimmedPayload,
|
|
974
|
+
channelId,
|
|
975
|
+
accountId: account.accountId,
|
|
976
|
+
agentId: route.agentId,
|
|
977
|
+
replyToId: resolveMattermostInteractionReplyRootId({
|
|
978
|
+
kind,
|
|
979
|
+
threadRootId: thread.effectiveReplyToId,
|
|
980
|
+
replyToId: trimmedPayload.replyToId,
|
|
981
|
+
interactionMessageSid: messageSid,
|
|
982
|
+
sourcePostId
|
|
983
|
+
}),
|
|
984
|
+
textLimit,
|
|
985
|
+
tableMode: "off",
|
|
986
|
+
sendMessage: sendMessageMattermost
|
|
987
|
+
});
|
|
988
|
+
},
|
|
989
|
+
onError: (err, info) => {
|
|
990
|
+
runtime.error?.(`mattermost model picker ${info.kind} reply failed: ${String(err)}`);
|
|
991
|
+
}
|
|
992
|
+
},
|
|
993
|
+
replyPipeline,
|
|
994
|
+
replyOptions
|
|
1039
995
|
});
|
|
1040
996
|
const currentModel = resolveMattermostModelPickerCurrentModel({
|
|
1041
997
|
cfg,
|
|
@@ -1475,19 +1431,6 @@ function consumeMattermostPublishedChunk(params) {
|
|
|
1475
1431
|
while (offset < params.source.length && /\s/.test(params.source[offset] ?? "")) offset += 1;
|
|
1476
1432
|
return params.source.startsWith(chunk, offset) ? offset + chunk.length : void 0;
|
|
1477
1433
|
}
|
|
1478
|
-
function createMattermostDraftPreviewBoundaryController(params) {
|
|
1479
|
-
let hasStreamedContent = false;
|
|
1480
|
-
return {
|
|
1481
|
-
noteUpdate() {
|
|
1482
|
-
hasStreamedContent = true;
|
|
1483
|
-
},
|
|
1484
|
-
async noteBoundary() {
|
|
1485
|
-
if (!params.enabled || !hasStreamedContent) return;
|
|
1486
|
-
hasStreamedContent = false;
|
|
1487
|
-
await params.forceNewMessage();
|
|
1488
|
-
}
|
|
1489
|
-
};
|
|
1490
|
-
}
|
|
1491
1434
|
function createMattermostDraftStream(params) {
|
|
1492
1435
|
const maxChars = Math.min(params.maxChars ?? MATTERMOST_STREAM_MAX_CHARS, MATTERMOST_STREAM_MAX_CHARS);
|
|
1493
1436
|
const throttleMs = Math.max(250, params.throttleMs ?? DEFAULT_THROTTLE_MS);
|
|
@@ -1694,8 +1637,8 @@ function createMattermostDraftStream(params) {
|
|
|
1694
1637
|
};
|
|
1695
1638
|
let remainingText = text.trim();
|
|
1696
1639
|
for (const sealedText of sealedAssistantTexts) {
|
|
1697
|
-
const completed = sealedText.text
|
|
1698
|
-
if (!
|
|
1640
|
+
const completed = sealedText.text;
|
|
1641
|
+
if (!remainingText.startsWith(completed)) return {
|
|
1699
1642
|
kind: "full",
|
|
1700
1643
|
text,
|
|
1701
1644
|
publishedParts
|
|
@@ -1876,27 +1819,6 @@ async function hasMattermostThreadParticipationWithPersistence(params) {
|
|
|
1876
1819
|
}
|
|
1877
1820
|
//#endregion
|
|
1878
1821
|
//#region extensions/mattermost/src/mattermost/monitor-turn.ts
|
|
1879
|
-
function createDisabledMattermostDraftStream() {
|
|
1880
|
-
const noopAsync = async () => {};
|
|
1881
|
-
return {
|
|
1882
|
-
update: () => {},
|
|
1883
|
-
updateAssistantText: () => {},
|
|
1884
|
-
flush: noopAsync,
|
|
1885
|
-
postId: () => void 0,
|
|
1886
|
-
clear: noopAsync,
|
|
1887
|
-
deleteCurrentMessage: noopAsync,
|
|
1888
|
-
discardPending: noopAsync,
|
|
1889
|
-
seal: noopAsync,
|
|
1890
|
-
stop: noopAsync,
|
|
1891
|
-
forceNewMessage: noopAsync,
|
|
1892
|
-
settleBoundaries: noopAsync,
|
|
1893
|
-
resolveFinalText: (text) => ({
|
|
1894
|
-
kind: "full",
|
|
1895
|
-
text,
|
|
1896
|
-
publishedParts: []
|
|
1897
|
-
})
|
|
1898
|
-
};
|
|
1899
|
-
}
|
|
1900
1822
|
async function dispatchMattermostInboundTurn(monitor, params) {
|
|
1901
1823
|
const { account, cfg, client, core, runtime } = monitor;
|
|
1902
1824
|
const { channelHistories, ctxPayload, eventPlan, historyKey, historyLimit, pinnedMainDmOwner, post, rawText, turnAdoptionLifecycle } = params;
|
|
@@ -1922,11 +1844,8 @@ async function dispatchMattermostInboundTurn(monitor, params) {
|
|
|
1922
1844
|
chunkText: (value) => core.channel.text.chunkMarkdownTextWithMode(core.channel.text.convertMarkdownTables(value, tableMode), textLimit, chunkMode),
|
|
1923
1845
|
log: monitor.logVerboseMessage,
|
|
1924
1846
|
warn: monitor.logVerboseMessage
|
|
1925
|
-
}) :
|
|
1926
|
-
|
|
1927
|
-
enabled: draftPreviewEnabled && account.streamingMode === "block",
|
|
1928
|
-
forceNewMessage: draftStream.forceNewMessage
|
|
1929
|
-
});
|
|
1847
|
+
}) : void 0;
|
|
1848
|
+
let hasStreamedPreview = false;
|
|
1930
1849
|
let lastPartialText = "";
|
|
1931
1850
|
let firstAssistantPreviewPrefix;
|
|
1932
1851
|
let firstAssistantPreviewPrefixPending = true;
|
|
@@ -1941,17 +1860,21 @@ async function dispatchMattermostInboundTurn(monitor, params) {
|
|
|
1941
1860
|
seed: `${account.accountId}:${channelId}`,
|
|
1942
1861
|
shouldStartNow: (line) => typeof line === "object" && line.kind === "item",
|
|
1943
1862
|
update: async (previewText, options) => {
|
|
1944
|
-
draftStream
|
|
1945
|
-
if (options?.flush) await draftStream
|
|
1863
|
+
draftStream?.update(previewText);
|
|
1864
|
+
if (options?.flush) await draftStream?.flush();
|
|
1946
1865
|
},
|
|
1947
|
-
deleteCurrent: () => draftStream
|
|
1866
|
+
deleteCurrent: () => draftStream?.deleteCurrentMessage()
|
|
1948
1867
|
});
|
|
1949
1868
|
const enterBlockPreviewActivity = (activity) => {
|
|
1950
1869
|
if (account.streamingMode !== "block") return;
|
|
1951
1870
|
const continuesCurrentActivity = activity === "tool" && blockPreviewActivity === "tool" || activity === "text" && blockPreviewActivity === "text" && !blockPreviewAssistantMessagePending || activity === "reasoning" && blockPreviewActivity === "reasoning";
|
|
1952
1871
|
const startsNewGeneration = !continuesCurrentActivity && blockPreviewActivity !== "reasoning";
|
|
1953
1872
|
if (startsNewGeneration) currentAssistantPreviewUsesPrefix = false;
|
|
1954
|
-
|
|
1873
|
+
let boundarySettled;
|
|
1874
|
+
if (startsNewGeneration && draftStream && hasStreamedPreview) {
|
|
1875
|
+
hasStreamedPreview = false;
|
|
1876
|
+
boundarySettled = draftStream.forceNewMessage();
|
|
1877
|
+
}
|
|
1955
1878
|
if (!continuesCurrentActivity) progressDraft.resetActivity();
|
|
1956
1879
|
blockPreviewActivity = activity;
|
|
1957
1880
|
blockPreviewAssistantMessagePending = false;
|
|
@@ -1959,7 +1882,7 @@ async function dispatchMattermostInboundTurn(monitor, params) {
|
|
|
1959
1882
|
return boundarySettled;
|
|
1960
1883
|
};
|
|
1961
1884
|
const previewLifecycle = createLivePreviewLifecycle({
|
|
1962
|
-
draft:
|
|
1885
|
+
draft: draftStream ? {
|
|
1963
1886
|
flush: draftStream.flush,
|
|
1964
1887
|
id: draftStream.postId,
|
|
1965
1888
|
seal: draftStream.seal,
|
|
@@ -1971,7 +1894,12 @@ async function dispatchMattermostInboundTurn(monitor, params) {
|
|
|
1971
1894
|
onCleanupFailure: (err) => monitor.logVerboseMessage(`mattermost draft preview cleanup failed: ${String(err)}`)
|
|
1972
1895
|
});
|
|
1973
1896
|
const resolvePreviewFinalText = (text) => {
|
|
1974
|
-
const
|
|
1897
|
+
const finalText = typeof text === "string" ? text : "";
|
|
1898
|
+
const resolution = draftStream?.resolveFinalText(finalText) ?? {
|
|
1899
|
+
kind: "full",
|
|
1900
|
+
text: finalText,
|
|
1901
|
+
publishedParts: []
|
|
1902
|
+
};
|
|
1975
1903
|
const confirmedDelivery = resolution.publishedParts.length > 0 ? (() => {
|
|
1976
1904
|
const receipt = createMessageReceiptFromOutboundResults({
|
|
1977
1905
|
results: resolution.publishedParts.map((part) => ({
|
|
@@ -2025,8 +1953,8 @@ async function dispatchMattermostInboundTurn(monitor, params) {
|
|
|
2025
1953
|
currentAssistantPreviewUsesPrefix = Boolean(firstAssistantPreviewPrefix);
|
|
2026
1954
|
}
|
|
2027
1955
|
const previewText = currentAssistantPreviewUsesPrefix && firstAssistantPreviewPrefix ? cleaned.startsWith(firstAssistantPreviewPrefix) ? cleaned : `${firstAssistantPreviewPrefix} ${cleaned}` : cleaned;
|
|
2028
|
-
draftStream
|
|
2029
|
-
|
|
1956
|
+
draftStream?.updateAssistantText(previewText);
|
|
1957
|
+
hasStreamedPreview = true;
|
|
2030
1958
|
return boundarySettled;
|
|
2031
1959
|
};
|
|
2032
1960
|
const dispatcherOptions = {
|
|
@@ -2039,7 +1967,7 @@ async function dispatchMattermostInboundTurn(monitor, params) {
|
|
|
2039
1967
|
deliver: async (payloadEntry, info) => {
|
|
2040
1968
|
if (info.kind === "final") {
|
|
2041
1969
|
await enterBlockPreviewActivity("text");
|
|
2042
|
-
await draftStream
|
|
1970
|
+
await draftStream?.settleBoundaries();
|
|
2043
1971
|
}
|
|
2044
1972
|
let threadParticipationRecorded = false;
|
|
2045
1973
|
const markThreadParticipation = async () => {
|
|
@@ -2059,7 +1987,7 @@ async function dispatchMattermostInboundTurn(monitor, params) {
|
|
|
2059
1987
|
logVerboseMessage: monitor.logVerboseMessage,
|
|
2060
1988
|
recordThreadParticipation: markThreadParticipation,
|
|
2061
1989
|
deliverPayload: async (payloadToDeliver) => {
|
|
2062
|
-
const finalTextResolution = info.kind === "final" && !payloadToDeliver.isError && typeof payloadToDeliver.text === "string" ? draftStream
|
|
1990
|
+
const finalTextResolution = info.kind === "final" && !payloadToDeliver.isError && typeof payloadToDeliver.text === "string" ? draftStream?.resolveFinalText(payloadToDeliver.text) : void 0;
|
|
2063
1991
|
const resolvedPayload = finalTextResolution ? {
|
|
2064
1992
|
...payloadToDeliver,
|
|
2065
1993
|
text: finalTextResolution.kind === "already-delivered" ? "" : finalTextResolution.text
|
|
@@ -2181,8 +2109,8 @@ async function dispatchMattermostInboundTurn(monitor, params) {
|
|
|
2181
2109
|
if (account.streamingMode === "progress") return await progressDraft.pushReasoningProgress(payloadResult.text || "Thinking…", { snapshot: payloadResult.isReasoningSnapshot === true });
|
|
2182
2110
|
if (!lastPartialText) {
|
|
2183
2111
|
const boundarySettled = enterBlockPreviewActivity("reasoning");
|
|
2184
|
-
draftStream
|
|
2185
|
-
|
|
2112
|
+
draftStream?.update("Thinking…");
|
|
2113
|
+
hasStreamedPreview = true;
|
|
2186
2114
|
await boundarySettled;
|
|
2187
2115
|
}
|
|
2188
2116
|
return false;
|
|
@@ -2194,7 +2122,7 @@ async function dispatchMattermostInboundTurn(monitor, params) {
|
|
|
2194
2122
|
explanation: payloadValue.explanation,
|
|
2195
2123
|
explanationFormat: payloadValue.explanationFormat
|
|
2196
2124
|
});
|
|
2197
|
-
|
|
2125
|
+
hasStreamedPreview = true;
|
|
2198
2126
|
const [, visible] = await Promise.all([boundarySettled, progressSettled]);
|
|
2199
2127
|
return visible;
|
|
2200
2128
|
},
|
|
@@ -2204,7 +2132,7 @@ async function dispatchMattermostInboundTurn(monitor, params) {
|
|
|
2204
2132
|
if (payloadLocal.hideFromChannelProgress || payloadLocal.suppressChannelProgress) return progressDraft.pushItemEvent(payloadLocal);
|
|
2205
2133
|
const boundarySettled = enterBlockPreviewActivity("tool");
|
|
2206
2134
|
const progressSettled = progressDraft.pushItemEvent(payloadLocal);
|
|
2207
|
-
|
|
2135
|
+
hasStreamedPreview = true;
|
|
2208
2136
|
const [, visible] = await Promise.all([boundarySettled, progressSettled]);
|
|
2209
2137
|
return visible;
|
|
2210
2138
|
}
|
|
@@ -2214,7 +2142,7 @@ async function dispatchMattermostInboundTurn(monitor, params) {
|
|
|
2214
2142
|
});
|
|
2215
2143
|
} finally {
|
|
2216
2144
|
try {
|
|
2217
|
-
await draftStream
|
|
2145
|
+
await draftStream?.stop();
|
|
2218
2146
|
await previewLifecycle.cleanup();
|
|
2219
2147
|
} catch (err) {
|
|
2220
2148
|
monitor.logVerboseMessage(`mattermost draft preview cleanup failed: ${String(err)}`);
|
|
@@ -2278,7 +2206,7 @@ function createMattermostPostHandler(monitor) {
|
|
|
2278
2206
|
const rawText = normalizeOptionalString(rawPostText) ?? "";
|
|
2279
2207
|
const commandBody = normalizeMention(rawText, botUsername).trim();
|
|
2280
2208
|
const { effectiveReplyToId, sessionKey } = thread;
|
|
2281
|
-
const { envelopeOptions, previousTimestamp } =
|
|
2209
|
+
const { envelopeOptions, previousTimestamp } = await resolveInboundSessionEnvelopeContextAsync({
|
|
2282
2210
|
cfg,
|
|
2283
2211
|
agentId: route.agentId,
|
|
2284
2212
|
sessionKey
|
|
@@ -2473,7 +2401,7 @@ function createMattermostPostHandler(monitor) {
|
|
|
2473
2401
|
monitor.logVerboseMessage(`mattermost: drop message (empty body after normalization channel=${channelId} sender=${senderId} wasMentioned=${wasMentioned})`);
|
|
2474
2402
|
return;
|
|
2475
2403
|
}
|
|
2476
|
-
const bodyForAgent = bodyText || rawText
|
|
2404
|
+
const bodyForAgent = bodyText || rawText;
|
|
2477
2405
|
core.channel.activity.record({
|
|
2478
2406
|
channel: "mattermost",
|
|
2479
2407
|
accountId: account.accountId,
|
|
@@ -2743,48 +2671,31 @@ async function registerMattermostMonitorSlashCommands(params) {
|
|
|
2743
2671
|
}
|
|
2744
2672
|
//#endregion
|
|
2745
2673
|
//#region extensions/mattermost/src/mattermost/reconnect.ts
|
|
2746
|
-
/**
|
|
2747
|
-
* Reconnection loop with exponential backoff.
|
|
2748
|
-
*
|
|
2749
|
-
* Calls `connectFn` in a while loop. On normal resolve (connection closed),
|
|
2750
|
-
* the backoff resets. On thrown error (connection failed), the current delay is
|
|
2751
|
-
* used, then doubled for the next retry.
|
|
2752
|
-
* The loop exits when `abortSignal` fires.
|
|
2753
|
-
*/
|
|
2754
2674
|
async function runWithReconnect(connectFn, opts = {}) {
|
|
2755
2675
|
const { initialDelayMs = 2e3, maxDelayMs = 6e4 } = opts;
|
|
2756
2676
|
const jitterRatio = Math.max(0, opts.jitterRatio ?? 0);
|
|
2757
2677
|
const random = opts.random ?? Math.random;
|
|
2758
2678
|
let retryDelay = initialDelayMs;
|
|
2759
|
-
let attempt = 0;
|
|
2760
2679
|
while (!opts.abortSignal?.aborted) {
|
|
2761
|
-
let
|
|
2762
|
-
let error;
|
|
2680
|
+
let failed = false;
|
|
2763
2681
|
try {
|
|
2764
2682
|
await connectFn();
|
|
2765
2683
|
} catch (err) {
|
|
2766
2684
|
if (opts.abortSignal?.aborted) return;
|
|
2767
|
-
|
|
2768
|
-
error = err;
|
|
2685
|
+
failed = true;
|
|
2769
2686
|
opts.onError?.(err);
|
|
2770
2687
|
}
|
|
2771
2688
|
if (opts.abortSignal?.aborted) return;
|
|
2772
|
-
if (
|
|
2689
|
+
if (!failed) retryDelay = initialDelayMs;
|
|
2773
2690
|
const delayMs = withJitter(retryDelay, jitterRatio, random);
|
|
2774
|
-
if (!
|
|
2775
|
-
attempt,
|
|
2776
|
-
delayMs,
|
|
2777
|
-
outcome,
|
|
2778
|
-
error
|
|
2779
|
-
}) ?? true)) return;
|
|
2691
|
+
if (!failed && opts.reconnectAfterClose === false) return;
|
|
2780
2692
|
opts.onReconnect?.(delayMs);
|
|
2781
2693
|
try {
|
|
2782
2694
|
await setTimeout$1(delayMs, void 0, { signal: opts.abortSignal });
|
|
2783
2695
|
} catch (delayError) {
|
|
2784
2696
|
if (!opts.abortSignal?.aborted) throw delayError;
|
|
2785
2697
|
}
|
|
2786
|
-
if (
|
|
2787
|
-
attempt++;
|
|
2698
|
+
if (failed) retryDelay = Math.min(retryDelay * 2, maxDelayMs);
|
|
2788
2699
|
}
|
|
2789
2700
|
}
|
|
2790
2701
|
function withJitter(baseMs, jitterRatio, random) {
|
|
@@ -2841,7 +2752,7 @@ async function monitorMattermostProvider(opts = {}) {
|
|
|
2841
2752
|
}, {
|
|
2842
2753
|
abortSignal: opts.abortSignal,
|
|
2843
2754
|
jitterRatio: .2,
|
|
2844
|
-
|
|
2755
|
+
reconnectAfterClose: false,
|
|
2845
2756
|
onError: (err) => {
|
|
2846
2757
|
runtime.error?.(`mattermost: API auth failed: ${String(err)}`);
|
|
2847
2758
|
publishMattermostRecoveringStatus(opts.statusSink, err);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as getMattermostRuntime } from "./runtime-CNB4YGqJ.mjs";
|
|
2
|
-
import { n as normalizeMattermostAllowEntry, t as mattermostIngressIdentity } from "./ingress-identity-
|
|
2
|
+
import { n as normalizeMattermostAllowEntry, t as mattermostIngressIdentity } from "./ingress-identity-D6hxfxvo.mjs";
|
|
3
3
|
import { uniqueStrings } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
4
4
|
import { logInboundDrop } from "openclaw/plugin-sdk/channel-inbound";
|
|
5
5
|
import { resolveAllowlistMatchSimple } from "openclaw/plugin-sdk/allow-from";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { h as normalizeMattermostBaseUrl } from "./client-
|
|
1
|
+
import { h as normalizeMattermostBaseUrl } from "./client-tv20cXIL.mjs";
|
|
2
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";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { c as setInteractionSecret, n as buildButtonProps, o as resolveInteractionCallbackUrl } from "./interactions-
|
|
1
|
+
import { c as setInteractionSecret, n as buildButtonProps, o as resolveInteractionCallbackUrl } from "./interactions-AdorvrsQ.mjs";
|
|
2
2
|
import { n as getOptionalMattermostRuntime, t as getMattermostRuntime } from "./runtime-CNB4YGqJ.mjs";
|
|
3
|
-
import { a as createMattermostPost, b as uploadMattermostFile, c as fetchMattermostChannelByName, d as fetchMattermostUser, f as fetchMattermostUserByUsername, g as parseMattermostApiStatus, h as normalizeMattermostBaseUrl, i as createMattermostDirectChannelWithRetry, p as fetchMattermostUserTeams, r as createMattermostClient, s as fetchMattermostChannel, u as fetchMattermostMe } from "./client-
|
|
4
|
-
import { o as resolveMattermostTrustedChatKind, v as loadOutboundMediaFromUrl } from "./monitor-auth-
|
|
5
|
-
import { u as resolveMattermostAccount } from "./normalize-
|
|
3
|
+
import { a as createMattermostPost, b as uploadMattermostFile, c as fetchMattermostChannelByName, d as fetchMattermostUser, f as fetchMattermostUserByUsername, g as parseMattermostApiStatus, h as normalizeMattermostBaseUrl, i as createMattermostDirectChannelWithRetry, p as fetchMattermostUserTeams, r as createMattermostClient, s as fetchMattermostChannel, u as fetchMattermostMe } from "./client-tv20cXIL.mjs";
|
|
4
|
+
import { o as resolveMattermostTrustedChatKind, v as loadOutboundMediaFromUrl } from "./monitor-auth-ChM45AzT.mjs";
|
|
5
|
+
import { u as resolveMattermostAccount } from "./normalize-B0VHjEFE.mjs";
|
|
6
6
|
import { normalizeLowercaseStringOrEmpty, normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
7
7
|
import { createChannelPartialDeliveryError } from "openclaw/plugin-sdk/channel-inbound";
|
|
8
8
|
import { createMessageReceiptFromOutboundResults, listMessageReceiptPlatformIds } from "openclaw/plugin-sdk/channel-outbound";
|
|
@@ -211,16 +211,6 @@ async function resolveChannelIdByName(params) {
|
|
|
211
211
|
}
|
|
212
212
|
throw new Error(`Mattermost channel "#${name}" not found in any team the bot belongs to`);
|
|
213
213
|
}
|
|
214
|
-
function mergeDmRetryOptions(base, override) {
|
|
215
|
-
const merged = {
|
|
216
|
-
maxRetries: override?.maxRetries ?? base?.maxRetries,
|
|
217
|
-
initialDelayMs: override?.initialDelayMs ?? base?.initialDelayMs,
|
|
218
|
-
maxDelayMs: override?.maxDelayMs ?? base?.maxDelayMs,
|
|
219
|
-
timeoutMs: override?.timeoutMs ?? base?.timeoutMs,
|
|
220
|
-
onRetry: override?.onRetry
|
|
221
|
-
};
|
|
222
|
-
return Object.values(merged).some((value) => value !== void 0) ? merged : void 0;
|
|
223
|
-
}
|
|
224
214
|
async function resolveTargetChannelId(params) {
|
|
225
215
|
if (params.target.kind === "channel") return params.target.id;
|
|
226
216
|
if (params.target.kind === "channel-name") return await resolveChannelIdByName({
|
|
@@ -238,7 +228,6 @@ async function resolveTargetChannelId(params) {
|
|
|
238
228
|
const channel = await createMattermostDirectChannelWithRetry(params.client, [botUser.id, userId], {
|
|
239
229
|
...params.dmRetryOptions,
|
|
240
230
|
onRetry: (attempt, delayMs, error) => {
|
|
241
|
-
params.dmRetryOptions?.onRetry?.(attempt, delayMs, error);
|
|
242
231
|
params.logger?.warn?.(`DM channel creation retry ${attempt} after ${delayMs}ms: ${error.message}`);
|
|
243
232
|
}
|
|
244
233
|
});
|
|
@@ -264,7 +253,13 @@ async function resolveMattermostSendContext(to, opts) {
|
|
|
264
253
|
allowPrivateNetwork: account.config.network?.dangerouslyAllowPrivateNetwork === true,
|
|
265
254
|
assertRequestCurrent: opts.assertDirectAdapterHandoff
|
|
266
255
|
});
|
|
267
|
-
const
|
|
256
|
+
const retry = account.config.dmChannelRetry;
|
|
257
|
+
const dmRetryOptions = retry && {
|
|
258
|
+
maxRetries: retry.maxRetries,
|
|
259
|
+
initialDelayMs: retry.initialDelayMs,
|
|
260
|
+
maxDelayMs: retry.maxDelayMs,
|
|
261
|
+
timeoutMs: retry.timeoutMs
|
|
262
|
+
};
|
|
268
263
|
let channelId;
|
|
269
264
|
try {
|
|
270
265
|
const trimmedTo = normalizeOptionalString(to) ?? "";
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { t as getMattermostRuntime } from "./runtime-CNB4YGqJ.mjs";
|
|
2
|
-
import { n as normalizeCallbackPath, r as resolveCallbackHost, t as collectMattermostCallbackPaths } from "./callback-host-
|
|
3
|
-
import { r as createMattermostClient, s as fetchMattermostChannel, v as sendMattermostTyping } from "./client-
|
|
4
|
-
import { D as sendHttpRequestRejection, b as logTypingFailure, h as isRequestBodyLimitError, i as normalizeMattermostAllowList, l as buildPreparedModelsProviderData, p as createWebhookInFlightLimiter, t as authorizeMattermostCommandInvocation, x as readRequestBodyWithLimit } from "./monitor-auth-
|
|
5
|
-
import { a as resolveMattermostPresentation, i as requiresMattermostMediaUpload } from "./normalize-
|
|
6
|
-
import { t as sendMessageMattermost } from "./send-
|
|
2
|
+
import { n as normalizeCallbackPath, r as resolveCallbackHost, t as collectMattermostCallbackPaths } from "./callback-host-Bu2cmtfI.mjs";
|
|
3
|
+
import { r as createMattermostClient, s as fetchMattermostChannel, v as sendMattermostTyping } from "./client-tv20cXIL.mjs";
|
|
4
|
+
import { D as sendHttpRequestRejection, b as logTypingFailure, h as isRequestBodyLimitError, i as normalizeMattermostAllowList, l as buildPreparedModelsProviderData, p as createWebhookInFlightLimiter, t as authorizeMattermostCommandInvocation, x as readRequestBodyWithLimit } from "./monitor-auth-ChM45AzT.mjs";
|
|
5
|
+
import { a as resolveMattermostPresentation, i as requiresMattermostMediaUpload } from "./normalize-B0VHjEFE.mjs";
|
|
6
|
+
import { t as sendMessageMattermost } from "./send-BAUVI-1U.mjs";
|
|
7
7
|
import { createHash } from "node:crypto";
|
|
8
8
|
import { safeEqualSecret } from "openclaw/plugin-sdk/security-runtime";
|
|
9
9
|
import { asFiniteNumber, normalizeOptionalString, normalizeStringifiedOptionalString, readStringField } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
10
10
|
import { truncateUtf16Safe, truncateUtf8Prefix } from "openclaw/plugin-sdk/text-utility-runtime";
|
|
11
|
-
import { createAcceptedChannelDeliveryResult, createChannelPartialDeliveryError, isChannelPartialDeliveryError } from "openclaw/plugin-sdk/channel-inbound";
|
|
12
11
|
import { asDateTimestampMs, parseStrictInteger, resolveExpiresAtMsFromDurationMs } from "openclaw/plugin-sdk/number-runtime";
|
|
12
|
+
import { createChannelDeliveryAccumulator } from "openclaw/plugin-sdk/channel-outbound";
|
|
13
13
|
import { resolveStoredModelOverride } from "openclaw/plugin-sdk/command-auth-native";
|
|
14
14
|
import { deliverTextOrMediaReply, isReasoningReplyPayload, resolveSendableOutboundReplyParts } from "openclaw/plugin-sdk/reply-payload";
|
|
15
15
|
import { resolveGlobalMap } from "openclaw/plugin-sdk/global-singleton";
|
|
@@ -272,19 +272,6 @@ function splitModelRef(modelRef) {
|
|
|
272
272
|
function normalizePage(value) {
|
|
273
273
|
return Math.max(1, Math.floor(asFiniteNumber(value) ?? 1));
|
|
274
274
|
}
|
|
275
|
-
function paginateItems(items, page, pageSize = MODELS_PAGE_SIZE) {
|
|
276
|
-
const totalPages = Math.max(1, Math.ceil(items.length / pageSize));
|
|
277
|
-
const safePage = Math.max(1, Math.min(normalizePage(page), totalPages));
|
|
278
|
-
const start = (safePage - 1) * pageSize;
|
|
279
|
-
return {
|
|
280
|
-
items: items.slice(start, start + pageSize),
|
|
281
|
-
page: safePage,
|
|
282
|
-
totalPages,
|
|
283
|
-
hasPrev: safePage > 1,
|
|
284
|
-
hasNext: safePage < totalPages,
|
|
285
|
-
totalItems: items.length
|
|
286
|
-
};
|
|
287
|
-
}
|
|
288
275
|
function buildButton(params) {
|
|
289
276
|
const baseState = {
|
|
290
277
|
action: params.action,
|
|
@@ -306,9 +293,6 @@ function buildButton(params) {
|
|
|
306
293
|
}
|
|
307
294
|
};
|
|
308
295
|
}
|
|
309
|
-
function getProviderModels(data, provider) {
|
|
310
|
-
return [...data.byProvider.get(normalizeProviderId(provider)) ?? /* @__PURE__ */ new Set()].toSorted();
|
|
311
|
-
}
|
|
312
296
|
function formatCurrentModelLine(currentModel) {
|
|
313
297
|
const parsed = splitModelRef(currentModel);
|
|
314
298
|
if (!parsed) return "Current: default";
|
|
@@ -424,7 +408,7 @@ function renderMattermostProviderPickerView(params) {
|
|
|
424
408
|
}
|
|
425
409
|
function renderMattermostModelsPickerView(params) {
|
|
426
410
|
const provider = normalizeProviderId(params.provider);
|
|
427
|
-
const models =
|
|
411
|
+
const models = [...params.data.byProvider.get(provider) ?? []].toSorted();
|
|
428
412
|
const current = splitModelRef(params.currentModel);
|
|
429
413
|
if (models.length === 0) return {
|
|
430
414
|
text: [
|
|
@@ -438,8 +422,10 @@ function renderMattermostModelsPickerView(params) {
|
|
|
438
422
|
text: "Back to providers"
|
|
439
423
|
})]]
|
|
440
424
|
};
|
|
441
|
-
const
|
|
442
|
-
const
|
|
425
|
+
const totalPages = Math.ceil(models.length / MODELS_PAGE_SIZE);
|
|
426
|
+
const page = Math.min(normalizePage(params.page), totalPages);
|
|
427
|
+
const start = (page - 1) * MODELS_PAGE_SIZE;
|
|
428
|
+
const rows = models.slice(start, start + MODELS_PAGE_SIZE).map((model) => {
|
|
443
429
|
const isCurrent = current?.provider === provider && current?.model === model;
|
|
444
430
|
return [buildButton({
|
|
445
431
|
action: "select",
|
|
@@ -447,24 +433,24 @@ function renderMattermostModelsPickerView(params) {
|
|
|
447
433
|
text: isCurrent ? `${model} [current]` : model,
|
|
448
434
|
provider,
|
|
449
435
|
model,
|
|
450
|
-
page
|
|
436
|
+
page,
|
|
451
437
|
style: isCurrent ? "primary" : "default"
|
|
452
438
|
})];
|
|
453
439
|
});
|
|
454
440
|
const navRow = [];
|
|
455
|
-
if (page
|
|
441
|
+
if (page > 1) navRow.push(buildButton({
|
|
456
442
|
action: "list",
|
|
457
443
|
ownerUserId: params.ownerUserId,
|
|
458
444
|
text: "Prev",
|
|
459
445
|
provider,
|
|
460
|
-
page: page
|
|
446
|
+
page: page - 1
|
|
461
447
|
}));
|
|
462
|
-
if (page
|
|
448
|
+
if (page < totalPages) navRow.push(buildButton({
|
|
463
449
|
action: "list",
|
|
464
450
|
ownerUserId: params.ownerUserId,
|
|
465
451
|
text: "Next",
|
|
466
452
|
provider,
|
|
467
|
-
page: page
|
|
453
|
+
page: page + 1
|
|
468
454
|
}));
|
|
469
455
|
if (navRow.length > 0) rows.push(navRow);
|
|
470
456
|
rows.push([buildButton({
|
|
@@ -474,9 +460,9 @@ function renderMattermostModelsPickerView(params) {
|
|
|
474
460
|
})]);
|
|
475
461
|
return {
|
|
476
462
|
text: [
|
|
477
|
-
`Models (${provider}) - ${
|
|
463
|
+
`Models (${provider}) - ${models.length} available`,
|
|
478
464
|
formatCurrentModelLine(params.currentModel),
|
|
479
|
-
`Page ${page
|
|
465
|
+
`Page ${page}/${totalPages}`,
|
|
480
466
|
"Select a model to switch immediately."
|
|
481
467
|
].join("\n"),
|
|
482
468
|
buttons: rows
|
|
@@ -498,8 +484,10 @@ async function deliverMattermostReplyPayload(params) {
|
|
|
498
484
|
const reply = resolveSendableOutboundReplyParts(params.payload, { text: params.core.channel.text.convertMarkdownTables(presentation.text, params.tableMode) });
|
|
499
485
|
const mediaLocalRoots = getAgentScopedMediaLocalRoots(params.cfg, params.agentId);
|
|
500
486
|
const chunkMode = params.core.channel.text.resolveChunkMode(params.cfg, "mattermost", params.accountId);
|
|
501
|
-
const
|
|
502
|
-
|
|
487
|
+
const accepted = createChannelDeliveryAccumulator({
|
|
488
|
+
kind: reply.mediaUrls.length > 0 ? "media" : "text",
|
|
489
|
+
...params.replyToId ? { replyToId: params.replyToId } : {}
|
|
490
|
+
});
|
|
503
491
|
const sendAccepted = async (text, mediaUrl) => {
|
|
504
492
|
const result = await params.sendMessage(`channel:${params.channelId}`, text, {
|
|
505
493
|
cfg: params.cfg,
|
|
@@ -509,11 +497,10 @@ async function deliverMattermostReplyPayload(params) {
|
|
|
509
497
|
mediaLocalRoots
|
|
510
498
|
} : {},
|
|
511
499
|
...requiresMattermostMediaUpload(mediaUrl) ? { requireMediaUpload: true } : {},
|
|
512
|
-
...
|
|
500
|
+
...accepted.size === 0 && reply.mediaUrls.length < 2 && presentation.buttons.length ? { buttons: presentation.buttons } : {},
|
|
513
501
|
replyToId: params.replyToId
|
|
514
502
|
});
|
|
515
|
-
|
|
516
|
-
acceptedContents.push(result.content);
|
|
503
|
+
accepted.add({ receipt: result.receipt }, result.content);
|
|
517
504
|
};
|
|
518
505
|
let outcome;
|
|
519
506
|
try {
|
|
@@ -525,29 +512,11 @@ async function deliverMattermostReplyPayload(params) {
|
|
|
525
512
|
sendMedia: ({ mediaUrl, caption }) => sendAccepted(caption ?? "", mediaUrl)
|
|
526
513
|
});
|
|
527
514
|
} catch (error) {
|
|
528
|
-
|
|
529
|
-
if (results.length === 0 && failedPartial?.visibleReplySent !== true) throw error;
|
|
530
|
-
throw createChannelPartialDeliveryError(error, createAcceptedChannelDeliveryResult({
|
|
531
|
-
results: results.map((result) => ({ receipt: result.receipt })),
|
|
532
|
-
deliveryResults: failedPartial ? [failedPartial] : [],
|
|
533
|
-
kind: reply.mediaUrls.length > 0 ? "media" : "text",
|
|
534
|
-
...params.replyToId ? { replyToId: params.replyToId } : {},
|
|
535
|
-
content: joinMattermostVisibleContent([...acceptedContents, failedPartial?.content])
|
|
536
|
-
}));
|
|
515
|
+
throw accepted.partialError(error);
|
|
537
516
|
}
|
|
538
|
-
if (outcome === "empty") return {
|
|
539
|
-
outcome,
|
|
540
|
-
visibleReplySent: false,
|
|
541
|
-
suppression: { reason: "no_visible_result" }
|
|
542
|
-
};
|
|
543
517
|
return {
|
|
544
518
|
outcome,
|
|
545
|
-
...
|
|
546
|
-
results: results.map((result) => ({ receipt: result.receipt })),
|
|
547
|
-
kind: outcome,
|
|
548
|
-
...params.replyToId ? { replyToId: params.replyToId } : {},
|
|
549
|
-
content: joinMattermostVisibleContent(acceptedContents)
|
|
550
|
-
})
|
|
519
|
+
...accepted.result()
|
|
551
520
|
};
|
|
552
521
|
}
|
|
553
522
|
//#endregion
|
package/dist/api.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { t as buildButtonAttachments } from "./.setup/interactions-
|
|
2
|
-
import { r as isMattermostSenderAllowed } from "./.setup/monitor-auth-
|
|
1
|
+
import { t as buildButtonAttachments } from "./.setup/interactions-AdorvrsQ.mjs";
|
|
2
|
+
import { r as isMattermostSenderAllowed } from "./.setup/monitor-auth-ChM45AzT.mjs";
|
|
3
3
|
export { buildButtonAttachments, isMattermostSenderAllowed };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as mattermostSetupPlugin, t as mattermostPlugin } from "./.setup/channel-plugin-runtime-
|
|
1
|
+
import { n as mattermostSetupPlugin, t as mattermostPlugin } from "./.setup/channel-plugin-runtime-D-I6TTe4.mjs";
|
|
2
2
|
export { mattermostPlugin, mattermostSetupPlugin };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as mattermostPlugin } from "./.setup/channel-plugin-runtime-
|
|
1
|
+
import { t as mattermostPlugin } from "./.setup/channel-plugin-runtime-D-I6TTe4.mjs";
|
|
2
2
|
export { mattermostPlugin };
|
package/dist/gateway-auth-api.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as resolveMattermostGatewayAuthBypassPaths } from "./.setup/gateway-auth-bypass-
|
|
1
|
+
import { t as resolveMattermostGatewayAuthBypassPaths } from "./.setup/gateway-auth-bypass-Lf99Gilr.mjs";
|
|
2
2
|
export { resolveMattermostGatewayAuthBypassPaths as resolveGatewayAuthBypassPaths };
|
package/dist/policy-api.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { r as isMattermostSenderAllowed } from "./.setup/monitor-auth-
|
|
1
|
+
import { r as isMattermostSenderAllowed } from "./.setup/monitor-auth-ChM45AzT.mjs";
|
|
2
2
|
export { isMattermostSenderAllowed };
|
package/dist/setup-entry.js
CHANGED
|
@@ -4,7 +4,7 @@ import { fileURLToPath } from "node:url";
|
|
|
4
4
|
var setup_entry_default = defineBundledChannelSetupEntry({
|
|
5
5
|
importMetaUrl: import.meta.url,
|
|
6
6
|
plugin: {
|
|
7
|
-
specifier: fileURLToPath(new URL(".setup/channel-plugin-api-
|
|
7
|
+
specifier: fileURLToPath(new URL(".setup/channel-plugin-api-DHjqj_yu.mjs", import.meta.url).href),
|
|
8
8
|
exportName: "mattermostSetupPlugin"
|
|
9
9
|
},
|
|
10
10
|
secrets: {
|
package/dist/slash-route-api.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { i as registerSlashCommandRoute } from "./.setup/slash-state-
|
|
1
|
+
import { i as registerSlashCommandRoute } from "./.setup/slash-state-CaHXPR0j.mjs";
|
|
2
2
|
export { registerSlashCommandRoute };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openclaw/mattermost",
|
|
3
|
-
"version": "2026.10.2",
|
|
3
|
+
"version": "2026.10.5-beta.2",
|
|
4
4
|
"description": "OpenClaw Mattermost channel plugin",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"zod": "4.6.5"
|
|
12
12
|
},
|
|
13
13
|
"peerDependencies": {
|
|
14
|
-
"openclaw": ">=2026.10.2"
|
|
14
|
+
"openclaw": ">=2026.10.5-beta.2"
|
|
15
15
|
},
|
|
16
16
|
"peerDependenciesMeta": {
|
|
17
17
|
"openclaw": {
|
|
@@ -93,10 +93,10 @@
|
|
|
93
93
|
"allowInvalidConfigRecovery": true
|
|
94
94
|
},
|
|
95
95
|
"compat": {
|
|
96
|
-
"pluginApi": ">=2026.10.2"
|
|
96
|
+
"pluginApi": ">=2026.10.5-beta.2"
|
|
97
97
|
},
|
|
98
98
|
"build": {
|
|
99
|
-
"openclawVersion": "2026.10.2",
|
|
99
|
+
"openclawVersion": "2026.10.5-beta.2",
|
|
100
100
|
"bundledDist": false
|
|
101
101
|
},
|
|
102
102
|
"release": {
|