@openclaw/mattermost 2026.9.8 → 2026.10.1-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 +34 -0
- package/dist/.setup/channel-plugin-api-Cg4FPSIP.mjs +3 -0
- package/dist/.setup/{channel-plugin-runtime-B0CAMiHe.mjs → channel-plugin-runtime-BsHE7a2R.mjs} +191 -200
- package/dist/.setup/{channel.runtime-E2B5dNrh.mjs → channel.runtime-B_P0FgP2.mjs} +24 -36
- package/dist/.setup/{client-CVeeTqCO.mjs → client-f2qstbX3.mjs} +8 -13
- package/dist/.setup/{doctor-contract-BI6SB2cd.mjs → doctor-contract-CjgZkyPm.mjs} +7 -10
- package/dist/.setup/gateway-auth-bypass-CfqoieHq.mjs +7 -0
- package/dist/.setup/{interactions-DMSZYnEx.mjs → interactions-CfOLvzca.mjs} +10 -26
- package/dist/.setup/{monitor-BZyzPkkb.mjs → monitor-mV676oDI.mjs} +64 -93
- package/dist/.setup/{normalize-BCjtmxtp.mjs → normalize-DhF6_2lt.mjs} +2 -3
- package/dist/.setup/{send-ClgX-usq.mjs → send-BI4525Fd.mjs} +21 -53
- package/dist/.setup/{slash-state-Dni1XNc1.mjs → slash-state-BtvU3GNd.mjs} +23 -89
- package/dist/api.js +1 -1
- package/dist/channel-plugin-api.js +1 -2
- package/dist/channel-plugin-runtime.js +1 -1
- package/dist/doctor-contract-api.js +1 -1
- package/dist/gateway-auth-api.js +1 -1
- package/dist/runtime-api.js +1 -2
- package/dist/setup-entry.js +1 -1
- package/dist/slash-route-api.js +1 -1
- package/package.json +4 -4
- package/dist/.setup/channel-plugin-api-Bc8Qc1-t.mjs +0 -3
- package/dist/.setup/channel-plugin-api-DXqHarCt.mjs +0 -40
- package/dist/.setup/gateway-auth-bypass-B93t91oq.mjs +0 -36
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { asOptionalRecord, normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
2
|
+
//#region extensions/mattermost/src/mattermost/callback-host.ts
|
|
3
|
+
const DEFAULT_SLASH_CALLBACK_PATH = "/api/channels/mattermost/command";
|
|
4
|
+
function normalizeCallbackPath(value) {
|
|
5
|
+
const path = normalizeOptionalString(value) ?? DEFAULT_SLASH_CALLBACK_PATH;
|
|
6
|
+
return path.startsWith("/") ? path : `/${path}`;
|
|
7
|
+
}
|
|
8
|
+
/** Registration and the pre-plugin auth artifact must discover the same routes. */
|
|
9
|
+
function collectMattermostCallbackPaths(config) {
|
|
10
|
+
const base = asOptionalRecord(config);
|
|
11
|
+
const paths = /* @__PURE__ */ new Set();
|
|
12
|
+
for (const account of [base, ...Object.values(asOptionalRecord(base?.accounts) ?? {})]) {
|
|
13
|
+
const commands = asOptionalRecord(asOptionalRecord(account)?.commands);
|
|
14
|
+
paths.add(normalizeCallbackPath(commands?.callbackPath));
|
|
15
|
+
const callbackUrl = normalizeOptionalString(commands?.callbackUrl);
|
|
16
|
+
if (callbackUrl) try {
|
|
17
|
+
const path = new URL(callbackUrl).pathname;
|
|
18
|
+
if (path) paths.add(path);
|
|
19
|
+
} catch {}
|
|
20
|
+
}
|
|
21
|
+
return [...paths];
|
|
22
|
+
}
|
|
23
|
+
function isWildcardBindHost(rawHost) {
|
|
24
|
+
const trimmed = rawHost.trim();
|
|
25
|
+
if (!trimmed) return false;
|
|
26
|
+
const host = trimmed.startsWith("[") && trimmed.endsWith("]") ? trimmed.slice(1, -1) : trimmed;
|
|
27
|
+
return host === "0.0.0.0" || host === "::" || host === "0:0:0:0:0:0:0:0" || host === "::0";
|
|
28
|
+
}
|
|
29
|
+
function resolveCallbackHost(rawHost, trim = false) {
|
|
30
|
+
const host = rawHost && !isWildcardBindHost(rawHost) ? trim ? rawHost.trim() : rawHost : "localhost";
|
|
31
|
+
return host.includes(":") && !(host.startsWith("[") && host.endsWith("]")) ? `[${host}]` : host;
|
|
32
|
+
}
|
|
33
|
+
//#endregion
|
|
34
|
+
export { normalizeCallbackPath as n, resolveCallbackHost as r, collectMattermostCallbackPaths as t };
|
package/dist/.setup/{channel-plugin-runtime-B0CAMiHe.mjs → channel-plugin-runtime-BsHE7a2R.mjs}
RENAMED
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import { h as normalizeMattermostBaseUrl } from "./client-
|
|
1
|
+
import { h as normalizeMattermostBaseUrl } from "./client-f2qstbX3.mjs";
|
|
2
2
|
import { t as mattermostIngressIdentity } from "./ingress-identity-DNl4yQSc.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-
|
|
4
|
-
import { t as resolveMattermostGatewayAuthBypassPaths } from "./gateway-auth-bypass-
|
|
5
|
-
import { n as normalizeCompatibilityConfig, t as legacyConfigRules } from "./doctor-contract-
|
|
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-DhF6_2lt.mjs";
|
|
4
|
+
import { t as resolveMattermostGatewayAuthBypassPaths } from "./gateway-auth-bypass-CfqoieHq.mjs";
|
|
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
|
-
import { normalizeLowercaseStringOrEmpty, normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
7
|
+
import { asOptionalRecord, normalizeLowercaseStringOrEmpty, normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
8
8
|
import { buildPassiveProbedChannelStatusSummary } from "openclaw/plugin-sdk/extension-shared";
|
|
9
|
-
import { isPrivateNetworkOptInEnabled } from "openclaw/plugin-sdk/ssrf-runtime";
|
|
10
9
|
import { z } from "zod";
|
|
11
10
|
import { formatNormalizedAllowFromEntries } from "openclaw/plugin-sdk/allow-from";
|
|
12
11
|
import { createLoggedPairingApprovalNotifier } from "openclaw/plugin-sdk/channel-pairing";
|
|
@@ -25,6 +24,7 @@ import { createLazyRuntimeModule } from "openclaw/plugin-sdk/lazy-runtime";
|
|
|
25
24
|
import { resolvePayloadMediaUrls, sendTextMediaPayload } from "openclaw/plugin-sdk/reply-payload";
|
|
26
25
|
import { createComputedAccountStatusAdapter, createDefaultChannelRuntimeState } from "openclaw/plugin-sdk/status-helpers";
|
|
27
26
|
import { chunkTextForOutbound, sanitizeAssistantVisibleText } from "openclaw/plugin-sdk/text-chunking";
|
|
27
|
+
import { textResult } from "openclaw/plugin-sdk/tool-results";
|
|
28
28
|
import { createChannelApprovalAuth } from "openclaw/plugin-sdk/approval-auth-runtime";
|
|
29
29
|
import { buildSecretInputSchema, hasConfiguredSecretInput } from "openclaw/plugin-sdk/secret-input";
|
|
30
30
|
import { adaptScopedAccountAccessor, createScopedChannelConfigAdapter } from "openclaw/plugin-sdk/channel-config-helpers";
|
|
@@ -269,138 +269,6 @@ const mattermostChannelConfigUiHints = {
|
|
|
269
269
|
//#region extensions/mattermost/src/config-surface.ts
|
|
270
270
|
const MattermostChannelConfigSchema = buildChannelConfigSchema(MattermostConfigSchema, { uiHints: mattermostChannelConfigUiHints });
|
|
271
271
|
//#endregion
|
|
272
|
-
//#region extensions/mattermost/src/doctor.ts
|
|
273
|
-
const isMattermostMutableAllowEntry = buildMutableAllowEntryDetector({ stableIdPattern: /^(?:(?:mattermost|user):)?@?[a-z0-9]{26}$/i });
|
|
274
|
-
const collectMattermostMutableAllowlistWarnings = createDangerousNameMatchingMutableAllowlistWarningCollector({
|
|
275
|
-
channel: "mattermost",
|
|
276
|
-
detector: isMattermostMutableAllowEntry,
|
|
277
|
-
collectLists: collectStandardAllowlistLists
|
|
278
|
-
});
|
|
279
|
-
const mattermostDoctor = {
|
|
280
|
-
legacyConfigRules,
|
|
281
|
-
normalizeCompatibilityConfig,
|
|
282
|
-
collectMutableAllowlistWarnings: collectMattermostMutableAllowlistWarnings
|
|
283
|
-
};
|
|
284
|
-
//#endregion
|
|
285
|
-
//#region extensions/mattermost/src/group-mentions.ts
|
|
286
|
-
function resolveMattermostGroupRequireMention(params) {
|
|
287
|
-
const account = resolveMattermostAccount({
|
|
288
|
-
cfg: params.cfg,
|
|
289
|
-
accountId: params.accountId
|
|
290
|
-
});
|
|
291
|
-
return resolveScopeRequireMention({
|
|
292
|
-
tree: buildChannelGroupsScopeTree(params.cfg, "mattermost", params.accountId),
|
|
293
|
-
path: params.groupId ? [params.groupId] : [],
|
|
294
|
-
requireMentionOverride: params.requireMentionOverride ?? account.requireMention,
|
|
295
|
-
overrideOrder: "after-config"
|
|
296
|
-
});
|
|
297
|
-
}
|
|
298
|
-
//#endregion
|
|
299
|
-
//#region extensions/mattermost/src/mattermost/emoji.ts
|
|
300
|
-
const MATTERMOST_EMOJI_SHORTNAME_BY_GLYPH = {
|
|
301
|
-
"✅": "white_check_mark",
|
|
302
|
-
"❌": "x",
|
|
303
|
-
"👍": "thumbsup",
|
|
304
|
-
"👎": "thumbsdown",
|
|
305
|
-
"🎉": "tada",
|
|
306
|
-
"❤": "heart",
|
|
307
|
-
"😄": "smile",
|
|
308
|
-
"😂": "joy",
|
|
309
|
-
"🚀": "rocket",
|
|
310
|
-
"👀": "eyes",
|
|
311
|
-
"🙏": "pray",
|
|
312
|
-
"🔥": "fire",
|
|
313
|
-
"💯": "100",
|
|
314
|
-
"⚠": "warning",
|
|
315
|
-
"➕": "heavy_plus_sign",
|
|
316
|
-
"➖": "heavy_minus_sign",
|
|
317
|
-
"🤔": "thinking_face",
|
|
318
|
-
"⚡": "zap",
|
|
319
|
-
"🌐": "globe_with_meridians",
|
|
320
|
-
"😱": "scream",
|
|
321
|
-
"🧠": "brain",
|
|
322
|
-
"💻": "computer",
|
|
323
|
-
"👋": "wave",
|
|
324
|
-
"🙌": "raised_hands"
|
|
325
|
-
};
|
|
326
|
-
const MATTERMOST_EMOJI_TONE_CAPABLE_NAMES = /* @__PURE__ */ new Set([
|
|
327
|
-
"thumbsup",
|
|
328
|
-
"thumbsdown",
|
|
329
|
-
"pray",
|
|
330
|
-
"wave",
|
|
331
|
-
"raised_hands"
|
|
332
|
-
]);
|
|
333
|
-
const MATTERMOST_EMOJI_TONE_SUFFIX_BY_MODIFIER = /* @__PURE__ */ new Map([
|
|
334
|
-
["🏻", "light_skin_tone"],
|
|
335
|
-
["🏼", "medium_light_skin_tone"],
|
|
336
|
-
["🏽", "medium_skin_tone"],
|
|
337
|
-
["🏾", "medium_dark_skin_tone"],
|
|
338
|
-
["🏿", "dark_skin_tone"]
|
|
339
|
-
]);
|
|
340
|
-
const EMOJI_SKIN_TONE_MODIFIER_RE = /[\u{1F3FB}-\u{1F3FF}]/gu;
|
|
341
|
-
const EMOJI_VARIATION_SELECTOR_RE = /[\u{FE00}-\u{FE0F}]/gu;
|
|
342
|
-
function normalizeMattermostEmojiName(raw) {
|
|
343
|
-
const withoutColons = raw?.trim().replace(/^:+|:+$/g, "");
|
|
344
|
-
if (!withoutColons) return;
|
|
345
|
-
const toneModifier = withoutColons.match(EMOJI_SKIN_TONE_MODIFIER_RE)?.[0];
|
|
346
|
-
const glyphKey = withoutColons.replace(EMOJI_SKIN_TONE_MODIFIER_RE, "").replace(EMOJI_VARIATION_SELECTOR_RE, "");
|
|
347
|
-
const shortname = Object.hasOwn(MATTERMOST_EMOJI_SHORTNAME_BY_GLYPH, glyphKey) ? MATTERMOST_EMOJI_SHORTNAME_BY_GLYPH[glyphKey] : void 0;
|
|
348
|
-
if (shortname === void 0) return withoutColons;
|
|
349
|
-
const toneSuffix = toneModifier ? MATTERMOST_EMOJI_TONE_SUFFIX_BY_MODIFIER.get(toneModifier) : void 0;
|
|
350
|
-
if (!toneSuffix || !MATTERMOST_EMOJI_TONE_CAPABLE_NAMES.has(shortname)) return shortname;
|
|
351
|
-
return `${shortname}_${toneSuffix}`;
|
|
352
|
-
}
|
|
353
|
-
//#endregion
|
|
354
|
-
//#region extensions/mattermost/src/session-route.ts
|
|
355
|
-
/**
|
|
356
|
-
* Reads the peer chat-kind already recorded for `peerId` in an agent session
|
|
357
|
-
* key. Agent session keys are
|
|
358
|
-
* `agent:<agentId>:mattermost:<direct|group|channel>:<peerId>[:thread:...]`, so
|
|
359
|
-
* the segment right after `mattermost:` is the authoritative inbound chat kind.
|
|
360
|
-
*/
|
|
361
|
-
function mattermostSessionKeyPeerKind(sessionKey, peerId) {
|
|
362
|
-
if (!sessionKey || !peerId) return;
|
|
363
|
-
const match = /^agent:[^:]+:mattermost:(direct|group|channel):([^:]+)(?::thread:[^:]+)?$/i.exec(sessionKey);
|
|
364
|
-
const kind = match?.[1]?.toLowerCase();
|
|
365
|
-
if (!kind || match?.[2] !== peerId) return;
|
|
366
|
-
return kind;
|
|
367
|
-
}
|
|
368
|
-
function resolveMattermostOutboundSessionRoute(params) {
|
|
369
|
-
let trimmed = stripChannelTargetPrefix(params.target, "mattermost");
|
|
370
|
-
if (!trimmed) return null;
|
|
371
|
-
const lower = normalizeLowercaseStringOrEmpty(trimmed);
|
|
372
|
-
const resolvedKind = params.resolvedTarget?.kind;
|
|
373
|
-
const isUser = resolvedKind === "user" || resolvedKind !== "channel" && resolvedKind !== "group" && (lower.startsWith("user:") || trimmed.startsWith("@"));
|
|
374
|
-
if (trimmed.startsWith("@")) trimmed = trimmed.slice(1).trim();
|
|
375
|
-
const rawId = stripTargetKindPrefix(trimmed);
|
|
376
|
-
if (!rawId) return null;
|
|
377
|
-
const hasExplicitUserKind = resolvedKind === "user" || lower.startsWith("user:");
|
|
378
|
-
const recipientSessionExact = isUser && hasExplicitUserKind && /^[a-z0-9]{26}$/.test(rawId);
|
|
379
|
-
const isGroup = !isUser && (resolvedKind === "group" || resolvedKind !== "channel" && (lower.startsWith("group:") || mattermostSessionKeyPeerKind(params.currentSessionKey, rawId) === "group"));
|
|
380
|
-
const kind = isUser ? "direct" : isGroup ? "group" : "channel";
|
|
381
|
-
const baseRoute = buildChannelOutboundSessionRoute({
|
|
382
|
-
cfg: params.cfg,
|
|
383
|
-
agentId: params.agentId,
|
|
384
|
-
channel: "mattermost",
|
|
385
|
-
accountId: params.accountId,
|
|
386
|
-
recipientSessionExact,
|
|
387
|
-
peer: {
|
|
388
|
-
kind,
|
|
389
|
-
id: rawId
|
|
390
|
-
},
|
|
391
|
-
chatType: kind,
|
|
392
|
-
from: isUser ? `mattermost:${rawId}` : `mattermost:${kind}:${rawId}`,
|
|
393
|
-
to: isUser ? `user:${rawId}` : `channel:${rawId}`
|
|
394
|
-
});
|
|
395
|
-
return buildThreadAwareOutboundSessionRoute({
|
|
396
|
-
route: baseRoute,
|
|
397
|
-
replyToId: params.replyToId,
|
|
398
|
-
threadId: params.threadId,
|
|
399
|
-
currentSessionKey: params.currentSessionKey,
|
|
400
|
-
canRecoverCurrentThread: ({ route }) => route.chatType !== "direct" || (params.cfg.session?.dmScope ?? "main") !== "main"
|
|
401
|
-
});
|
|
402
|
-
}
|
|
403
|
-
//#endregion
|
|
404
272
|
//#region extensions/mattermost/src/setup-core.ts
|
|
405
273
|
const channel$1 = "mattermost";
|
|
406
274
|
function isMattermostConfigured(account) {
|
|
@@ -601,8 +469,176 @@ const mattermostSetupWizard = {
|
|
|
601
469
|
disable: (cfg) => setSetupChannelEnabled(cfg, channel, false)
|
|
602
470
|
};
|
|
603
471
|
//#endregion
|
|
472
|
+
//#region extensions/mattermost/src/channel.setup.ts
|
|
473
|
+
const mattermostSetupPlugin = {
|
|
474
|
+
id: "mattermost",
|
|
475
|
+
meta: { ...mattermostMeta },
|
|
476
|
+
capabilities: {
|
|
477
|
+
chatTypes: [
|
|
478
|
+
"direct",
|
|
479
|
+
"channel",
|
|
480
|
+
"group",
|
|
481
|
+
"thread"
|
|
482
|
+
],
|
|
483
|
+
reactions: true,
|
|
484
|
+
threads: true,
|
|
485
|
+
media: true,
|
|
486
|
+
nativeCommands: true
|
|
487
|
+
},
|
|
488
|
+
reload: {
|
|
489
|
+
configPrefixes: ["channels.mattermost"],
|
|
490
|
+
noopPrefixes: ["messages.inbound"],
|
|
491
|
+
/**
|
|
492
|
+
* accounts.default is promoted; named resolution merges only channel-wide fields
|
|
493
|
+
* plus the selected account. Runtime monitor, debounce, and ingress use accountId.
|
|
494
|
+
*/
|
|
495
|
+
accountScopedRestart: true
|
|
496
|
+
},
|
|
497
|
+
configSchema: MattermostChannelConfigSchema,
|
|
498
|
+
config: {
|
|
499
|
+
...mattermostConfigAdapter,
|
|
500
|
+
isConfigured: isMattermostConfigured$1,
|
|
501
|
+
describeAccount: describeMattermostAccount
|
|
502
|
+
},
|
|
503
|
+
gateway: { resolveGatewayAuthBypassPaths: resolveMattermostGatewayAuthBypassPaths },
|
|
504
|
+
setupContract: mattermostSetupContract,
|
|
505
|
+
setupWizard: mattermostSetupWizard
|
|
506
|
+
};
|
|
507
|
+
//#endregion
|
|
508
|
+
//#region extensions/mattermost/src/doctor.ts
|
|
509
|
+
const isMattermostMutableAllowEntry = buildMutableAllowEntryDetector({ stableIdPattern: /^(?:(?:mattermost|user):)?@?[a-z0-9]{26}$/i });
|
|
510
|
+
const collectMattermostMutableAllowlistWarnings = createDangerousNameMatchingMutableAllowlistWarningCollector({
|
|
511
|
+
channel: "mattermost",
|
|
512
|
+
detector: isMattermostMutableAllowEntry,
|
|
513
|
+
collectLists: collectStandardAllowlistLists
|
|
514
|
+
});
|
|
515
|
+
const mattermostDoctor = {
|
|
516
|
+
legacyConfigRules,
|
|
517
|
+
normalizeCompatibilityConfig,
|
|
518
|
+
collectMutableAllowlistWarnings: collectMattermostMutableAllowlistWarnings
|
|
519
|
+
};
|
|
520
|
+
//#endregion
|
|
521
|
+
//#region extensions/mattermost/src/group-mentions.ts
|
|
522
|
+
function resolveMattermostGroupRequireMention(params) {
|
|
523
|
+
const account = resolveMattermostAccount({
|
|
524
|
+
cfg: params.cfg,
|
|
525
|
+
accountId: params.accountId
|
|
526
|
+
});
|
|
527
|
+
return resolveScopeRequireMention({
|
|
528
|
+
tree: buildChannelGroupsScopeTree(params.cfg, "mattermost", params.accountId),
|
|
529
|
+
path: params.groupId ? [params.groupId] : [],
|
|
530
|
+
requireMentionOverride: params.requireMentionOverride ?? account.requireMention,
|
|
531
|
+
overrideOrder: "after-config"
|
|
532
|
+
});
|
|
533
|
+
}
|
|
534
|
+
//#endregion
|
|
535
|
+
//#region extensions/mattermost/src/mattermost/emoji.ts
|
|
536
|
+
const MATTERMOST_EMOJI_SHORTNAME_BY_GLYPH = {
|
|
537
|
+
"✅": "white_check_mark",
|
|
538
|
+
"❌": "x",
|
|
539
|
+
"👍": "thumbsup",
|
|
540
|
+
"👎": "thumbsdown",
|
|
541
|
+
"🎉": "tada",
|
|
542
|
+
"❤": "heart",
|
|
543
|
+
"😄": "smile",
|
|
544
|
+
"😂": "joy",
|
|
545
|
+
"🚀": "rocket",
|
|
546
|
+
"👀": "eyes",
|
|
547
|
+
"🙏": "pray",
|
|
548
|
+
"🔥": "fire",
|
|
549
|
+
"💯": "100",
|
|
550
|
+
"⚠": "warning",
|
|
551
|
+
"➕": "heavy_plus_sign",
|
|
552
|
+
"➖": "heavy_minus_sign",
|
|
553
|
+
"🤔": "thinking_face",
|
|
554
|
+
"⚡": "zap",
|
|
555
|
+
"🌐": "globe_with_meridians",
|
|
556
|
+
"😱": "scream",
|
|
557
|
+
"🧠": "brain",
|
|
558
|
+
"💻": "computer",
|
|
559
|
+
"👋": "wave",
|
|
560
|
+
"🙌": "raised_hands"
|
|
561
|
+
};
|
|
562
|
+
const MATTERMOST_EMOJI_TONE_CAPABLE_NAMES = /* @__PURE__ */ new Set([
|
|
563
|
+
"thumbsup",
|
|
564
|
+
"thumbsdown",
|
|
565
|
+
"pray",
|
|
566
|
+
"wave",
|
|
567
|
+
"raised_hands"
|
|
568
|
+
]);
|
|
569
|
+
const MATTERMOST_EMOJI_TONE_SUFFIX_BY_MODIFIER = /* @__PURE__ */ new Map([
|
|
570
|
+
["🏻", "light_skin_tone"],
|
|
571
|
+
["🏼", "medium_light_skin_tone"],
|
|
572
|
+
["🏽", "medium_skin_tone"],
|
|
573
|
+
["🏾", "medium_dark_skin_tone"],
|
|
574
|
+
["🏿", "dark_skin_tone"]
|
|
575
|
+
]);
|
|
576
|
+
const EMOJI_SKIN_TONE_MODIFIER_RE = /[\u{1F3FB}-\u{1F3FF}]/gu;
|
|
577
|
+
const EMOJI_VARIATION_SELECTOR_RE = /[\u{FE00}-\u{FE0F}]/gu;
|
|
578
|
+
function normalizeMattermostEmojiName(raw) {
|
|
579
|
+
const withoutColons = raw?.trim().replace(/^:+|:+$/g, "");
|
|
580
|
+
if (!withoutColons) return;
|
|
581
|
+
const toneModifier = withoutColons.match(EMOJI_SKIN_TONE_MODIFIER_RE)?.[0];
|
|
582
|
+
const glyphKey = withoutColons.replace(EMOJI_SKIN_TONE_MODIFIER_RE, "").replace(EMOJI_VARIATION_SELECTOR_RE, "");
|
|
583
|
+
const shortname = Object.hasOwn(MATTERMOST_EMOJI_SHORTNAME_BY_GLYPH, glyphKey) ? MATTERMOST_EMOJI_SHORTNAME_BY_GLYPH[glyphKey] : void 0;
|
|
584
|
+
if (shortname === void 0) return withoutColons;
|
|
585
|
+
const toneSuffix = toneModifier ? MATTERMOST_EMOJI_TONE_SUFFIX_BY_MODIFIER.get(toneModifier) : void 0;
|
|
586
|
+
if (!toneSuffix || !MATTERMOST_EMOJI_TONE_CAPABLE_NAMES.has(shortname)) return shortname;
|
|
587
|
+
return `${shortname}_${toneSuffix}`;
|
|
588
|
+
}
|
|
589
|
+
//#endregion
|
|
590
|
+
//#region extensions/mattermost/src/session-route.ts
|
|
591
|
+
/**
|
|
592
|
+
* Reads the peer chat-kind already recorded for `peerId` in an agent session
|
|
593
|
+
* key. Agent session keys are
|
|
594
|
+
* `agent:<agentId>:mattermost:<direct|group|channel>:<peerId>[:thread:...]`, so
|
|
595
|
+
* the segment right after `mattermost:` is the authoritative inbound chat kind.
|
|
596
|
+
*/
|
|
597
|
+
function mattermostSessionKeyPeerKind(sessionKey, peerId) {
|
|
598
|
+
if (!sessionKey || !peerId) return;
|
|
599
|
+
const match = /^agent:[^:]+:mattermost:(direct|group|channel):([^:]+)(?::thread:[^:]+)?$/i.exec(sessionKey);
|
|
600
|
+
const kind = match?.[1]?.toLowerCase();
|
|
601
|
+
if (!kind || match?.[2] !== peerId) return;
|
|
602
|
+
return kind;
|
|
603
|
+
}
|
|
604
|
+
function resolveMattermostOutboundSessionRoute(params) {
|
|
605
|
+
let trimmed = stripChannelTargetPrefix(params.target, "mattermost");
|
|
606
|
+
if (!trimmed) return null;
|
|
607
|
+
const lower = normalizeLowercaseStringOrEmpty(trimmed);
|
|
608
|
+
const resolvedKind = params.resolvedTarget?.kind;
|
|
609
|
+
const isUser = resolvedKind === "user" || resolvedKind !== "channel" && resolvedKind !== "group" && (lower.startsWith("user:") || trimmed.startsWith("@"));
|
|
610
|
+
if (trimmed.startsWith("@")) trimmed = trimmed.slice(1).trim();
|
|
611
|
+
const rawId = stripTargetKindPrefix(trimmed);
|
|
612
|
+
if (!rawId) return null;
|
|
613
|
+
const hasExplicitUserKind = resolvedKind === "user" || lower.startsWith("user:");
|
|
614
|
+
const recipientSessionExact = isUser && hasExplicitUserKind && /^[a-z0-9]{26}$/.test(rawId);
|
|
615
|
+
const isGroup = !isUser && (resolvedKind === "group" || resolvedKind !== "channel" && (lower.startsWith("group:") || mattermostSessionKeyPeerKind(params.currentSessionKey, rawId) === "group"));
|
|
616
|
+
const kind = isUser ? "direct" : isGroup ? "group" : "channel";
|
|
617
|
+
const baseRoute = buildChannelOutboundSessionRoute({
|
|
618
|
+
cfg: params.cfg,
|
|
619
|
+
agentId: params.agentId,
|
|
620
|
+
channel: "mattermost",
|
|
621
|
+
accountId: params.accountId,
|
|
622
|
+
recipientSessionExact,
|
|
623
|
+
peer: {
|
|
624
|
+
kind,
|
|
625
|
+
id: rawId
|
|
626
|
+
},
|
|
627
|
+
chatType: kind,
|
|
628
|
+
from: isUser ? `mattermost:${rawId}` : `mattermost:${kind}:${rawId}`,
|
|
629
|
+
to: isUser ? `user:${rawId}` : `channel:${rawId}`
|
|
630
|
+
});
|
|
631
|
+
return buildThreadAwareOutboundSessionRoute({
|
|
632
|
+
route: baseRoute,
|
|
633
|
+
replyToId: params.replyToId,
|
|
634
|
+
threadId: params.threadId,
|
|
635
|
+
currentSessionKey: params.currentSessionKey,
|
|
636
|
+
canRecoverCurrentThread: ({ route }) => route.chatType !== "direct" || (params.cfg.session?.dmScope ?? "main") !== "main"
|
|
637
|
+
});
|
|
638
|
+
}
|
|
639
|
+
//#endregion
|
|
604
640
|
//#region extensions/mattermost/src/channel.ts
|
|
605
|
-
const loadMattermostChannelRuntime = createLazyRuntimeModule(() => import("./channel.runtime-
|
|
641
|
+
const loadMattermostChannelRuntime = createLazyRuntimeModule(() => import("./channel.runtime-B_P0FgP2.mjs"));
|
|
606
642
|
const MATTERMOST_PRESENTATION_CAPABILITIES = {
|
|
607
643
|
supported: true,
|
|
608
644
|
buttons: true,
|
|
@@ -618,12 +654,7 @@ function hasMattermostPresentationNavigation(presentation) {
|
|
|
618
654
|
}));
|
|
619
655
|
}
|
|
620
656
|
function readMattermostPayloadData(payload) {
|
|
621
|
-
|
|
622
|
-
return data && typeof data === "object" && !Array.isArray(data) ? data : void 0;
|
|
623
|
-
}
|
|
624
|
-
function readMattermostPresentationButtons(payload) {
|
|
625
|
-
const buttons = readMattermostPayloadData(payload)?.presentationButtons;
|
|
626
|
-
return Array.isArray(buttons) ? buttons : void 0;
|
|
657
|
+
return asOptionalRecord(payload.channelData?.mattermost);
|
|
627
658
|
}
|
|
628
659
|
const mattermostSecurityAdapter = createRestrictSendersChannelSecurity({
|
|
629
660
|
channelKey: "mattermost",
|
|
@@ -815,13 +846,7 @@ const mattermostMessageActions = {
|
|
|
815
846
|
conversationReadOrigin
|
|
816
847
|
});
|
|
817
848
|
if (!result.ok) throw new Error(result.error);
|
|
818
|
-
return {
|
|
819
|
-
content: [{
|
|
820
|
-
type: "text",
|
|
821
|
-
text: remove ? `Removed reaction :${emojiName}: from ${postId}` : `Reacted with :${emojiName}: on ${postId}`
|
|
822
|
-
}],
|
|
823
|
-
details: {}
|
|
824
|
-
};
|
|
849
|
+
return textResult(remove ? `Removed reaction :${emojiName}: from ${postId}` : `Reacted with :${emojiName}: on ${postId}`, {});
|
|
825
850
|
}
|
|
826
851
|
};
|
|
827
852
|
function parseMattermostReactActionParams(params) {
|
|
@@ -858,7 +883,7 @@ function resolveMattermostSendAttachmentMedia(params) {
|
|
|
858
883
|
if (mediaUrls.length > 1) throw new Error("Mattermost send supports one attachment per message; split multiple mediaUrls or attachments[] entries into separate sends.");
|
|
859
884
|
return mediaUrls[0];
|
|
860
885
|
}
|
|
861
|
-
async function
|
|
886
|
+
async function sendMattermostContent(ctx, content = ctx) {
|
|
862
887
|
return toMattermostOutboundResult(await (await loadMattermostChannelRuntime()).sendMessageMattermost(ctx.to, content.text, {
|
|
863
888
|
cfg: ctx.cfg,
|
|
864
889
|
accountId: ctx.accountId ?? void 0,
|
|
@@ -911,15 +936,16 @@ const mattermostOutbound = {
|
|
|
911
936
|
};
|
|
912
937
|
},
|
|
913
938
|
sendPayload: async (ctx) => {
|
|
914
|
-
const
|
|
915
|
-
const
|
|
939
|
+
const mattermostData = readMattermostPayloadData(ctx.payload);
|
|
940
|
+
const buttons = Array.isArray(mattermostData?.presentationButtons) ? mattermostData.presentationButtons : void 0;
|
|
941
|
+
const rawAttachmentText = mattermostData?.attachmentText;
|
|
916
942
|
const attachmentText = typeof rawAttachmentText === "string" ? rawAttachmentText : void 0;
|
|
917
943
|
if (buttons?.length || attachmentText !== void 0) {
|
|
918
944
|
const mediaUrl = resolvePayloadMediaUrls({
|
|
919
945
|
...ctx.payload,
|
|
920
946
|
mediaUrl: ctx.payload.mediaUrl ?? ctx.mediaUrl
|
|
921
947
|
}).map((url) => url.trim()).find(Boolean);
|
|
922
|
-
const result = await
|
|
948
|
+
const result = await sendMattermostContent(ctx, {
|
|
923
949
|
text: ctx.payload.text ?? ctx.text,
|
|
924
950
|
mediaUrl,
|
|
925
951
|
buttons,
|
|
@@ -946,15 +972,8 @@ const mattermostOutbound = {
|
|
|
946
972
|
},
|
|
947
973
|
...createAttachedChannelResultAdapter({
|
|
948
974
|
channel: "mattermost",
|
|
949
|
-
sendText:
|
|
950
|
-
|
|
951
|
-
accountId: ctx.accountId ?? void 0,
|
|
952
|
-
replyToId: ctx.replyToId ?? (ctx.threadId != null ? String(ctx.threadId) : void 0),
|
|
953
|
-
assertDirectAdapterHandoff: ctx.assertDirectAdapterHandoff,
|
|
954
|
-
onPlatformSendDispatch: ctx.onPlatformSendDispatch,
|
|
955
|
-
onDeliveryResult: createMattermostDeliveryProgressReporter(ctx.onDeliveryResult)
|
|
956
|
-
})),
|
|
957
|
-
sendMedia: sendMattermostMedia
|
|
975
|
+
sendText: (ctx) => sendMattermostContent(ctx, { text: ctx.text }),
|
|
976
|
+
sendMedia: sendMattermostContent
|
|
958
977
|
})
|
|
959
978
|
};
|
|
960
979
|
const mattermostMessageAdapter = createChannelMessageAdapterFromOutbound({
|
|
@@ -975,41 +994,11 @@ const mattermostMessageAdapter = createChannelMessageAdapterFromOutbound({
|
|
|
975
994
|
});
|
|
976
995
|
const mattermostPlugin = createChatChannelPlugin({
|
|
977
996
|
base: {
|
|
978
|
-
|
|
979
|
-
meta: { ...mattermostMeta },
|
|
980
|
-
setupContract: mattermostSetupContract,
|
|
981
|
-
setupWizard: mattermostSetupWizard,
|
|
982
|
-
capabilities: {
|
|
983
|
-
chatTypes: [
|
|
984
|
-
"direct",
|
|
985
|
-
"channel",
|
|
986
|
-
"group",
|
|
987
|
-
"thread"
|
|
988
|
-
],
|
|
989
|
-
reactions: true,
|
|
990
|
-
threads: true,
|
|
991
|
-
media: true,
|
|
992
|
-
nativeCommands: true
|
|
993
|
-
},
|
|
997
|
+
...mattermostSetupPlugin,
|
|
994
998
|
streaming: { blockStreamingCoalesceDefaults: {
|
|
995
999
|
minChars: 1500,
|
|
996
1000
|
idleMs: 1e3
|
|
997
1001
|
} },
|
|
998
|
-
reload: {
|
|
999
|
-
configPrefixes: ["channels.mattermost"],
|
|
1000
|
-
noopPrefixes: ["messages.inbound"],
|
|
1001
|
-
/**
|
|
1002
|
-
* accounts.default is promoted; named resolution merges only channel-wide fields
|
|
1003
|
-
* plus the selected account. Monitor debounce and durable ingress use accountId.
|
|
1004
|
-
*/
|
|
1005
|
-
accountScopedRestart: true
|
|
1006
|
-
},
|
|
1007
|
-
configSchema: MattermostChannelConfigSchema,
|
|
1008
|
-
config: {
|
|
1009
|
-
...mattermostConfigAdapter,
|
|
1010
|
-
isConfigured: isMattermostConfigured$1,
|
|
1011
|
-
describeAccount: describeMattermostAccount
|
|
1012
|
-
},
|
|
1013
1002
|
approvalCapability: mattermostApprovalAuth,
|
|
1014
1003
|
doctor: mattermostDoctor,
|
|
1015
1004
|
groups: { resolveRequireMention: resolveMattermostGroupRequireMention },
|
|
@@ -1081,7 +1070,9 @@ const mattermostPlugin = createChatChannelPlugin({
|
|
|
1081
1070
|
ok: false,
|
|
1082
1071
|
error: "bot token or baseUrl missing"
|
|
1083
1072
|
};
|
|
1084
|
-
|
|
1073
|
+
const channelRuntime = await loadMattermostChannelRuntime();
|
|
1074
|
+
const allowPrivateNetwork = account.config.network?.dangerouslyAllowPrivateNetwork === true;
|
|
1075
|
+
return await channelRuntime.probeMattermost(baseUrl, token, timeoutMs, allowPrivateNetwork);
|
|
1085
1076
|
},
|
|
1086
1077
|
resolveAccountSnapshot: ({ account, runtime }) => ({
|
|
1087
1078
|
accountId: account.accountId,
|
|
@@ -1100,7 +1091,7 @@ const mattermostPlugin = createChatChannelPlugin({
|
|
|
1100
1091
|
})
|
|
1101
1092
|
}),
|
|
1102
1093
|
gateway: {
|
|
1103
|
-
|
|
1094
|
+
...mattermostSetupPlugin.gateway,
|
|
1104
1095
|
startAccount: async (ctx) => {
|
|
1105
1096
|
const account = ctx.account;
|
|
1106
1097
|
const statusSink = createAccountStatusSink({
|
|
@@ -1112,7 +1103,7 @@ const mattermostPlugin = createChatChannelPlugin({
|
|
|
1112
1103
|
botTokenSource: account.botTokenSource
|
|
1113
1104
|
});
|
|
1114
1105
|
ctx.log?.info(`[${account.accountId}] starting channel`);
|
|
1115
|
-
return (await import("./monitor-
|
|
1106
|
+
return (await import("./monitor-mV676oDI.mjs")).monitorMattermostProvider({
|
|
1116
1107
|
botToken: account.botToken ?? void 0,
|
|
1117
1108
|
baseUrl: account.baseUrl ?? void 0,
|
|
1118
1109
|
accountId: account.accountId,
|
|
@@ -1155,4 +1146,4 @@ const mattermostPlugin = createChatChannelPlugin({
|
|
|
1155
1146
|
outbound: mattermostOutbound
|
|
1156
1147
|
});
|
|
1157
1148
|
//#endregion
|
|
1158
|
-
export {
|
|
1149
|
+
export { mattermostSetupPlugin as n, mattermostPlugin as t };
|
|
@@ -1,28 +1,16 @@
|
|
|
1
|
-
import { _ as readMattermostError, h as normalizeMattermostBaseUrl, l as fetchMattermostChannelPosts, r as createMattermostClient, s as fetchMattermostChannel, u as fetchMattermostMe } from "./client-
|
|
1
|
+
import { _ as readMattermostError, h as normalizeMattermostBaseUrl, l as fetchMattermostChannelPosts, r as createMattermostClient, s as fetchMattermostChannel, u as fetchMattermostMe } from "./client-f2qstbX3.mjs";
|
|
2
2
|
import { o as resolveMattermostTrustedChatKind } from "./monitor-auth-aZ0b1gqx.mjs";
|
|
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-
|
|
3
|
+
import { c as listMattermostAccountIds, n as normalizeMattermostMessagingTarget, o as inspectMattermostAccount, u as resolveMattermostAccount } from "./normalize-DhF6_2lt.mjs";
|
|
4
|
+
import { n as resolveMattermostOpaqueTarget, t as sendMessageMattermost } from "./send-BI4525Fd.mjs";
|
|
5
5
|
import { normalizeLowercaseStringOrEmpty } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
6
|
+
import { runChannelProbe } from "openclaw/plugin-sdk/text-utility-runtime";
|
|
6
7
|
import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
|
|
7
8
|
import { asDateTimestampMs, resolveExpiresAtMsFromDurationMs, resolveTimerTimeoutMs } from "openclaw/plugin-sdk/number-runtime";
|
|
8
9
|
import { readProviderJsonResponse } from "openclaw/plugin-sdk/provider-http";
|
|
9
|
-
import { fetchWithSsrFGuard,
|
|
10
|
+
import { fetchWithSsrFGuard, ssrfPolicyFromPrivateNetworkOptIn } from "openclaw/plugin-sdk/ssrf-runtime";
|
|
10
11
|
import { resolveAllowlistProviderRuntimeGroupPolicy } from "openclaw/plugin-sdk/runtime-group-policy";
|
|
11
12
|
import { normalizeAccountId } from "openclaw/plugin-sdk/account-id";
|
|
12
|
-
import { runChannelProbe } from "openclaw/plugin-sdk/text-utility-runtime";
|
|
13
13
|
//#region extensions/mattermost/src/mattermost/directory.ts
|
|
14
|
-
function buildClient(params) {
|
|
15
|
-
const account = inspectMattermostAccount({
|
|
16
|
-
cfg: params.cfg,
|
|
17
|
-
accountId: params.accountId
|
|
18
|
-
});
|
|
19
|
-
if (!account.enabled || !account.botToken || !account.baseUrl) return null;
|
|
20
|
-
return createMattermostClient({
|
|
21
|
-
baseUrl: account.baseUrl,
|
|
22
|
-
botToken: account.botToken,
|
|
23
|
-
allowPrivateNetwork: isPrivateNetworkOptInEnabled(account.config)
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
14
|
/** Build the requested account client, or aggregate accounts for an explicitly unscoped lookup. */
|
|
27
15
|
function buildClients(params) {
|
|
28
16
|
const requestedAccountId = params.accountId?.trim();
|
|
@@ -30,11 +18,17 @@ function buildClients(params) {
|
|
|
30
18
|
const seen = /* @__PURE__ */ new Set();
|
|
31
19
|
const clients = [];
|
|
32
20
|
for (const id of accountIds) {
|
|
33
|
-
const
|
|
21
|
+
const account = inspectMattermostAccount({
|
|
34
22
|
cfg: params.cfg,
|
|
35
23
|
accountId: id
|
|
36
24
|
});
|
|
37
|
-
if (
|
|
25
|
+
if (!account.enabled || !account.botToken || !account.baseUrl) continue;
|
|
26
|
+
const client = createMattermostClient({
|
|
27
|
+
baseUrl: account.baseUrl,
|
|
28
|
+
botToken: account.botToken,
|
|
29
|
+
allowPrivateNetwork: account.config.network?.dangerouslyAllowPrivateNetwork === true
|
|
30
|
+
});
|
|
31
|
+
if (!seen.has(client.token)) {
|
|
38
32
|
seen.add(client.token);
|
|
39
33
|
clients.push(client);
|
|
40
34
|
}
|
|
@@ -267,7 +261,7 @@ async function runMattermostReaction(params, options) {
|
|
|
267
261
|
baseUrl,
|
|
268
262
|
botToken,
|
|
269
263
|
fetchImpl: params.fetchImpl,
|
|
270
|
-
allowPrivateNetwork:
|
|
264
|
+
allowPrivateNetwork: resolved.config.network?.dangerouslyAllowPrivateNetwork === true
|
|
271
265
|
});
|
|
272
266
|
const cacheKey = `${baseUrl}:${botToken}`;
|
|
273
267
|
try {
|
|
@@ -322,8 +316,6 @@ function parseMattermostChannelTarget(rawTarget) {
|
|
|
322
316
|
}
|
|
323
317
|
function isCurrentMattermostReadTarget(params) {
|
|
324
318
|
const toolContext = params.context.toolContext;
|
|
325
|
-
const requesterAccountId = params.context.requesterAccountId?.trim();
|
|
326
|
-
if (normalizeLowercaseStringOrEmpty(toolContext?.currentChannelProvider) !== "mattermost" || !requesterAccountId || normalizeAccountId(requesterAccountId) !== normalizeAccountId(params.accountId)) return false;
|
|
327
319
|
const nativeChannelId = toolContext?.currentChannelId;
|
|
328
320
|
if (typeof nativeChannelId === "string" && nativeChannelId.trim()) return parseMattermostChannelTarget(nativeChannelId) === params.channelId;
|
|
329
321
|
const messagingTarget = toolContext?.currentMessagingTarget;
|
|
@@ -353,25 +345,21 @@ async function readMattermostMessages(params) {
|
|
|
353
345
|
baseUrl,
|
|
354
346
|
botToken,
|
|
355
347
|
fetchImpl: params.fetchImpl,
|
|
356
|
-
allowPrivateNetwork:
|
|
357
|
-
});
|
|
358
|
-
const directOperator = params.context.conversationReadOrigin === "direct-operator";
|
|
359
|
-
const currentConversation = isCurrentMattermostReadTarget({
|
|
360
|
-
accountId: account.accountId,
|
|
361
|
-
channelId: params.channelId,
|
|
362
|
-
context: params.context
|
|
348
|
+
allowPrivateNetwork: account.config.network?.dangerouslyAllowPrivateNetwork === true
|
|
363
349
|
});
|
|
364
|
-
if (
|
|
350
|
+
if (params.context.conversationReadOrigin !== "direct-operator") {
|
|
365
351
|
const requesterAccountId = params.context.requesterAccountId?.trim();
|
|
366
352
|
const sameProvider = normalizeLowercaseStringOrEmpty(params.context.toolContext?.currentChannelProvider) === "mattermost";
|
|
367
353
|
const sameAccount = requesterAccountId && normalizeAccountId(requesterAccountId) === normalizeAccountId(account.accountId);
|
|
368
354
|
if (!sameProvider || !sameAccount) throw new Error("Mattermost delegated reads require the current Mattermost account.");
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
355
|
+
if (!isCurrentMattermostReadTarget(params)) {
|
|
356
|
+
const channel = await fetchMattermostChannel(client, params.channelId);
|
|
357
|
+
if (channel.type !== "O" && channel.type !== "P" || !isConfiguredMattermostReadTarget({
|
|
358
|
+
cfg: params.cfg,
|
|
359
|
+
account,
|
|
360
|
+
channelId: params.channelId
|
|
361
|
+
})) throw new Error("Mattermost read target channel is not allowed.");
|
|
362
|
+
}
|
|
375
363
|
}
|
|
376
364
|
return await fetchMattermostChannelPosts(client, params.channelId, {
|
|
377
365
|
limit: params.limit,
|