@openclaw/mattermost 2026.9.2 → 2026.9.3
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/channel-plugin-api.js +1 -1
- package/dist/{channel-plugin-runtime-Bq86sS1N.js → channel-plugin-runtime-C4u91PKh.js} +4 -1
- package/dist/channel-plugin-runtime.js +1 -1
- package/dist/{channel.runtime-B454n78J.js → channel.runtime-CGEfnc2y.js} +48 -43
- package/dist/slash-route-api.js +1 -1
- package/dist/{slash-state-njvQCdwt.js → slash-state-BjBTvP7u.js} +62 -104
- package/package.json +7 -4
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { o as isMattermostConfigured } from "./normalize-R-ATEEHC.js";
|
|
2
|
-
import { a as describeMattermostAccount, i as MattermostChannelConfigSchema, n as mattermostSetupWizard, o as mattermostConfigAdapter, r as mattermostSetupContract, s as mattermostMeta, t as mattermostPlugin } from "./channel-plugin-runtime-
|
|
2
|
+
import { a as describeMattermostAccount, i as MattermostChannelConfigSchema, n as mattermostSetupWizard, o as mattermostConfigAdapter, r as mattermostSetupContract, s as mattermostMeta, t as mattermostPlugin } from "./channel-plugin-runtime-C4u91PKh.js";
|
|
3
3
|
import { t as resolveMattermostGatewayAuthBypassPaths } from "./gateway-auth-bypass-B93t91oq.js";
|
|
4
4
|
//#region extensions/mattermost/src/channel.setup.ts
|
|
5
5
|
const mattermostSetupPlugin = {
|
|
@@ -431,7 +431,10 @@ function applyMattermostSetupConfigPatch(params) {
|
|
|
431
431
|
patch: params.patch
|
|
432
432
|
});
|
|
433
433
|
}
|
|
434
|
+
const accountCredentialKeys = ["botToken", "baseUrl"];
|
|
434
435
|
const mattermostSetupAdapter = {
|
|
436
|
+
singleAccountKeysToMove: accountCredentialKeys,
|
|
437
|
+
namedAccountPromotionKeys: accountCredentialKeys,
|
|
435
438
|
resolveAccountId: ({ accountId }) => normalizeAccountId(accountId),
|
|
436
439
|
applyAccountName: ({ cfg, accountId, name }) => applyAccountNameToChannelSection({
|
|
437
440
|
cfg,
|
|
@@ -594,7 +597,7 @@ const mattermostSetupWizard = {
|
|
|
594
597
|
};
|
|
595
598
|
//#endregion
|
|
596
599
|
//#region extensions/mattermost/src/channel.ts
|
|
597
|
-
const loadMattermostChannelRuntime = createLazyRuntimeModule(() => import("./channel.runtime-
|
|
600
|
+
const loadMattermostChannelRuntime = createLazyRuntimeModule(() => import("./channel.runtime-CGEfnc2y.js"));
|
|
598
601
|
const MATTERMOST_PRESENTATION_CAPABILITIES = {
|
|
599
602
|
supported: true,
|
|
600
603
|
buttons: true,
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as mattermostPlugin } from "./channel-plugin-runtime-
|
|
1
|
+
import { t as mattermostPlugin } from "./channel-plugin-runtime-C4u91PKh.js";
|
|
2
2
|
export { mattermostPlugin };
|
|
@@ -4,12 +4,13 @@ import { _ as sendMattermostTyping, a as createMattermostPost, d as fetchMatterm
|
|
|
4
4
|
import { C as resolveDefaultGroupPolicy, T as warnMissingProviderGroupPolicyFallbackOnce, _ as logTypingFailure, a as resolveMattermostMonitorInboundAccess, b as resolveAllowlistProviderRuntimeGroupPolicy$1, c as buildPreparedModelsProviderData, d as createChannelPairingController, g as logInboundDrop, l as createChannelHistoryWindow, m as listSkillCommandsForAgents, n as formatMattermostDirectMessageDropLog, o as resolveMattermostTrustedChatKind, s as DEFAULT_GROUP_HISTORY_LIMIT, t as authorizeMattermostCommandInvocation, u as createChannelMessageReplyPipeline, x as resolveChannelMediaMaxBytes, y as registerPluginHttpRoute } from "./monitor-auth-C6RGYyn-.js";
|
|
5
5
|
import { n as normalizeMattermostAllowEntry } from "./ingress-identity-DNl4yQSc.js";
|
|
6
6
|
import { a as inspectMattermostAccount, l as resolveMattermostAccount, n as normalizeMattermostMessagingTarget, s as listMattermostAccountIds, u as resolveMattermostReplyToMode } from "./normalize-R-ATEEHC.js";
|
|
7
|
-
import { _ as registerSlashCommands, a as sendMessageMattermost, c as joinMattermostVisibleContent, d as renderMattermostModelsPickerView, f as renderMattermostProviderPickerView, g as isSlashCommandsEnabled, h as cleanupSlashCommands, l as buildMattermostAllowedModelRefs, m as DEFAULT_COMMAND_SPECS, n as deactivateSlashCommands, o as resolveMattermostOpaqueTarget, p as resolveMattermostModelPickerCurrentModel, r as getSlashCommandState, s as deliverMattermostReplyPayload, t as activateSlashCommands, u as parseMattermostModelPickerContext, v as resolveCallbackUrl, y as resolveSlashCommandConfig } from "./slash-state-
|
|
7
|
+
import { _ as registerSlashCommands, a as sendMessageMattermost, c as joinMattermostVisibleContent, d as renderMattermostModelsPickerView, f as renderMattermostProviderPickerView, g as isSlashCommandsEnabled, h as cleanupSlashCommands, l as buildMattermostAllowedModelRefs, m as DEFAULT_COMMAND_SPECS, n as deactivateSlashCommands, o as resolveMattermostOpaqueTarget, p as resolveMattermostModelPickerCurrentModel, r as getSlashCommandState, s as deliverMattermostReplyPayload, t as activateSlashCommands, u as parseMattermostModelPickerContext, v as resolveCallbackUrl, y as resolveSlashCommandConfig } from "./slash-state-BjBTvP7u.js";
|
|
8
|
+
import { createRequire } from "node:module";
|
|
8
9
|
import { randomUUID } from "node:crypto";
|
|
9
10
|
import { resolveGatewayPort } from "openclaw/plugin-sdk/gateway-config-runtime";
|
|
10
11
|
import { resolvePinnedMainDmOwnerFromAllowlist, sanitizeUntrustedFileName } from "openclaw/plugin-sdk/security-runtime";
|
|
11
12
|
import { normalizeLowercaseStringOrEmpty, normalizeOptionalString, normalizeStringEntries, normalizeTrimmedStringList, uniqueStrings } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
12
|
-
import { buildChannelInboundMediaPayload, createChannelPartialDeliveryError, formatInboundEnvelope, formatInboundFromLabel, formatInboundMediaUnavailableText, formatMediaPlaceholderText, implicitMentionKindWhen, isChannelPartialDeliveryError, resolveInboundMentionDecision, resolveInboundSessionEnvelopeContext, toInboundMediaFactsWithMetadata } from "openclaw/plugin-sdk/channel-inbound";
|
|
13
|
+
import { buildChannelInboundMediaPayload, createAcceptedChannelDeliveryResult, createChannelPartialDeliveryError, formatInboundEnvelope, formatInboundFromLabel, formatInboundMediaUnavailableText, formatMediaPlaceholderText, implicitMentionKindWhen, isChannelPartialDeliveryError, resolveInboundMentionDecision, resolveInboundSessionEnvelopeContext, toInboundMediaFactsWithMetadata } from "openclaw/plugin-sdk/channel-inbound";
|
|
13
14
|
import { formatErrorMessage, toErrorObject } from "openclaw/plugin-sdk/error-runtime";
|
|
14
15
|
import { safeParseJsonWithSchema, safeParseWithSchema } from "openclaw/plugin-sdk/extension-shared";
|
|
15
16
|
import { asDateTimestampMs, resolveExpiresAtMsFromDurationMs, resolveTimerTimeoutMs } from "openclaw/plugin-sdk/number-runtime";
|
|
@@ -33,7 +34,7 @@ import { pruneMapToMaxSize } from "openclaw/plugin-sdk/collection-runtime";
|
|
|
33
34
|
import { channelReadyPatch, isLoopbackHost } from "openclaw/plugin-sdk/gateway-runtime";
|
|
34
35
|
import { createRuntimeConfigReader } from "openclaw/plugin-sdk/runtime-config-snapshot";
|
|
35
36
|
import { captureWsEvent, createDebugProxyWebSocketAgent, resolveDebugProxySettings } from "openclaw/plugin-sdk/proxy-capture";
|
|
36
|
-
import
|
|
37
|
+
import path from "node:path";
|
|
37
38
|
import { resolveChannelContextVisibilityMode, shouldIncludeSupplementalContext } from "openclaw/plugin-sdk/context-visibility-runtime";
|
|
38
39
|
import { getGlobalHookRunner } from "openclaw/plugin-sdk/plugin-runtime";
|
|
39
40
|
import { chunkMarkdownTextWithMode } from "openclaw/plugin-sdk/reply-chunking";
|
|
@@ -216,6 +217,10 @@ function shouldDropEmptyMattermostBody(params) {
|
|
|
216
217
|
return !botUsername || normalizeLowercaseStringOrEmpty(bareMention ?? "") !== `@${botUsername}`;
|
|
217
218
|
}
|
|
218
219
|
//#endregion
|
|
220
|
+
//#region extensions/mattermost/src/mattermost/ws-runtime.ts
|
|
221
|
+
const require = createRequire(import.meta.url);
|
|
222
|
+
const WebSocket = require(path.join(path.dirname(require.resolve("ws/package.json")), "index.js"));
|
|
223
|
+
//#endregion
|
|
219
224
|
//#region extensions/mattermost/src/mattermost/monitor-websocket.ts
|
|
220
225
|
const MATTERMOST_WEBSOCKET_MAX_PAYLOAD_BYTES = 16777216;
|
|
221
226
|
const MATTERMOST_WEBSOCKET_HANDSHAKE_TIMEOUT_MS = 3e4;
|
|
@@ -1616,6 +1621,20 @@ function createMattermostDraftStream(params) {
|
|
|
1616
1621
|
await clearWithStop(discardPending);
|
|
1617
1622
|
assertNoAcceptedDeliveryFailure();
|
|
1618
1623
|
};
|
|
1624
|
+
const deleteCurrentMessage = async () => {
|
|
1625
|
+
assertNoAcceptedDeliveryFailure();
|
|
1626
|
+
await clearWithStop(async () => {
|
|
1627
|
+
loop.resetPending();
|
|
1628
|
+
await loop.waitForInFlight();
|
|
1629
|
+
await currentGeneration.ready;
|
|
1630
|
+
assertNoAcceptedDeliveryFailure();
|
|
1631
|
+
currentGeneration.lastSentText = "";
|
|
1632
|
+
currentGeneration.latestSourceText = "";
|
|
1633
|
+
currentGeneration.latestAssistantText = void 0;
|
|
1634
|
+
loop.resetThrottleWindow();
|
|
1635
|
+
});
|
|
1636
|
+
assertNoAcceptedDeliveryFailure();
|
|
1637
|
+
};
|
|
1619
1638
|
const seal = async () => {
|
|
1620
1639
|
assertNoAcceptedDeliveryFailure();
|
|
1621
1640
|
await sealLifecycle();
|
|
@@ -1689,6 +1708,7 @@ function createMattermostDraftStream(params) {
|
|
|
1689
1708
|
flush,
|
|
1690
1709
|
postId: () => currentGeneration.postId,
|
|
1691
1710
|
clear,
|
|
1711
|
+
deleteCurrentMessage,
|
|
1692
1712
|
discardPending,
|
|
1693
1713
|
seal,
|
|
1694
1714
|
stop,
|
|
@@ -1702,16 +1722,12 @@ function createMattermostDraftStream(params) {
|
|
|
1702
1722
|
function combineMattermostVisibleDeliveryResults(results) {
|
|
1703
1723
|
const visibleResults = results.filter((result) => result?.visibleReplySent === true);
|
|
1704
1724
|
if (visibleResults.length === 0) return;
|
|
1705
|
-
const receiptResults = [];
|
|
1706
|
-
for (const result of visibleResults) if (result.receipt) receiptResults.push({ receipt: result.receipt });
|
|
1707
|
-
else receiptResults.push(...(result.messageIds ?? []).map((messageId) => ({ messageId })));
|
|
1708
|
-
const receipt = createMessageReceiptFromOutboundResults({ results: receiptResults });
|
|
1709
1725
|
return {
|
|
1710
1726
|
outcome: visibleResults.some((result) => result.outcome === "media") ? "media" : "text",
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1727
|
+
...createAcceptedChannelDeliveryResult({
|
|
1728
|
+
deliveryResults: visibleResults,
|
|
1729
|
+
content: joinMattermostVisibleContent(visibleResults.map((result) => result.content))
|
|
1730
|
+
})
|
|
1715
1731
|
};
|
|
1716
1732
|
}
|
|
1717
1733
|
async function deliverMattermostReplyWithDraftPreview(params) {
|
|
@@ -1811,26 +1827,16 @@ async function deliverMattermostReplyWithDraftPreview(params) {
|
|
|
1811
1827
|
normalDeliveryResult
|
|
1812
1828
|
]) ?? previewDeliveryResult;
|
|
1813
1829
|
} catch (error) {
|
|
1814
|
-
const completedVisibleResults = [
|
|
1815
|
-
const completedReceiptResults = [];
|
|
1816
|
-
for (const result of [
|
|
1830
|
+
const completedVisibleResults = [
|
|
1817
1831
|
confirmedPreviewDelivery,
|
|
1818
1832
|
previewDeliveryResult,
|
|
1819
1833
|
normalDeliveryResult,
|
|
1820
1834
|
supplementalDeliveryResult
|
|
1821
|
-
])
|
|
1822
|
-
if (result?.visibleReplySent !== true) continue;
|
|
1823
|
-
completedVisibleResults.push(result);
|
|
1824
|
-
if (result.receipt) completedReceiptResults.push({ receipt: result.receipt });
|
|
1825
|
-
else completedReceiptResults.push(...(result.messageIds ?? []).map((messageId) => ({ messageId })));
|
|
1826
|
-
}
|
|
1835
|
+
].filter((result) => result?.visibleReplySent === true);
|
|
1827
1836
|
if (completedVisibleResults.length === 0) throw error;
|
|
1828
1837
|
const failedPartial = isChannelPartialDeliveryError(error) ? error.deliveryResult : void 0;
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
messageIds: listMessageReceiptPlatformIds(receipt),
|
|
1832
|
-
receipt,
|
|
1833
|
-
visibleReplySent: true,
|
|
1838
|
+
throw createChannelPartialDeliveryError(error, createAcceptedChannelDeliveryResult({
|
|
1839
|
+
deliveryResults: [...completedVisibleResults, ...failedPartial ? [failedPartial] : []],
|
|
1834
1840
|
content: joinMattermostVisibleContent([
|
|
1835
1841
|
confirmedPreviewDelivery?.content,
|
|
1836
1842
|
previewDeliveryResult?.content,
|
|
@@ -1838,7 +1844,7 @@ async function deliverMattermostReplyWithDraftPreview(params) {
|
|
|
1838
1844
|
supplementalDeliveryResult?.content,
|
|
1839
1845
|
failedPartial?.content
|
|
1840
1846
|
])
|
|
1841
|
-
});
|
|
1847
|
+
}));
|
|
1842
1848
|
}
|
|
1843
1849
|
}
|
|
1844
1850
|
//#endregion
|
|
@@ -1879,6 +1885,7 @@ function createDisabledMattermostDraftStream() {
|
|
|
1879
1885
|
flush: noopAsync,
|
|
1880
1886
|
postId: () => void 0,
|
|
1881
1887
|
clear: noopAsync,
|
|
1888
|
+
deleteCurrentMessage: noopAsync,
|
|
1882
1889
|
discardPending: noopAsync,
|
|
1883
1890
|
seal: noopAsync,
|
|
1884
1891
|
stop: noopAsync,
|
|
@@ -1935,10 +1942,12 @@ async function dispatchMattermostInboundTurn(monitor, params) {
|
|
|
1935
1942
|
mode: account.streamingMode,
|
|
1936
1943
|
active: draftPreviewEnabled,
|
|
1937
1944
|
seed: `${account.accountId}:${channelId}`,
|
|
1945
|
+
shouldStartNow: (line) => typeof line === "object" && line.kind === "item",
|
|
1938
1946
|
update: async (previewText, options) => {
|
|
1939
1947
|
draftStream.update(previewText);
|
|
1940
1948
|
if (options?.flush) await draftStream.flush();
|
|
1941
|
-
}
|
|
1949
|
+
},
|
|
1950
|
+
deleteCurrent: () => draftStream.deleteCurrentMessage()
|
|
1942
1951
|
});
|
|
1943
1952
|
const enterBlockPreviewActivity = (activity) => {
|
|
1944
1953
|
if (account.streamingMode !== "block") return;
|
|
@@ -1946,7 +1955,7 @@ async function dispatchMattermostInboundTurn(monitor, params) {
|
|
|
1946
1955
|
const startsNewGeneration = !continuesCurrentActivity && blockPreviewActivity !== "reasoning";
|
|
1947
1956
|
if (startsNewGeneration) currentAssistantPreviewUsesPrefix = false;
|
|
1948
1957
|
const boundarySettled = startsNewGeneration ? previewBoundaryController.noteBoundary() : void 0;
|
|
1949
|
-
if (!continuesCurrentActivity) progressDraft.
|
|
1958
|
+
if (!continuesCurrentActivity) progressDraft.resetActivity();
|
|
1950
1959
|
blockPreviewActivity = activity;
|
|
1951
1960
|
blockPreviewAssistantMessagePending = false;
|
|
1952
1961
|
if (activity === "tool") lastPartialText = "";
|
|
@@ -2005,6 +2014,7 @@ async function dispatchMattermostInboundTurn(monitor, params) {
|
|
|
2005
2014
|
if (!cleaned || cleaned === lastPartialText) return;
|
|
2006
2015
|
if (lastPartialText && lastPartialText.startsWith(cleaned) && cleaned.length < lastPartialText.length) return;
|
|
2007
2016
|
const boundarySettled = enterBlockPreviewActivity("text");
|
|
2017
|
+
progressDraft.resetActivity({ suppressed: true });
|
|
2008
2018
|
lastPartialText = cleaned;
|
|
2009
2019
|
if (firstAssistantPreviewPrefixPending) {
|
|
2010
2020
|
firstAssistantPreviewPrefix = resolveResponsePrefix?.();
|
|
@@ -2164,18 +2174,16 @@ async function dispatchMattermostInboundTurn(monitor, params) {
|
|
|
2164
2174
|
onPartialReply: (payloadResult) => account.streamingMode === "progress" ? false : updateDraftFromPartial(payloadResult.text),
|
|
2165
2175
|
onAssistantMessageStart: () => {
|
|
2166
2176
|
lastPartialText = "";
|
|
2167
|
-
progressDraft.
|
|
2177
|
+
progressDraft.beginAssistantMessage();
|
|
2168
2178
|
if (account.streamingMode === "block") {
|
|
2169
2179
|
blockPreviewAssistantMessagePending = true;
|
|
2170
2180
|
return false;
|
|
2171
2181
|
}
|
|
2172
|
-
if (account.streamingMode !== "progress") progressDraft.reset();
|
|
2173
2182
|
return false;
|
|
2174
2183
|
},
|
|
2175
2184
|
onReasoningEnd: () => {
|
|
2176
2185
|
lastPartialText = "";
|
|
2177
2186
|
progressDraft.resetReasoningProgress();
|
|
2178
|
-
if (account.streamingMode !== "block" && account.streamingMode !== "progress") progressDraft.reset();
|
|
2179
2187
|
return false;
|
|
2180
2188
|
},
|
|
2181
2189
|
onReasoningStream: async (payloadResult) => {
|
|
@@ -2188,6 +2196,14 @@ async function dispatchMattermostInboundTurn(monitor, params) {
|
|
|
2188
2196
|
}
|
|
2189
2197
|
return false;
|
|
2190
2198
|
},
|
|
2199
|
+
onPlanUpdate: async (payloadValue) => {
|
|
2200
|
+
if (!draftProgressEnabled || payloadValue.phase !== "update") return false;
|
|
2201
|
+
const boundarySettled = enterBlockPreviewActivity("tool");
|
|
2202
|
+
const progressSettled = progressDraft.pushPlanProgress(payloadValue.steps, { explanation: payloadValue.explanation });
|
|
2203
|
+
previewBoundaryController.noteUpdate();
|
|
2204
|
+
const [, visible] = await Promise.all([boundarySettled, progressSettled]);
|
|
2205
|
+
return visible;
|
|
2206
|
+
},
|
|
2191
2207
|
onToolStart: async (payloadValue) => {
|
|
2192
2208
|
if (!draftProgressEnabled) return false;
|
|
2193
2209
|
const boundarySettled = enterBlockPreviewActivity("tool");
|
|
@@ -2206,18 +2222,7 @@ async function dispatchMattermostInboundTurn(monitor, params) {
|
|
|
2206
2222
|
onItemEvent: async (payloadLocal) => {
|
|
2207
2223
|
if (!draftProgressEnabled) return false;
|
|
2208
2224
|
const boundarySettled = enterBlockPreviewActivity("tool");
|
|
2209
|
-
const progressSettled = progressDraft.
|
|
2210
|
-
event: "item",
|
|
2211
|
-
itemId: payloadLocal.itemId,
|
|
2212
|
-
itemKind: payloadLocal.kind,
|
|
2213
|
-
title: payloadLocal.title,
|
|
2214
|
-
name: payloadLocal.name,
|
|
2215
|
-
phase: payloadLocal.phase,
|
|
2216
|
-
status: payloadLocal.status,
|
|
2217
|
-
summary: payloadLocal.summary,
|
|
2218
|
-
progressText: payloadLocal.progressText,
|
|
2219
|
-
meta: payloadLocal.meta
|
|
2220
|
-
}), { startImmediately: true });
|
|
2225
|
+
const progressSettled = progressDraft.pushItemEvent(payloadLocal);
|
|
2221
2226
|
previewBoundaryController.noteUpdate();
|
|
2222
2227
|
const [, visible] = await Promise.all([boundarySettled, progressSettled]);
|
|
2223
2228
|
return visible;
|
package/dist/slash-route-api.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { i as registerSlashCommandRoute } from "./slash-state-
|
|
1
|
+
import { i as registerSlashCommandRoute } from "./slash-state-BjBTvP7u.js";
|
|
2
2
|
export { registerSlashCommandRoute };
|
|
@@ -6,7 +6,7 @@ import { i as resolveMattermostPresentation, l as resolveMattermostAccount, r as
|
|
|
6
6
|
import { createHash } from "node:crypto";
|
|
7
7
|
import { safeEqualSecret } from "openclaw/plugin-sdk/security-runtime";
|
|
8
8
|
import { asFiniteNumber, normalizeLowercaseStringOrEmpty, normalizeOptionalString, normalizeStringifiedOptionalString, readStringField } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
9
|
-
import { createChannelPartialDeliveryError, isChannelPartialDeliveryError } from "openclaw/plugin-sdk/channel-inbound";
|
|
9
|
+
import { createAcceptedChannelDeliveryResult, createChannelPartialDeliveryError, isChannelPartialDeliveryError } from "openclaw/plugin-sdk/channel-inbound";
|
|
10
10
|
import { asDateTimestampMs, parseStrictInteger, resolveExpiresAtMsFromDurationMs } from "openclaw/plugin-sdk/number-runtime";
|
|
11
11
|
import { isPrivateNetworkOptInEnabled } from "openclaw/plugin-sdk/ssrf-runtime";
|
|
12
12
|
import { createMessageReceiptFromOutboundResults, listMessageReceiptPlatformIds } from "openclaw/plugin-sdk/channel-outbound";
|
|
@@ -650,34 +650,27 @@ async function deliverMattermostReplyPayload(params) {
|
|
|
650
650
|
} catch (error) {
|
|
651
651
|
const failedPartial = isChannelPartialDeliveryError(error) ? error.deliveryResult : void 0;
|
|
652
652
|
if (results.length === 0 && failedPartial?.visibleReplySent !== true) throw error;
|
|
653
|
-
|
|
654
|
-
results:
|
|
653
|
+
throw createChannelPartialDeliveryError(error, createAcceptedChannelDeliveryResult({
|
|
654
|
+
results: results.map((result) => ({ receipt: result.receipt })),
|
|
655
|
+
deliveryResults: failedPartial ? [failedPartial] : [],
|
|
655
656
|
kind: reply.mediaUrls.length > 0 ? "media" : "text",
|
|
656
|
-
...params.replyToId ? { replyToId: params.replyToId } : {}
|
|
657
|
-
});
|
|
658
|
-
throw createChannelPartialDeliveryError(error, {
|
|
659
|
-
messageIds: listMessageReceiptPlatformIds(receipt),
|
|
660
|
-
receipt,
|
|
661
|
-
visibleReplySent: true,
|
|
657
|
+
...params.replyToId ? { replyToId: params.replyToId } : {},
|
|
662
658
|
content: joinMattermostVisibleContent([...acceptedContents, failedPartial?.content])
|
|
663
|
-
});
|
|
659
|
+
}));
|
|
664
660
|
}
|
|
665
661
|
if (outcome === "empty") return {
|
|
666
662
|
outcome,
|
|
667
663
|
visibleReplySent: false,
|
|
668
664
|
suppression: { reason: "no_visible_result" }
|
|
669
665
|
};
|
|
670
|
-
const receipt = createMessageReceiptFromOutboundResults({
|
|
671
|
-
results: results.map((result) => ({ receipt: result.receipt })),
|
|
672
|
-
kind: outcome,
|
|
673
|
-
...params.replyToId ? { replyToId: params.replyToId } : {}
|
|
674
|
-
});
|
|
675
666
|
return {
|
|
676
667
|
outcome,
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
668
|
+
...createAcceptedChannelDeliveryResult({
|
|
669
|
+
results: results.map((result) => ({ receipt: result.receipt })),
|
|
670
|
+
kind: outcome,
|
|
671
|
+
...params.replyToId ? { replyToId: params.replyToId } : {},
|
|
672
|
+
content: joinMattermostVisibleContent(acceptedContents)
|
|
673
|
+
})
|
|
681
674
|
};
|
|
682
675
|
}
|
|
683
676
|
//#endregion
|
|
@@ -781,26 +774,30 @@ function isExplicitMattermostTarget(raw) {
|
|
|
781
774
|
async function resolveMattermostOpaqueTarget(params) {
|
|
782
775
|
const input = params.input.trim();
|
|
783
776
|
if (!input || isExplicitMattermostTarget(input) || !isMattermostId(input)) return null;
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
777
|
+
let client;
|
|
778
|
+
if ("client" in params) client = params.client;
|
|
779
|
+
else {
|
|
780
|
+
const account = resolveMattermostAccount({
|
|
781
|
+
cfg: params.cfg,
|
|
782
|
+
accountId: params.accountId
|
|
783
|
+
});
|
|
784
|
+
if (!account.enabled) throw new Error(`Mattermost account "${account.accountId}" is disabled`);
|
|
785
|
+
const token = normalizeOptionalString(account.botToken);
|
|
786
|
+
const baseUrl = normalizeMattermostBaseUrl(account.baseUrl);
|
|
787
|
+
if (!token || !baseUrl) return null;
|
|
788
|
+
client = createMattermostClient({
|
|
789
|
+
baseUrl,
|
|
790
|
+
botToken: token,
|
|
791
|
+
allowPrivateNetwork: isPrivateNetworkOptInEnabled(account.config)
|
|
792
|
+
});
|
|
793
|
+
}
|
|
794
|
+
const key = cacheKey$1(client.baseUrl, client.token, input);
|
|
793
795
|
const cachedKind = getCachedMattermostOpaqueTargetKind(key);
|
|
794
796
|
if (cachedKind) return {
|
|
795
797
|
kind: cachedKind,
|
|
796
798
|
id: input,
|
|
797
799
|
to: cachedKind === "user" ? `user:${input}` : `channel:${input}`
|
|
798
800
|
};
|
|
799
|
-
const client = createMattermostClient({
|
|
800
|
-
baseUrl,
|
|
801
|
-
botToken: token,
|
|
802
|
-
allowPrivateNetwork: isPrivateNetworkOptInEnabled(account?.config)
|
|
803
|
-
});
|
|
804
801
|
try {
|
|
805
802
|
await fetchMattermostUser(client, input);
|
|
806
803
|
cacheMattermostOpaqueTarget(key, "user");
|
|
@@ -893,43 +890,28 @@ function normalizeMessage(text, mediaUrl) {
|
|
|
893
890
|
function isHttpUrl(value) {
|
|
894
891
|
return /^https?:\/\//i.test(value);
|
|
895
892
|
}
|
|
896
|
-
async function resolveBotUser(
|
|
897
|
-
const key = cacheKey(baseUrl, token);
|
|
893
|
+
async function resolveBotUser(client) {
|
|
894
|
+
const key = cacheKey(client.baseUrl, client.token);
|
|
898
895
|
const cached = botUserCache.get(key);
|
|
899
896
|
if (cached) return cached;
|
|
900
|
-
const client = createMattermostClient({
|
|
901
|
-
baseUrl,
|
|
902
|
-
botToken: token,
|
|
903
|
-
allowPrivateNetwork
|
|
904
|
-
});
|
|
905
897
|
const user = await fetchMattermostMe(client);
|
|
906
898
|
cacheOutboundEntry(botUserCache, key, user, MATTERMOST_BOT_USER_CACHE_MAX_ENTRIES);
|
|
907
899
|
return user;
|
|
908
900
|
}
|
|
909
901
|
async function resolveUserIdByUsername(params) {
|
|
910
|
-
const {
|
|
911
|
-
const key = `${cacheKey(baseUrl, token)}::${normalizeLowercaseStringOrEmpty(username)}`;
|
|
902
|
+
const { client, username } = params;
|
|
903
|
+
const key = `${cacheKey(client.baseUrl, client.token)}::${normalizeLowercaseStringOrEmpty(username)}`;
|
|
912
904
|
const cached = userByNameCache.get(key);
|
|
913
905
|
if (cached?.id) return cached.id;
|
|
914
|
-
const client = createMattermostClient({
|
|
915
|
-
baseUrl,
|
|
916
|
-
botToken: token,
|
|
917
|
-
allowPrivateNetwork: params.allowPrivateNetwork
|
|
918
|
-
});
|
|
919
906
|
const user = await fetchMattermostUserByUsername(client, username);
|
|
920
907
|
cacheOutboundEntry(userByNameCache, key, user, MATTERMOST_TARGET_CACHE_MAX_ENTRIES);
|
|
921
908
|
return user.id;
|
|
922
909
|
}
|
|
923
910
|
async function resolveChannelIdByName(params) {
|
|
924
|
-
const {
|
|
925
|
-
const key = `${cacheKey(baseUrl, token)}::channel::${normalizeLowercaseStringOrEmpty(name)}`;
|
|
911
|
+
const { client, name } = params;
|
|
912
|
+
const key = `${cacheKey(client.baseUrl, client.token)}::channel::${normalizeLowercaseStringOrEmpty(name)}`;
|
|
926
913
|
const cached = channelByNameCache.get(key);
|
|
927
914
|
if (cached) return cached;
|
|
928
|
-
const client = createMattermostClient({
|
|
929
|
-
baseUrl,
|
|
930
|
-
botToken: token,
|
|
931
|
-
allowPrivateNetwork: params.allowPrivateNetwork
|
|
932
|
-
});
|
|
933
915
|
const me = await fetchMattermostMe(client);
|
|
934
916
|
const teams = await fetchMattermostUserTeams(client, me.id);
|
|
935
917
|
for (const team of teams) try {
|
|
@@ -957,27 +939,18 @@ function mergeDmRetryOptions(base, override) {
|
|
|
957
939
|
async function resolveTargetChannelId(params) {
|
|
958
940
|
if (params.target.kind === "channel") return params.target.id;
|
|
959
941
|
if (params.target.kind === "channel-name") return await resolveChannelIdByName({
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
name: params.target.name,
|
|
963
|
-
allowPrivateNetwork: params.allowPrivateNetwork
|
|
942
|
+
client: params.client,
|
|
943
|
+
name: params.target.name
|
|
964
944
|
});
|
|
965
945
|
const userId = params.target.id ? params.target.id : await resolveUserIdByUsername({
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
username: params.target.username ?? "",
|
|
969
|
-
allowPrivateNetwork: params.allowPrivateNetwork
|
|
946
|
+
client: params.client,
|
|
947
|
+
username: params.target.username ?? ""
|
|
970
948
|
});
|
|
971
|
-
const dmKey = `${cacheKey(params.baseUrl, params.token)}::dm::${userId}`;
|
|
949
|
+
const dmKey = `${cacheKey(params.client.baseUrl, params.client.token)}::dm::${userId}`;
|
|
972
950
|
const cachedDm = dmChannelCache.get(dmKey);
|
|
973
951
|
if (cachedDm) return cachedDm;
|
|
974
|
-
const botUser = await resolveBotUser(params.
|
|
975
|
-
const
|
|
976
|
-
baseUrl: params.baseUrl,
|
|
977
|
-
botToken: params.token,
|
|
978
|
-
allowPrivateNetwork: params.allowPrivateNetwork
|
|
979
|
-
});
|
|
980
|
-
const channel = await createMattermostDirectChannelWithRetry(client, [botUser.id, userId], {
|
|
952
|
+
const botUser = await resolveBotUser(params.client);
|
|
953
|
+
const channel = await createMattermostDirectChannelWithRetry(params.client, [botUser.id, userId], {
|
|
981
954
|
...params.dmRetryOptions,
|
|
982
955
|
onRetry: (attempt, delayMs, error) => {
|
|
983
956
|
params.dmRetryOptions?.onRetry?.(attempt, delayMs, error);
|
|
@@ -1000,41 +973,31 @@ async function resolveMattermostSendContext(to, opts) {
|
|
|
1000
973
|
if (!token) throw new Error(`Mattermost bot token missing for account "${account.accountId}" (set channels.mattermost.accounts.${account.accountId}.botToken or MATTERMOST_BOT_TOKEN for default).`);
|
|
1001
974
|
const baseUrl = normalizeMattermostBaseUrl(opts.baseUrl ?? account.baseUrl);
|
|
1002
975
|
if (!baseUrl) throw new Error(`Mattermost baseUrl missing for account "${account.accountId}" (set channels.mattermost.accounts.${account.accountId}.baseUrl or MATTERMOST_URL for default).`);
|
|
1003
|
-
const
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
baseUrl
|
|
976
|
+
const client = createMattermostClient({
|
|
977
|
+
baseUrl,
|
|
978
|
+
botToken: token,
|
|
979
|
+
allowPrivateNetwork: isPrivateNetworkOptInEnabled(account.config)
|
|
1008
980
|
});
|
|
1009
|
-
const
|
|
1010
|
-
kind: "user",
|
|
1011
|
-
id: opaqueTarget.id
|
|
1012
|
-
} : opaqueTarget?.kind === "channel" ? {
|
|
1013
|
-
kind: "channel",
|
|
1014
|
-
id: opaqueTarget.id
|
|
1015
|
-
} : parseMattermostTarget(trimmedTo);
|
|
1016
|
-
const dmRetryOptions = mergeDmRetryOptions(account.config.dmChannelRetry ? {
|
|
1017
|
-
maxRetries: account.config.dmChannelRetry.maxRetries,
|
|
1018
|
-
initialDelayMs: account.config.dmChannelRetry.initialDelayMs,
|
|
1019
|
-
maxDelayMs: account.config.dmChannelRetry.maxDelayMs,
|
|
1020
|
-
timeoutMs: account.config.dmChannelRetry.timeoutMs
|
|
1021
|
-
} : void 0, opts.dmRetryOptions);
|
|
1022
|
-
const allowPrivateNetwork = isPrivateNetworkOptInEnabled(account.config);
|
|
981
|
+
const trimmedTo = normalizeOptionalString(to) ?? "";
|
|
1023
982
|
const channelId = await resolveTargetChannelId({
|
|
1024
|
-
target
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
983
|
+
target: parseMattermostTarget((await resolveMattermostOpaqueTarget({
|
|
984
|
+
input: trimmedTo,
|
|
985
|
+
client
|
|
986
|
+
}))?.to ?? trimmedTo),
|
|
987
|
+
client,
|
|
988
|
+
dmRetryOptions: mergeDmRetryOptions(account.config.dmChannelRetry ? {
|
|
989
|
+
maxRetries: account.config.dmChannelRetry.maxRetries,
|
|
990
|
+
initialDelayMs: account.config.dmChannelRetry.initialDelayMs,
|
|
991
|
+
maxDelayMs: account.config.dmChannelRetry.maxDelayMs,
|
|
992
|
+
timeoutMs: account.config.dmChannelRetry.timeoutMs
|
|
993
|
+
} : void 0, opts.dmRetryOptions),
|
|
1029
994
|
logger: core.logging.shouldLogVerbose() ? logger : void 0
|
|
1030
995
|
});
|
|
1031
996
|
return {
|
|
1032
997
|
cfg,
|
|
1033
998
|
accountId: account.accountId,
|
|
1034
|
-
|
|
1035
|
-
baseUrl,
|
|
999
|
+
client,
|
|
1036
1000
|
channelId,
|
|
1037
|
-
allowPrivateNetwork,
|
|
1038
1001
|
mediaMaxBytes: resolveChannelMediaMaxBytes({
|
|
1039
1002
|
cfg,
|
|
1040
1003
|
accountId: account.accountId,
|
|
@@ -1045,15 +1008,10 @@ async function resolveMattermostSendContext(to, opts) {
|
|
|
1045
1008
|
async function sendMessageMattermost(to, text, opts) {
|
|
1046
1009
|
const core = getCore();
|
|
1047
1010
|
const logger = core.logging.getChildLogger({ module: "mattermost" });
|
|
1048
|
-
const { cfg, accountId,
|
|
1049
|
-
const client = createMattermostClient({
|
|
1050
|
-
baseUrl,
|
|
1051
|
-
botToken: token,
|
|
1052
|
-
allowPrivateNetwork
|
|
1053
|
-
});
|
|
1011
|
+
const { cfg, accountId, client, channelId, mediaMaxBytes } = await resolveMattermostSendContext(to, opts);
|
|
1054
1012
|
let props = opts.props;
|
|
1055
1013
|
if (!props && Array.isArray(opts.buttons) && opts.buttons.length > 0) {
|
|
1056
|
-
setInteractionSecret(accountId, token);
|
|
1014
|
+
setInteractionSecret(accountId, client.token);
|
|
1057
1015
|
props = buildButtonProps({
|
|
1058
1016
|
callbackUrl: resolveInteractionCallbackUrl(accountId, {
|
|
1059
1017
|
gateway: cfg.gateway,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openclaw/mattermost",
|
|
3
|
-
"version": "2026.9.
|
|
3
|
+
"version": "2026.9.3",
|
|
4
4
|
"description": "OpenClaw Mattermost channel plugin",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"zod": "4.4.3"
|
|
13
13
|
},
|
|
14
14
|
"peerDependencies": {
|
|
15
|
-
"openclaw": ">=2026.9.
|
|
15
|
+
"openclaw": ">=2026.9.3"
|
|
16
16
|
},
|
|
17
17
|
"peerDependenciesMeta": {
|
|
18
18
|
"openclaw": {
|
|
@@ -24,6 +24,9 @@
|
|
|
24
24
|
"./index.ts"
|
|
25
25
|
],
|
|
26
26
|
"setupEntry": "./dist/setup-entry.js",
|
|
27
|
+
"setupFeatures": {
|
|
28
|
+
"configPromotion": true
|
|
29
|
+
},
|
|
27
30
|
"channel": {
|
|
28
31
|
"id": "mattermost",
|
|
29
32
|
"configuredState": {
|
|
@@ -91,10 +94,10 @@
|
|
|
91
94
|
"allowInvalidConfigRecovery": true
|
|
92
95
|
},
|
|
93
96
|
"compat": {
|
|
94
|
-
"pluginApi": ">=2026.9.
|
|
97
|
+
"pluginApi": ">=2026.9.3"
|
|
95
98
|
},
|
|
96
99
|
"build": {
|
|
97
|
-
"openclawVersion": "2026.9.
|
|
100
|
+
"openclawVersion": "2026.9.3",
|
|
98
101
|
"bundledDist": false
|
|
99
102
|
},
|
|
100
103
|
"release": {
|