@openclaw/mattermost 2026.10.10-beta.5 → 2026.11.5-beta.1
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-Bu2cmtfI.mjs → callback-host-CRQTeNn9.mjs} +1 -2
- package/dist/.setup/channel-plugin-api-C5kL5jd0.mjs +1 -0
- package/dist/.setup/{channel-plugin-runtime-BHcfJ_4v.mjs → channel-plugin-api-CC8EU4bs.mjs} +162 -159
- package/dist/.setup/{channel.runtime-C0yG8kgq.mjs → channel.runtime-ukouI9k4.mjs} +41 -45
- package/dist/.setup/{client-B_4C9q6z.mjs → client-CVipK0N2.mjs} +12 -86
- package/dist/.setup/{doctor-contract-CjgZkyPm.mjs → doctor-contract-i788N90j.mjs} +6 -11
- package/dist/.setup/{gateway-auth-bypass-Lf99Gilr.mjs → gateway-auth-bypass-DhWaV22L.mjs} +2 -3
- package/dist/.setup/{ingress-identity-D6hxfxvo.mjs → ingress-identity-CtHiOUDu.mjs} +0 -1
- package/dist/.setup/{interactions-CQcJYGsz.mjs → interactions-cgV9-piH.mjs} +33 -53
- package/dist/.setup/{monitor-DYEU-u6s.mjs → monitor-Bn-I4iu7.mjs} +313 -439
- package/dist/.setup/{monitor-auth-DYWeWEJ4.mjs → monitor-auth-D7Fl9CyF.mjs} +7 -12
- package/dist/.setup/{normalize-Dli2PK7k.mjs → normalize-DuLSV4tT.mjs} +23 -11
- package/dist/.setup/{rolldown-runtime-BBjsoOtd.mjs → rolldown-runtime-782esTHO.mjs} +1 -2
- package/dist/.setup/{runtime-CNB4YGqJ.mjs → runtime-y_L8jPMH.mjs} +1 -2
- package/dist/.setup/secret-contract-BkDCURCE.mjs +19 -0
- package/dist/.setup/{secret-contract-api-ChqAE2v-.mjs → secret-contract-api-DydsmAPQ.mjs} +1 -1
- package/dist/.setup/send-CoWXMKnY.mjs +300 -0
- package/dist/.setup/{slash-state-CDj8M2pP.mjs → slash-state-CwLVacYg.mjs} +367 -420
- package/dist/.source-module-urls/8fb0cb1067b83fd2cf3f3ba0f7a23e627c27e8e3adf1a4ea18753ddb884ff71e.json +1 -0
- package/dist/api.js +2 -2
- package/dist/channel-plugin-api.js +1 -1
- package/dist/doctor-contract-api.js +1 -1
- package/dist/gateway-auth-api.js +1 -1
- package/dist/index.js +1 -2
- package/dist/policy-api.js +1 -1
- package/dist/runtime-api.js +1 -1
- package/dist/secret-contract-api.js +1 -1
- package/dist/setup-entry.js +3 -4
- package/dist/slash-route-api.js +1 -1
- package/node_modules/zod/package.json +1 -1
- package/node_modules/zod/src/v4/classic/tests/array.test.ts +27 -0
- package/node_modules/zod/src/v4/classic/tests/map.test.ts +7 -0
- package/node_modules/zod/src/v4/classic/tests/set.test.ts +6 -0
- package/node_modules/zod/src/v4/core/compile.ts +9 -0
- package/node_modules/zod/src/v4/core/schemas.ts +35 -1
- package/node_modules/zod/src/v4/core/util.ts +13 -0
- package/node_modules/zod/src/v4/core/versions.ts +1 -1
- package/node_modules/zod/v4/core/compile.cjs +8 -0
- package/node_modules/zod/v4/core/compile.js +8 -0
- package/node_modules/zod/v4/core/schemas.cjs +30 -0
- package/node_modules/zod/v4/core/schemas.d.cts +3 -1
- package/node_modules/zod/v4/core/schemas.d.ts +3 -1
- package/node_modules/zod/v4/core/schemas.js +30 -0
- package/node_modules/zod/v4/core/util.cjs +15 -0
- package/node_modules/zod/v4/core/util.d.cts +2 -0
- package/node_modules/zod/v4/core/util.d.ts +2 -0
- package/node_modules/zod/v4/core/util.js +14 -0
- package/node_modules/zod/v4/core/versions.cjs +1 -1
- package/node_modules/zod/v4/core/versions.js +1 -1
- package/openclaw.plugin.json +172 -0
- package/package.json +5 -5
- package/dist/.setup/channel-plugin-api-Di7yxxmg.mjs +0 -2
- package/dist/.setup/secret-contract-qg3NXRlS.mjs +0 -12
- package/dist/.setup/send-1f6TWzMJ.mjs +0 -400
- package/dist/.source-module-urls/9b327bbbce22c2cbef393c115f9a63999afd57e223aad992389710cb3f1e29cc.json +0 -1
- package/dist/channel-plugin-runtime.js +0 -1
|
@@ -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 { s as resolveMattermostTrustedChatKind } from "./monitor-auth-
|
|
3
|
-
import {
|
|
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-CVipK0N2.mjs";
|
|
2
|
+
import { s as resolveMattermostTrustedChatKind } from "./monitor-auth-D7Fl9CyF.mjs";
|
|
3
|
+
import { d as resolveMattermostAccount, l as listMattermostAccountIds, n as normalizeMattermostMessagingTarget, s as inspectMattermostAccount } from "./normalize-DuLSV4tT.mjs";
|
|
4
|
+
import { n as resolveMattermostOpaqueTarget, t as sendMessageMattermost } from "./send-CoWXMKnY.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";
|
|
@@ -10,7 +10,7 @@ import { readProviderJsonResponse } from "openclaw/plugin-sdk/provider-http";
|
|
|
10
10
|
import { fetchWithSsrFGuard, ssrfPolicyFromPrivateNetworkOptIn } from "openclaw/plugin-sdk/ssrf-runtime";
|
|
11
11
|
import { resolveAllowlistProviderRuntimeGroupPolicy } from "openclaw/plugin-sdk/runtime-group-policy";
|
|
12
12
|
import { normalizeAccountId } from "openclaw/plugin-sdk/account-id";
|
|
13
|
-
|
|
13
|
+
// extensions/mattermost/src/mattermost/directory.ts
|
|
14
14
|
/** Build the requested account client, or aggregate accounts for an explicitly unscoped lookup. */
|
|
15
15
|
function buildClients(params) {
|
|
16
16
|
const requestedAccountId = params.accountId?.trim();
|
|
@@ -23,13 +23,19 @@ function buildClients(params) {
|
|
|
23
23
|
accountId: id
|
|
24
24
|
});
|
|
25
25
|
if (!account.enabled || !account.botToken || !account.baseUrl) continue;
|
|
26
|
+
const allowPrivateNetwork = account.config.network?.dangerouslyAllowPrivateNetwork === true;
|
|
26
27
|
const client = createMattermostClient({
|
|
27
28
|
baseUrl: account.baseUrl,
|
|
28
29
|
botToken: account.botToken,
|
|
29
|
-
allowPrivateNetwork
|
|
30
|
+
allowPrivateNetwork
|
|
30
31
|
});
|
|
31
|
-
|
|
32
|
-
|
|
32
|
+
const key = JSON.stringify([
|
|
33
|
+
client.baseUrl,
|
|
34
|
+
client.token,
|
|
35
|
+
allowPrivateNetwork
|
|
36
|
+
]);
|
|
37
|
+
if (!seen.has(key)) {
|
|
38
|
+
seen.add(key);
|
|
33
39
|
clients.push(client);
|
|
34
40
|
}
|
|
35
41
|
}
|
|
@@ -45,7 +51,7 @@ function buildClients(params) {
|
|
|
45
51
|
async function listMattermostDirectoryGroups(params) {
|
|
46
52
|
const clients = buildClients(params);
|
|
47
53
|
if (!clients.length) return [];
|
|
48
|
-
const q = normalizeLowercaseStringOrEmpty(params.query);
|
|
54
|
+
const q = normalizeLowercaseStringOrEmpty(params.query).normalize("NFC");
|
|
49
55
|
const seenIds = /* @__PURE__ */ new Set();
|
|
50
56
|
const entries = [];
|
|
51
57
|
for (const client of clients) try {
|
|
@@ -55,8 +61,8 @@ async function listMattermostDirectoryGroups(params) {
|
|
|
55
61
|
if (ch.type !== "O" && ch.type !== "P") continue;
|
|
56
62
|
if (seenIds.has(ch.id)) continue;
|
|
57
63
|
if (q) {
|
|
58
|
-
const name = normalizeLowercaseStringOrEmpty(ch.name);
|
|
59
|
-
const display = normalizeLowercaseStringOrEmpty(ch.display_name);
|
|
64
|
+
const name = normalizeLowercaseStringOrEmpty(ch.name).normalize("NFC");
|
|
65
|
+
const display = normalizeLowercaseStringOrEmpty(ch.display_name).normalize("NFC");
|
|
60
66
|
if (!name.includes(q) && !display.includes(q)) continue;
|
|
61
67
|
}
|
|
62
68
|
seenIds.add(ch.id);
|
|
@@ -129,8 +135,7 @@ async function listMattermostDirectoryPeers(params) {
|
|
|
129
135
|
return [];
|
|
130
136
|
}
|
|
131
137
|
}
|
|
132
|
-
|
|
133
|
-
//#region extensions/mattermost/src/mattermost/probe.ts
|
|
138
|
+
// extensions/mattermost/src/mattermost/probe.ts
|
|
134
139
|
async function probeMattermost(baseUrl, botToken, timeoutMs = 2500, allowPrivateNetwork = false) {
|
|
135
140
|
const normalized = normalizeMattermostBaseUrl(baseUrl);
|
|
136
141
|
if (!normalized) return {
|
|
@@ -175,8 +180,7 @@ async function probeMattermost(baseUrl, botToken, timeoutMs = 2500, allowPrivate
|
|
|
175
180
|
error: formatErrorMessage(error)
|
|
176
181
|
}));
|
|
177
182
|
}
|
|
178
|
-
|
|
179
|
-
//#region extensions/mattermost/src/mattermost/reactions.ts
|
|
183
|
+
// extensions/mattermost/src/mattermost/reactions.ts
|
|
180
184
|
const BOT_USER_CACHE_TTL_MS = 6e5;
|
|
181
185
|
const botUserIdCache = /* @__PURE__ */ new Map();
|
|
182
186
|
async function resolveBotUserId(client, cacheKey) {
|
|
@@ -219,23 +223,6 @@ function parseAuthorizedReactionTarget(rawTarget) {
|
|
|
219
223
|
}
|
|
220
224
|
return null;
|
|
221
225
|
}
|
|
222
|
-
async function authorizeMattermostReactionResource(params) {
|
|
223
|
-
const target = parseAuthorizedReactionTarget(params.authorizedTarget);
|
|
224
|
-
if (!target) throw new Error("Mattermost delegated reactions require a canonical authorized conversation target.");
|
|
225
|
-
const postChannelId = (await params.client.request(`/posts/${encodeURIComponent(params.postId)}`)).channel_id?.trim();
|
|
226
|
-
if (!postChannelId) throw new Error("Mattermost reaction post is missing its conversation binding.");
|
|
227
|
-
if (target.kind === "channel") {
|
|
228
|
-
if (postChannelId !== target.id) throw new Error("Mattermost reaction post belongs to a different conversation.");
|
|
229
|
-
return;
|
|
230
|
-
}
|
|
231
|
-
const botUserId = await resolveBotUserId(params.client, params.cacheKey);
|
|
232
|
-
if (!botUserId) throw new Error("Mattermost reactions failed: could not resolve bot user id.");
|
|
233
|
-
const channel = await fetchMattermostChannel(params.client, postChannelId);
|
|
234
|
-
const participants = channel.name?.split("__").map((entry) => entry.trim()).filter(Boolean).toSorted() ?? [];
|
|
235
|
-
const authorizedParticipants = [botUserId, target.id].toSorted();
|
|
236
|
-
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.");
|
|
237
|
-
return botUserId;
|
|
238
|
-
}
|
|
239
226
|
async function runMattermostReaction(params, action) {
|
|
240
227
|
const resolved = resolveMattermostAccount({
|
|
241
228
|
cfg: params.cfg,
|
|
@@ -250,17 +237,29 @@ async function runMattermostReaction(params, action) {
|
|
|
250
237
|
const client = createMattermostClient({
|
|
251
238
|
baseUrl,
|
|
252
239
|
botToken,
|
|
253
|
-
fetchImpl: params.fetchImpl,
|
|
254
240
|
allowPrivateNetwork: resolved.config.network?.dangerouslyAllowPrivateNetwork === true
|
|
255
241
|
});
|
|
256
242
|
const cacheKey = `${baseUrl}:${botToken}`;
|
|
257
243
|
try {
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
244
|
+
async function authorizeMattermostReactionResource() {
|
|
245
|
+
const { postId, authorizedTarget } = params;
|
|
246
|
+
const target = parseAuthorizedReactionTarget(authorizedTarget);
|
|
247
|
+
if (!target) throw new Error("Mattermost delegated reactions require a canonical authorized conversation target.");
|
|
248
|
+
const postChannelId = (await client.request(`/posts/${encodeURIComponent(postId)}`)).channel_id?.trim();
|
|
249
|
+
if (!postChannelId) throw new Error("Mattermost reaction post is missing its conversation binding.");
|
|
250
|
+
if (target.kind === "channel") {
|
|
251
|
+
if (postChannelId !== target.id) throw new Error("Mattermost reaction post belongs to a different conversation.");
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
254
|
+
const botUserId = await resolveBotUserId(client, cacheKey);
|
|
255
|
+
if (!botUserId) throw new Error("Mattermost reactions failed: could not resolve bot user id.");
|
|
256
|
+
const channel = await fetchMattermostChannel(client, postChannelId);
|
|
257
|
+
const participants = channel.name?.split("__").map((entry) => entry.trim()).filter(Boolean).toSorted() ?? [];
|
|
258
|
+
const authorizedParticipants = [botUserId, target.id].toSorted();
|
|
259
|
+
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.");
|
|
260
|
+
return botUserId;
|
|
261
|
+
}
|
|
262
|
+
const userId = (params.conversationReadOrigin === "direct-operator" ? void 0 : await authorizeMattermostReactionResource()) ?? await resolveBotUserId(client, cacheKey);
|
|
264
263
|
if (!userId) return {
|
|
265
264
|
ok: false,
|
|
266
265
|
error: "Mattermost reactions failed: could not resolve bot user id."
|
|
@@ -289,8 +288,7 @@ async function runMattermostReaction(params, action) {
|
|
|
289
288
|
}
|
|
290
289
|
return { ok: true };
|
|
291
290
|
}
|
|
292
|
-
|
|
293
|
-
//#region extensions/mattermost/src/mattermost/read.ts
|
|
291
|
+
// extensions/mattermost/src/mattermost/read.ts
|
|
294
292
|
function parseMattermostChannelTarget(rawTarget) {
|
|
295
293
|
const normalized = normalizeMattermostMessagingTarget(rawTarget);
|
|
296
294
|
if (normalized?.startsWith("channel:")) return normalized.slice(8).trim() || void 0;
|
|
@@ -300,9 +298,9 @@ function parseMattermostChannelTarget(rawTarget) {
|
|
|
300
298
|
function isCurrentMattermostReadTarget(params) {
|
|
301
299
|
const toolContext = params.context.toolContext;
|
|
302
300
|
const nativeChannelId = toolContext?.currentChannelId;
|
|
303
|
-
if (
|
|
301
|
+
if (nativeChannelId?.trim()) return parseMattermostChannelTarget(nativeChannelId) === params.channelId;
|
|
304
302
|
const messagingTarget = toolContext?.currentMessagingTarget;
|
|
305
|
-
return
|
|
303
|
+
return messagingTarget !== void 0 && Boolean(messagingTarget.trim()) && parseMattermostChannelTarget(messagingTarget) === params.channelId;
|
|
306
304
|
}
|
|
307
305
|
function isConfiguredMattermostReadTarget(params) {
|
|
308
306
|
const { groupPolicy } = resolveAllowlistProviderRuntimeGroupPolicy({
|
|
@@ -327,7 +325,6 @@ async function readMattermostMessages(params) {
|
|
|
327
325
|
const client = createMattermostClient({
|
|
328
326
|
baseUrl,
|
|
329
327
|
botToken,
|
|
330
|
-
fetchImpl: params.fetchImpl,
|
|
331
328
|
allowPrivateNetwork: account.config.network?.dangerouslyAllowPrivateNetwork === true
|
|
332
329
|
});
|
|
333
330
|
if (params.context.conversationReadOrigin !== "direct-operator") {
|
|
@@ -350,5 +347,4 @@ async function readMattermostMessages(params) {
|
|
|
350
347
|
after: params.after
|
|
351
348
|
});
|
|
352
349
|
}
|
|
353
|
-
//#endregion
|
|
354
350
|
export { addMattermostReaction, listMattermostDirectoryGroups, listMattermostDirectoryPeers, probeMattermost, readMattermostMessages, removeMattermostReaction, resolveMattermostOpaqueTarget, sendMessageMattermost };
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import { asOptionalObjectRecord, normalizeLowercaseStringOrEmpty, normalizeOptionalString, readStringField } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
2
2
|
import { bufferToBlobPart } from "openclaw/plugin-sdk/blob-runtime";
|
|
3
3
|
import { createChannelPartialDeliveryError } from "openclaw/plugin-sdk/channel-inbound";
|
|
4
|
-
import { PlatformMessageNotDispatchedError, collectErrorGraphCandidates
|
|
5
|
-
import {
|
|
6
|
-
import { captureChannelReadAuthority, captureEffectAuthority, responseWithRelease } from "openclaw/plugin-sdk/fetch-runtime";
|
|
4
|
+
import { PlatformMessageNotDispatchedError, collectErrorGraphCandidates } from "openclaw/plugin-sdk/error-runtime";
|
|
5
|
+
import { captureChannelReadAuthority, responseWithRelease } from "openclaw/plugin-sdk/fetch-runtime";
|
|
7
6
|
import { resolveTimerTimeoutMs } from "openclaw/plugin-sdk/number-runtime";
|
|
8
7
|
import { readProviderJsonResponse, redactProviderResponseErrorText } from "openclaw/plugin-sdk/provider-http";
|
|
9
8
|
import { readResponseTextPrefix, readResponseWithLimit } from "openclaw/plugin-sdk/response-limit-runtime";
|
|
10
|
-
import { retryAsync } from "openclaw/plugin-sdk/retry-runtime";
|
|
9
|
+
import { isTransientNetworkError, retryAsync } from "openclaw/plugin-sdk/retry-runtime";
|
|
11
10
|
import { fetchWithSsrFGuard, ssrfPolicyFromPrivateNetworkOptIn } from "openclaw/plugin-sdk/ssrf-runtime";
|
|
12
11
|
import { z } from "zod";
|
|
13
|
-
|
|
12
|
+
// extensions/mattermost/src/mattermost/client.ts
|
|
14
13
|
const MATTERMOST_ERROR_BODY_LIMIT_BYTES = 8192;
|
|
15
14
|
const MATTERMOST_REQUEST_TIMEOUT_MS = 3e4;
|
|
16
15
|
const MATTERMOST_TEXT_RESPONSE_LIMIT_BYTES = 65536;
|
|
@@ -83,7 +82,6 @@ function createMattermostClient(params) {
|
|
|
83
82
|
if (!baseUrl) throw new Error("Mattermost baseUrl is required");
|
|
84
83
|
const apiBaseUrl = `${baseUrl}/api/v4`;
|
|
85
84
|
const token = params.botToken.trim();
|
|
86
|
-
const requestTimeoutMs = resolveTimerTimeoutMs(params.timeoutMs, MATTERMOST_REQUEST_TIMEOUT_MS);
|
|
87
85
|
const assertSenderCurrent = params.assertRequestCurrent;
|
|
88
86
|
let postDispatchStarted = false;
|
|
89
87
|
const assertRequestCurrent = assertSenderCurrent ? () => {
|
|
@@ -98,14 +96,13 @@ function createMattermostClient(params) {
|
|
|
98
96
|
});
|
|
99
97
|
}
|
|
100
98
|
} : void 0;
|
|
101
|
-
const
|
|
102
|
-
const guardedFetchImpl = async (input, init) => {
|
|
99
|
+
const fetchImpl = async (input, init) => {
|
|
103
100
|
const assertReadAuthority = captureChannelReadAuthority();
|
|
104
101
|
assertReadAuthority?.();
|
|
105
102
|
assertRequestCurrent?.();
|
|
106
103
|
const url = typeof input === "string" ? input : input instanceof URL ? input.toString() : input.url;
|
|
107
104
|
const { timeoutMs: initTimeoutMs, isMessagePost, ...requestInit } = init ?? {};
|
|
108
|
-
const timeoutMs = resolveTimerTimeoutMs(initTimeoutMs,
|
|
105
|
+
const timeoutMs = resolveTimerTimeoutMs(initTimeoutMs, MATTERMOST_REQUEST_TIMEOUT_MS);
|
|
109
106
|
const { response, release } = await fetchWithSsrFGuard({
|
|
110
107
|
url,
|
|
111
108
|
init: requestInit,
|
|
@@ -121,37 +118,6 @@ function createMattermostClient(params) {
|
|
|
121
118
|
});
|
|
122
119
|
return responseWithRelease(response, release);
|
|
123
120
|
};
|
|
124
|
-
const fetchImpl = (externalFetchImpl ? async (input, init) => {
|
|
125
|
-
const effect = captureEffectAuthority();
|
|
126
|
-
const assertReadAuthority = captureChannelReadAuthority();
|
|
127
|
-
assertReadAuthority?.();
|
|
128
|
-
const url = typeof input === "string" ? input : input instanceof URL ? input.toString() : input.url;
|
|
129
|
-
const { timeoutMs: initTimeoutMs, isMessagePost, ...requestInit } = init ?? {};
|
|
130
|
-
const timeoutMs = resolveTimerTimeoutMs(initTimeoutMs, requestTimeoutMs);
|
|
131
|
-
const { signal: timeoutSignal, cleanup } = buildTimeoutAbortSignal({
|
|
132
|
-
timeoutMs,
|
|
133
|
-
operation: "mattermost-api",
|
|
134
|
-
url
|
|
135
|
-
});
|
|
136
|
-
const callerSignal = requestInit.signal ?? void 0;
|
|
137
|
-
const signal = callerSignal && timeoutSignal ? AbortSignal.any([callerSignal, timeoutSignal]) : callerSignal ?? timeoutSignal;
|
|
138
|
-
try {
|
|
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
|
-
});
|
|
148
|
-
});
|
|
149
|
-
return responseWithRelease(response, async () => cleanup());
|
|
150
|
-
} catch (error) {
|
|
151
|
-
cleanup();
|
|
152
|
-
throw error;
|
|
153
|
-
}
|
|
154
|
-
} : void 0) ?? guardedFetchImpl;
|
|
155
121
|
const request = async (path, init) => {
|
|
156
122
|
const url = buildMattermostApiUrl(baseUrl, path);
|
|
157
123
|
const { discardResponse, ...requestInit } = init ?? {};
|
|
@@ -238,31 +204,6 @@ async function sendMattermostTyping(client, params) {
|
|
|
238
204
|
discardResponse: true
|
|
239
205
|
});
|
|
240
206
|
}
|
|
241
|
-
const RETRYABLE_NETWORK_ERROR_CODES = /* @__PURE__ */ new Set([
|
|
242
|
-
"ECONNRESET",
|
|
243
|
-
"ECONNREFUSED",
|
|
244
|
-
"ETIMEDOUT",
|
|
245
|
-
"ESOCKETTIMEDOUT",
|
|
246
|
-
"ECONNABORTED",
|
|
247
|
-
"ENOTFOUND",
|
|
248
|
-
"EAI_AGAIN",
|
|
249
|
-
"EHOSTUNREACH",
|
|
250
|
-
"ENETUNREACH",
|
|
251
|
-
"EPIPE",
|
|
252
|
-
"UND_ERR_CONNECT_TIMEOUT",
|
|
253
|
-
"UND_ERR_DNS_RESOLVE_FAILED",
|
|
254
|
-
"UND_ERR_CONNECT",
|
|
255
|
-
"UND_ERR_SOCKET",
|
|
256
|
-
"UND_ERR_HEADERS_TIMEOUT",
|
|
257
|
-
"UND_ERR_BODY_TIMEOUT"
|
|
258
|
-
]);
|
|
259
|
-
const RETRYABLE_NETWORK_ERROR_NAMES = /* @__PURE__ */ new Set([
|
|
260
|
-
"AbortError",
|
|
261
|
-
"TimeoutError",
|
|
262
|
-
"ConnectTimeoutError",
|
|
263
|
-
"HeadersTimeoutError",
|
|
264
|
-
"BodyTimeoutError"
|
|
265
|
-
]);
|
|
266
207
|
const RETRYABLE_NETWORK_MESSAGE_SNIPPETS = [
|
|
267
208
|
"network error",
|
|
268
209
|
"timeout",
|
|
@@ -284,17 +225,11 @@ const RETRYABLE_NETWORK_MESSAGE_SNIPPETS = [
|
|
|
284
225
|
async function createMattermostDirectChannelWithRetry(client, userIds, options = {}) {
|
|
285
226
|
const { maxRetries = 3, initialDelayMs = 1e3, maxDelayMs = 1e4, timeoutMs: rawTimeoutMs = 3e4, onRetry } = options;
|
|
286
227
|
const timeoutMs = resolveTimerTimeoutMs(rawTimeoutMs, 3e4);
|
|
287
|
-
return await retryAsync(
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
timeoutMs
|
|
293
|
-
});
|
|
294
|
-
} catch (err) {
|
|
295
|
-
throw err instanceof Error ? err : new Error(String(err));
|
|
296
|
-
}
|
|
297
|
-
}, {
|
|
228
|
+
return await retryAsync(() => client.request("/channels/direct", {
|
|
229
|
+
method: "POST",
|
|
230
|
+
body: JSON.stringify(userIds),
|
|
231
|
+
timeoutMs
|
|
232
|
+
}), {
|
|
298
233
|
attempts: maxRetries + 1,
|
|
299
234
|
minDelayMs: Math.min(initialDelayMs, maxDelayMs),
|
|
300
235
|
maxDelayMs,
|
|
@@ -314,20 +249,12 @@ function isRetryableError(error) {
|
|
|
314
249
|
const status = parseMattermostApiStatus(candidate);
|
|
315
250
|
if (status !== void 0) return status === 429 || status >= 500 && status < 600;
|
|
316
251
|
}
|
|
317
|
-
if (
|
|
318
|
-
if (candidates.some((candidate) => RETRYABLE_NETWORK_ERROR_NAMES.has(readErrorName(candidate)))) return true;
|
|
252
|
+
if (isTransientNetworkError(error)) return true;
|
|
319
253
|
return candidates.some((candidate) => {
|
|
320
254
|
const message = normalizeLowercaseStringOrEmpty(readStringField(asOptionalObjectRecord(candidate), "message"));
|
|
321
255
|
return message.includes("too many requests") || RETRYABLE_NETWORK_MESSAGE_SNIPPETS.some((pattern) => message.includes(pattern));
|
|
322
256
|
});
|
|
323
257
|
}
|
|
324
|
-
function readErrorCode(error) {
|
|
325
|
-
if (!error || typeof error !== "object") return;
|
|
326
|
-
const { code, errno } = error;
|
|
327
|
-
const raw = typeof code === "string" && code.trim() ? code : errno;
|
|
328
|
-
if (typeof raw === "string" && raw.trim()) return raw.trim().toUpperCase();
|
|
329
|
-
if (typeof raw === "number" && Number.isFinite(raw)) return String(raw);
|
|
330
|
-
}
|
|
331
258
|
async function createMattermostPost(client, params) {
|
|
332
259
|
const payload = {
|
|
333
260
|
channel_id: params.channelId,
|
|
@@ -393,5 +320,4 @@ async function uploadMattermostFile(client, params) {
|
|
|
393
320
|
if (!info?.id) throw new Error("Mattermost file upload failed");
|
|
394
321
|
return info;
|
|
395
322
|
}
|
|
396
|
-
//#endregion
|
|
397
323
|
export { readMattermostError as _, createMattermostPost as a, uploadMattermostFile as b, fetchMattermostChannelByName as c, fetchMattermostUser as d, fetchMattermostUserByUsername as f, parseMattermostApiStatus as g, normalizeMattermostBaseUrl as h, createMattermostDirectChannelWithRetry as i, fetchMattermostChannelPosts as l, isRetryableError as m, buildMattermostApiUrl as n, deleteMattermostPost as o, fetchMattermostUserTeams as p, createMattermostClient as r, fetchMattermostChannel as s, MattermostPostSchema as t, fetchMattermostMe as u, sendMattermostTyping as v, updateMattermostPost as y };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { n as __reExport, t as __exportAll } from "./rolldown-runtime-
|
|
2
|
-
|
|
1
|
+
import { n as __reExport, t as __exportAll } from "./rolldown-runtime-782esTHO.mjs";
|
|
2
|
+
// packages/normalization-core/src/record-coerce.ts
|
|
3
3
|
/** Type guard for non-array object records at browser-safe boundaries. */
|
|
4
4
|
function isRecord(value) {
|
|
5
5
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
@@ -8,8 +8,7 @@ function isRecord(value) {
|
|
|
8
8
|
function asNullableRecord(value) {
|
|
9
9
|
return isRecord(value) ? value : null;
|
|
10
10
|
}
|
|
11
|
-
|
|
12
|
-
//#region src/config/channel-config-normalization.ts
|
|
11
|
+
// src/config/channel-config-normalization.ts
|
|
13
12
|
/** Applies one channel-specific doctor migration to every object-shaped account. */
|
|
14
13
|
function normalizeChannelAccounts(params) {
|
|
15
14
|
const rawAccounts = asNullableRecord(params.entry.accounts);
|
|
@@ -85,8 +84,7 @@ function normalizeChannelConfigEntries(params) {
|
|
|
85
84
|
changes
|
|
86
85
|
};
|
|
87
86
|
}
|
|
88
|
-
|
|
89
|
-
//#region src/plugin-sdk/legacy-webhook-listener-migration.ts
|
|
87
|
+
// src/plugin-sdk/legacy-webhook-listener-migration.ts
|
|
90
88
|
/** Preserve explicitly configured webhook listeners while moving ingress onto Gateway routes. */
|
|
91
89
|
function createLegacyWebhookListenerDoctorContract(params) {
|
|
92
90
|
const portKey = params.portKey ?? "webhookPort";
|
|
@@ -156,17 +154,14 @@ function createLegacyWebhookListenerDoctorContract(params) {
|
|
|
156
154
|
}
|
|
157
155
|
};
|
|
158
156
|
}
|
|
159
|
-
|
|
160
|
-
//#region \0openclaw:bundled-sdk:openclaw/plugin-sdk/runtime-doctor-migrations
|
|
157
|
+
// \0openclaw:bundled-sdk:openclaw/plugin-sdk/runtime-doctor-migrations
|
|
161
158
|
var runtime_doctor_migrations_exports = /* @__PURE__ */ __exportAll({ createLegacyWebhookListenerDoctorContract: () => createLegacyWebhookListenerDoctorContract });
|
|
162
159
|
import * as import_openclaw_plugin_sdk_runtime_doctor_migrations from "openclaw/plugin-sdk/runtime-doctor-migrations";
|
|
163
160
|
__reExport(runtime_doctor_migrations_exports, import_openclaw_plugin_sdk_runtime_doctor_migrations);
|
|
164
|
-
|
|
165
|
-
//#region extensions/mattermost/src/doctor-contract.ts
|
|
161
|
+
// extensions/mattermost/src/doctor-contract.ts
|
|
166
162
|
const { legacyConfigRules, normalizeChannelConfig: normalizeCompatibilityConfig } = (0, runtime_doctor_migrations_exports.defineChannelAliasMigration)({
|
|
167
163
|
channelId: "mattermost",
|
|
168
164
|
streaming: { defaultMode: "partial" },
|
|
169
165
|
accountStreamingReplacesRoot: true
|
|
170
166
|
});
|
|
171
|
-
//#endregion
|
|
172
167
|
export { normalizeCompatibilityConfig as n, legacyConfigRules as t };
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { t as collectMattermostCallbackPaths } from "./callback-host-
|
|
2
|
-
|
|
1
|
+
import { t as collectMattermostCallbackPaths } from "./callback-host-CRQTeNn9.mjs";
|
|
2
|
+
// 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/"));
|
|
5
5
|
}
|
|
6
|
-
//#endregion
|
|
7
6
|
export { resolveMattermostGatewayAuthBypassPaths as t };
|
|
@@ -22,5 +22,4 @@ function normalizeMattermostAllowEntry(entry) {
|
|
|
22
22
|
if (accessGroupName) return `accessGroup:${accessGroupName}`;
|
|
23
23
|
return normalizeLowercaseStringOrEmpty(trimmed.replace(/^(mattermost|user):/i, "").replace(/^@/, ""));
|
|
24
24
|
}
|
|
25
|
-
//#endregion
|
|
26
25
|
export { normalizeMattermostAllowEntry as n, mattermostIngressIdentity as t };
|