@openclaw/mattermost 2026.9.2 → 2026.9.4
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-Dhr44A2Y.js} +9 -23
- package/dist/channel-plugin-runtime.js +1 -1
- package/dist/{channel.runtime-B454n78J.js → channel.runtime-CYxC0VaI.js} +58 -43
- package/dist/slash-route-api.js +1 -1
- package/dist/{slash-state-njvQCdwt.js → slash-state-BjBTvP7u.js} +62 -104
- package/openclaw.plugin.json +3 -0
- 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-Dhr44A2Y.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 = {
|
|
@@ -15,7 +15,6 @@ import { describeAccountSnapshot } from "openclaw/plugin-sdk/account-helpers";
|
|
|
15
15
|
import { DEFAULT_ACCOUNT_ID as DEFAULT_ACCOUNT_ID$1, buildChannelOutboundSessionRoute, buildThreadAwareOutboundSessionRoute, stripChannelTargetPrefix, stripTargetKindPrefix } from "openclaw/plugin-sdk/core";
|
|
16
16
|
import { identityEntryAuthenticationClassifier } from "openclaw/plugin-sdk/channel-ingress-runtime";
|
|
17
17
|
import { jsonResult, readPositiveIntegerParam, readStringArrayParam, readStringParam, withNormalizedTimestamp } from "openclaw/plugin-sdk/channel-actions";
|
|
18
|
-
import { adaptScopedAccountAccessor, createScopedChannelConfigAdapter } from "openclaw/plugin-sdk/channel-config-helpers";
|
|
19
18
|
import { createChannelConfigUiHints, createChatChannelPlugin } from "openclaw/plugin-sdk/channel-core";
|
|
20
19
|
import { buildChannelGroupsScopeTree, buildMutableAllowEntryDetector, collectStandardAllowlistLists, createDangerousNameMatchingMutableAllowlistWarningCollector, createRestrictSendersChannelSecurity, resolveScopeRequireMention } from "openclaw/plugin-sdk/channel-policy";
|
|
21
20
|
import { attachChannelToResult, createAttachedChannelResultAdapter } from "openclaw/plugin-sdk/channel-send-result";
|
|
@@ -27,6 +26,7 @@ import { createComputedAccountStatusAdapter, createDefaultChannelRuntimeState }
|
|
|
27
26
|
import { chunkTextForOutbound, sanitizeAssistantVisibleText } from "openclaw/plugin-sdk/text-chunking";
|
|
28
27
|
import { createChannelApprovalAuth } from "openclaw/plugin-sdk/approval-auth-runtime";
|
|
29
28
|
import { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "openclaw/plugin-sdk/account-id";
|
|
29
|
+
import { adaptScopedAccountAccessor, createScopedChannelConfigAdapter } from "openclaw/plugin-sdk/channel-config-helpers";
|
|
30
30
|
import { BlockStreamingCoalesceSchema, ChannelImplicitMentionsSchema, ContextVisibilityModeSchema, DmPolicySchema, GroupPolicySchema, MarkdownConfigSchema, buildChannelConfigSchema, buildGroupEntrySchema, buildMultiAccountChannelSchema, requireOpenAllowFrom } from "openclaw/plugin-sdk/channel-config-schema";
|
|
31
31
|
import { defineChannelSetupContract } from "openclaw/plugin-sdk/channel-setup";
|
|
32
32
|
import { applyAccountNameToChannelSection, applySetupAccountConfigPatch, baseUrlTextInput, createSetupTranslator, createStandardChannelSetupStatus, defineTokenCredential, formatDocsLink, migrateBaseNameToDefaultAccount, setSetupChannelEnabled } from "openclaw/plugin-sdk/setup";
|
|
@@ -78,6 +78,7 @@ const mattermostConfigAdapter = createScopedChannelConfigAdapter({
|
|
|
78
78
|
sectionKey: "mattermost",
|
|
79
79
|
listAccountIds: listMattermostAccountIds,
|
|
80
80
|
resolveAccount: adaptScopedAccountAccessor(resolveMattermostAccount),
|
|
81
|
+
inspectAccount: adaptScopedAccountAccessor(inspectMattermostAccount),
|
|
81
82
|
defaultAccountId: resolveDefaultMattermostAccountId,
|
|
82
83
|
clearBaseFields: [
|
|
83
84
|
"botToken",
|
|
@@ -431,7 +432,10 @@ function applyMattermostSetupConfigPatch(params) {
|
|
|
431
432
|
patch: params.patch
|
|
432
433
|
});
|
|
433
434
|
}
|
|
435
|
+
const accountCredentialKeys = ["botToken", "baseUrl"];
|
|
434
436
|
const mattermostSetupAdapter = {
|
|
437
|
+
singleAccountKeysToMove: accountCredentialKeys,
|
|
438
|
+
namedAccountPromotionKeys: accountCredentialKeys,
|
|
435
439
|
resolveAccountId: ({ accountId }) => normalizeAccountId(accountId),
|
|
436
440
|
applyAccountName: ({ cfg, accountId, name }) => applyAccountNameToChannelSection({
|
|
437
441
|
cfg,
|
|
@@ -594,7 +598,7 @@ const mattermostSetupWizard = {
|
|
|
594
598
|
};
|
|
595
599
|
//#endregion
|
|
596
600
|
//#region extensions/mattermost/src/channel.ts
|
|
597
|
-
const loadMattermostChannelRuntime = createLazyRuntimeModule(() => import("./channel.runtime-
|
|
601
|
+
const loadMattermostChannelRuntime = createLazyRuntimeModule(() => import("./channel.runtime-CYxC0VaI.js"));
|
|
598
602
|
const MATTERMOST_PRESENTATION_CAPABILITIES = {
|
|
599
603
|
supported: true,
|
|
600
604
|
buttons: true,
|
|
@@ -808,25 +812,8 @@ const mattermostMessageActions = {
|
|
|
808
812
|
if (!(account.config.actions?.reactions ?? mattermostConfig?.actions?.reactions ?? true)) throw new Error("Mattermost reactions are disabled in config");
|
|
809
813
|
const { postId, emojiName, remove } = parseMattermostReactActionParams(params);
|
|
810
814
|
const authorizedTarget = normalizeOptionalString(params.to);
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
cfg,
|
|
814
|
-
postId,
|
|
815
|
-
emojiName,
|
|
816
|
-
accountId: resolvedAccountId,
|
|
817
|
-
authorizedTarget,
|
|
818
|
-
conversationReadOrigin
|
|
819
|
-
});
|
|
820
|
-
if (!result.ok) throw new Error(result.error);
|
|
821
|
-
return {
|
|
822
|
-
content: [{
|
|
823
|
-
type: "text",
|
|
824
|
-
text: `Removed reaction :${emojiName}: from ${postId}`
|
|
825
|
-
}],
|
|
826
|
-
details: {}
|
|
827
|
-
};
|
|
828
|
-
}
|
|
829
|
-
const result = await (await loadMattermostChannelRuntime()).addMattermostReaction({
|
|
815
|
+
const runtime = await loadMattermostChannelRuntime();
|
|
816
|
+
const result = await (remove ? runtime.removeMattermostReaction : runtime.addMattermostReaction)({
|
|
830
817
|
cfg,
|
|
831
818
|
postId,
|
|
832
819
|
emojiName,
|
|
@@ -838,7 +825,7 @@ const mattermostMessageActions = {
|
|
|
838
825
|
return {
|
|
839
826
|
content: [{
|
|
840
827
|
type: "text",
|
|
841
|
-
text: `Reacted with :${emojiName}: on ${postId}`
|
|
828
|
+
text: remove ? `Removed reaction :${emojiName}: from ${postId}` : `Reacted with :${emojiName}: on ${postId}`
|
|
842
829
|
}],
|
|
843
830
|
details: {}
|
|
844
831
|
};
|
|
@@ -1041,7 +1028,6 @@ const mattermostPlugin = createChatChannelPlugin({
|
|
|
1041
1028
|
configSchema: MattermostChannelConfigSchema,
|
|
1042
1029
|
config: {
|
|
1043
1030
|
...mattermostConfigAdapter,
|
|
1044
|
-
inspectAccount: adaptScopedAccountAccessor(inspectMattermostAccount),
|
|
1045
1031
|
isConfigured: isMattermostConfigured$1,
|
|
1046
1032
|
describeAccount: describeMattermostAccount
|
|
1047
1033
|
},
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as mattermostPlugin } from "./channel-plugin-runtime-
|
|
1
|
+
import { t as mattermostPlugin } from "./channel-plugin-runtime-Dhr44A2Y.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,30 @@ function createMattermostDraftStream(params) {
|
|
|
1616
1621
|
await clearWithStop(discardPending);
|
|
1617
1622
|
assertNoAcceptedDeliveryFailure();
|
|
1618
1623
|
};
|
|
1624
|
+
const deleteCurrentMessage = async () => {
|
|
1625
|
+
assertNoAcceptedDeliveryFailure();
|
|
1626
|
+
const retiring = currentGeneration;
|
|
1627
|
+
loop.resetPending();
|
|
1628
|
+
const inFlight = loop.waitForInFlight();
|
|
1629
|
+
const retirement = clearWithStop(async () => {
|
|
1630
|
+
await retiring.ready;
|
|
1631
|
+
await inFlight;
|
|
1632
|
+
assertNoAcceptedDeliveryFailure();
|
|
1633
|
+
}, {
|
|
1634
|
+
readMessageId: () => retiring.postId,
|
|
1635
|
+
clearMessageId: () => {
|
|
1636
|
+
retiring.postId = void 0;
|
|
1637
|
+
}
|
|
1638
|
+
});
|
|
1639
|
+
currentGeneration = {
|
|
1640
|
+
lastSentText: "",
|
|
1641
|
+
latestSourceText: "",
|
|
1642
|
+
ready: retirement
|
|
1643
|
+
};
|
|
1644
|
+
loop.resetThrottleWindow();
|
|
1645
|
+
await retirement;
|
|
1646
|
+
assertNoAcceptedDeliveryFailure();
|
|
1647
|
+
};
|
|
1619
1648
|
const seal = async () => {
|
|
1620
1649
|
assertNoAcceptedDeliveryFailure();
|
|
1621
1650
|
await sealLifecycle();
|
|
@@ -1689,6 +1718,7 @@ function createMattermostDraftStream(params) {
|
|
|
1689
1718
|
flush,
|
|
1690
1719
|
postId: () => currentGeneration.postId,
|
|
1691
1720
|
clear,
|
|
1721
|
+
deleteCurrentMessage,
|
|
1692
1722
|
discardPending,
|
|
1693
1723
|
seal,
|
|
1694
1724
|
stop,
|
|
@@ -1702,16 +1732,12 @@ function createMattermostDraftStream(params) {
|
|
|
1702
1732
|
function combineMattermostVisibleDeliveryResults(results) {
|
|
1703
1733
|
const visibleResults = results.filter((result) => result?.visibleReplySent === true);
|
|
1704
1734
|
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
1735
|
return {
|
|
1710
1736
|
outcome: visibleResults.some((result) => result.outcome === "media") ? "media" : "text",
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1737
|
+
...createAcceptedChannelDeliveryResult({
|
|
1738
|
+
deliveryResults: visibleResults,
|
|
1739
|
+
content: joinMattermostVisibleContent(visibleResults.map((result) => result.content))
|
|
1740
|
+
})
|
|
1715
1741
|
};
|
|
1716
1742
|
}
|
|
1717
1743
|
async function deliverMattermostReplyWithDraftPreview(params) {
|
|
@@ -1811,26 +1837,16 @@ async function deliverMattermostReplyWithDraftPreview(params) {
|
|
|
1811
1837
|
normalDeliveryResult
|
|
1812
1838
|
]) ?? previewDeliveryResult;
|
|
1813
1839
|
} catch (error) {
|
|
1814
|
-
const completedVisibleResults = [
|
|
1815
|
-
const completedReceiptResults = [];
|
|
1816
|
-
for (const result of [
|
|
1840
|
+
const completedVisibleResults = [
|
|
1817
1841
|
confirmedPreviewDelivery,
|
|
1818
1842
|
previewDeliveryResult,
|
|
1819
1843
|
normalDeliveryResult,
|
|
1820
1844
|
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
|
-
}
|
|
1845
|
+
].filter((result) => result?.visibleReplySent === true);
|
|
1827
1846
|
if (completedVisibleResults.length === 0) throw error;
|
|
1828
1847
|
const failedPartial = isChannelPartialDeliveryError(error) ? error.deliveryResult : void 0;
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
messageIds: listMessageReceiptPlatformIds(receipt),
|
|
1832
|
-
receipt,
|
|
1833
|
-
visibleReplySent: true,
|
|
1848
|
+
throw createChannelPartialDeliveryError(error, createAcceptedChannelDeliveryResult({
|
|
1849
|
+
deliveryResults: [...completedVisibleResults, ...failedPartial ? [failedPartial] : []],
|
|
1834
1850
|
content: joinMattermostVisibleContent([
|
|
1835
1851
|
confirmedPreviewDelivery?.content,
|
|
1836
1852
|
previewDeliveryResult?.content,
|
|
@@ -1838,7 +1854,7 @@ async function deliverMattermostReplyWithDraftPreview(params) {
|
|
|
1838
1854
|
supplementalDeliveryResult?.content,
|
|
1839
1855
|
failedPartial?.content
|
|
1840
1856
|
])
|
|
1841
|
-
});
|
|
1857
|
+
}));
|
|
1842
1858
|
}
|
|
1843
1859
|
}
|
|
1844
1860
|
//#endregion
|
|
@@ -1879,6 +1895,7 @@ function createDisabledMattermostDraftStream() {
|
|
|
1879
1895
|
flush: noopAsync,
|
|
1880
1896
|
postId: () => void 0,
|
|
1881
1897
|
clear: noopAsync,
|
|
1898
|
+
deleteCurrentMessage: noopAsync,
|
|
1882
1899
|
discardPending: noopAsync,
|
|
1883
1900
|
seal: noopAsync,
|
|
1884
1901
|
stop: noopAsync,
|
|
@@ -1935,10 +1952,12 @@ async function dispatchMattermostInboundTurn(monitor, params) {
|
|
|
1935
1952
|
mode: account.streamingMode,
|
|
1936
1953
|
active: draftPreviewEnabled,
|
|
1937
1954
|
seed: `${account.accountId}:${channelId}`,
|
|
1955
|
+
shouldStartNow: (line) => typeof line === "object" && line.kind === "item",
|
|
1938
1956
|
update: async (previewText, options) => {
|
|
1939
1957
|
draftStream.update(previewText);
|
|
1940
1958
|
if (options?.flush) await draftStream.flush();
|
|
1941
|
-
}
|
|
1959
|
+
},
|
|
1960
|
+
deleteCurrent: () => draftStream.deleteCurrentMessage()
|
|
1942
1961
|
});
|
|
1943
1962
|
const enterBlockPreviewActivity = (activity) => {
|
|
1944
1963
|
if (account.streamingMode !== "block") return;
|
|
@@ -1946,7 +1965,7 @@ async function dispatchMattermostInboundTurn(monitor, params) {
|
|
|
1946
1965
|
const startsNewGeneration = !continuesCurrentActivity && blockPreviewActivity !== "reasoning";
|
|
1947
1966
|
if (startsNewGeneration) currentAssistantPreviewUsesPrefix = false;
|
|
1948
1967
|
const boundarySettled = startsNewGeneration ? previewBoundaryController.noteBoundary() : void 0;
|
|
1949
|
-
if (!continuesCurrentActivity) progressDraft.
|
|
1968
|
+
if (!continuesCurrentActivity) progressDraft.resetActivity();
|
|
1950
1969
|
blockPreviewActivity = activity;
|
|
1951
1970
|
blockPreviewAssistantMessagePending = false;
|
|
1952
1971
|
if (activity === "tool") lastPartialText = "";
|
|
@@ -2005,6 +2024,7 @@ async function dispatchMattermostInboundTurn(monitor, params) {
|
|
|
2005
2024
|
if (!cleaned || cleaned === lastPartialText) return;
|
|
2006
2025
|
if (lastPartialText && lastPartialText.startsWith(cleaned) && cleaned.length < lastPartialText.length) return;
|
|
2007
2026
|
const boundarySettled = enterBlockPreviewActivity("text");
|
|
2027
|
+
progressDraft.resetActivity({ suppressed: true });
|
|
2008
2028
|
lastPartialText = cleaned;
|
|
2009
2029
|
if (firstAssistantPreviewPrefixPending) {
|
|
2010
2030
|
firstAssistantPreviewPrefix = resolveResponsePrefix?.();
|
|
@@ -2164,18 +2184,16 @@ async function dispatchMattermostInboundTurn(monitor, params) {
|
|
|
2164
2184
|
onPartialReply: (payloadResult) => account.streamingMode === "progress" ? false : updateDraftFromPartial(payloadResult.text),
|
|
2165
2185
|
onAssistantMessageStart: () => {
|
|
2166
2186
|
lastPartialText = "";
|
|
2167
|
-
progressDraft.
|
|
2187
|
+
progressDraft.beginAssistantMessage();
|
|
2168
2188
|
if (account.streamingMode === "block") {
|
|
2169
2189
|
blockPreviewAssistantMessagePending = true;
|
|
2170
2190
|
return false;
|
|
2171
2191
|
}
|
|
2172
|
-
if (account.streamingMode !== "progress") progressDraft.reset();
|
|
2173
2192
|
return false;
|
|
2174
2193
|
},
|
|
2175
2194
|
onReasoningEnd: () => {
|
|
2176
2195
|
lastPartialText = "";
|
|
2177
2196
|
progressDraft.resetReasoningProgress();
|
|
2178
|
-
if (account.streamingMode !== "block" && account.streamingMode !== "progress") progressDraft.reset();
|
|
2179
2197
|
return false;
|
|
2180
2198
|
},
|
|
2181
2199
|
onReasoningStream: async (payloadResult) => {
|
|
@@ -2188,6 +2206,14 @@ async function dispatchMattermostInboundTurn(monitor, params) {
|
|
|
2188
2206
|
}
|
|
2189
2207
|
return false;
|
|
2190
2208
|
},
|
|
2209
|
+
onPlanUpdate: async (payloadValue) => {
|
|
2210
|
+
if (!draftProgressEnabled || payloadValue.phase !== "update") return false;
|
|
2211
|
+
const boundarySettled = enterBlockPreviewActivity("tool");
|
|
2212
|
+
const progressSettled = progressDraft.pushPlanProgress(payloadValue.steps, { explanation: payloadValue.explanation });
|
|
2213
|
+
previewBoundaryController.noteUpdate();
|
|
2214
|
+
const [, visible] = await Promise.all([boundarySettled, progressSettled]);
|
|
2215
|
+
return visible;
|
|
2216
|
+
},
|
|
2191
2217
|
onToolStart: async (payloadValue) => {
|
|
2192
2218
|
if (!draftProgressEnabled) return false;
|
|
2193
2219
|
const boundarySettled = enterBlockPreviewActivity("tool");
|
|
@@ -2206,18 +2232,7 @@ async function dispatchMattermostInboundTurn(monitor, params) {
|
|
|
2206
2232
|
onItemEvent: async (payloadLocal) => {
|
|
2207
2233
|
if (!draftProgressEnabled) return false;
|
|
2208
2234
|
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 });
|
|
2235
|
+
const progressSettled = progressDraft.pushItemEvent(payloadLocal);
|
|
2221
2236
|
previewBoundaryController.noteUpdate();
|
|
2222
2237
|
const [, visible] = await Promise.all([boundarySettled, progressSettled]);
|
|
2223
2238
|
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/openclaw.plugin.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openclaw/mattermost",
|
|
3
|
-
"version": "2026.9.
|
|
3
|
+
"version": "2026.9.4",
|
|
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.4"
|
|
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.4"
|
|
95
98
|
},
|
|
96
99
|
"build": {
|
|
97
|
-
"openclawVersion": "2026.9.
|
|
100
|
+
"openclawVersion": "2026.9.4",
|
|
98
101
|
"bundledDist": false
|
|
99
102
|
},
|
|
100
103
|
"release": {
|