@openclaw/mattermost 2026.7.2-beta.5 → 2026.7.2-beta.7
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/{accounts-BR6Nl5Qf.js → accounts-NaMdx9yF.js} +23 -8
- package/dist/api.js +2 -2
- package/dist/channel-plugin-api.js +1 -1
- package/dist/{channel-plugin-runtime-DLBTUlbh.js → channel-plugin-runtime-DlrMaSIu.js} +141 -60
- package/dist/channel-plugin-runtime.js +1 -1
- package/dist/{channel.runtime-CR1V5M8l.js → channel.runtime-DndW9G7T.js} +543 -209
- package/dist/{client-w0lkxuKh.js → client-CqqzTcno.js} +25 -2
- package/dist/{interactions-B4gg-KRm.js → interactions-BQXY_48h.js} +2 -2
- package/dist/{monitor-auth-BOh6zLW9.js → monitor-auth-rctDliGZ.js} +2 -2
- package/dist/policy-api.js +1 -1
- package/dist/slash-route-api.js +1 -1
- package/dist/{slash-state-VCRdqj5F.js → slash-state-DM8qmFJR.js} +135 -51
- package/openclaw.plugin.json +22 -16
- package/package.json +4 -4
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { m as normalizeMattermostBaseUrl } from "./client-CqqzTcno.js";
|
|
2
2
|
import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
3
3
|
import { resolveChannelPreviewStreamMode, resolveChannelStreamingBlockCoalesce, resolveChannelStreamingBlockEnabled, resolveChannelStreamingChunkMode } from "openclaw/plugin-sdk/channel-outbound";
|
|
4
4
|
import { createAccountListHelpers, hasConfiguredAccountValue } from "openclaw/plugin-sdk/account-helpers";
|
|
5
5
|
import { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "openclaw/plugin-sdk/account-id";
|
|
6
|
-
import { buildSecretInputSchema, hasConfiguredSecretInput,
|
|
6
|
+
import { buildSecretInputSchema, hasConfiguredSecretInput, resolveSecretInputString } from "openclaw/plugin-sdk/secret-input";
|
|
7
7
|
//#region extensions/mattermost/src/mattermost/accounts.ts
|
|
8
8
|
const { listAccountIds: listMattermostAccountIds, resolveDefaultAccountId: resolveDefaultMattermostAccountId, resolveAccountConfig: mergeMattermostAccountConfig } = createAccountListHelpers("mattermost", {
|
|
9
9
|
omitKeys: ["defaultAccount"],
|
|
@@ -19,7 +19,7 @@ function resolveMattermostRequireMention(config) {
|
|
|
19
19
|
if (config.chatmode === "onchar") return true;
|
|
20
20
|
return config.requireMention;
|
|
21
21
|
}
|
|
22
|
-
function
|
|
22
|
+
function resolveMattermostAccountWithMode(params) {
|
|
23
23
|
const accountId = normalizeAccountId(params.accountId ?? resolveDefaultMattermostAccountId(params.cfg));
|
|
24
24
|
const baseEnabled = params.cfg.channels?.mattermost?.enabled !== false;
|
|
25
25
|
const merged = mergeMattermostAccountConfig(params.cfg, accountId);
|
|
@@ -28,15 +28,17 @@ function resolveMattermostAccount(params) {
|
|
|
28
28
|
const allowEnv = accountId === DEFAULT_ACCOUNT_ID;
|
|
29
29
|
const envToken = allowEnv ? process.env.MATTERMOST_BOT_TOKEN?.trim() : void 0;
|
|
30
30
|
const envUrl = allowEnv ? process.env.MATTERMOST_URL?.trim() : void 0;
|
|
31
|
-
const configToken =
|
|
31
|
+
const configToken = resolveSecretInputString({
|
|
32
32
|
value: merged.botToken,
|
|
33
|
-
path: `channels.mattermost.accounts.${accountId}.botToken
|
|
33
|
+
path: `channels.mattermost.accounts.${accountId}.botToken`,
|
|
34
|
+
mode: params.mode
|
|
34
35
|
});
|
|
35
36
|
const configUrl = merged.baseUrl?.trim();
|
|
36
|
-
const botToken = configToken
|
|
37
|
+
const botToken = configToken.status === "available" ? configToken.value : configToken.status === "missing" ? envToken : void 0;
|
|
37
38
|
const baseUrl = normalizeMattermostBaseUrl(configUrl || envUrl);
|
|
38
39
|
const requireMention = resolveMattermostRequireMention(merged);
|
|
39
|
-
const botTokenSource = configToken ? "config" : envToken ? "env" : "none";
|
|
40
|
+
const botTokenSource = configToken.status !== "missing" ? "config" : envToken ? "env" : "none";
|
|
41
|
+
const botTokenStatus = configToken.status !== "missing" ? configToken.status : envToken ? "available" : "missing";
|
|
40
42
|
const baseUrlSource = configUrl ? "config" : envUrl ? "env" : "none";
|
|
41
43
|
return {
|
|
42
44
|
accountId,
|
|
@@ -45,6 +47,7 @@ function resolveMattermostAccount(params) {
|
|
|
45
47
|
botToken,
|
|
46
48
|
baseUrl,
|
|
47
49
|
botTokenSource,
|
|
50
|
+
botTokenStatus,
|
|
48
51
|
baseUrlSource,
|
|
49
52
|
config: merged,
|
|
50
53
|
chatmode: merged.chatmode,
|
|
@@ -57,6 +60,18 @@ function resolveMattermostAccount(params) {
|
|
|
57
60
|
blockStreamingCoalesce: resolveChannelStreamingBlockCoalesce(merged)
|
|
58
61
|
};
|
|
59
62
|
}
|
|
63
|
+
function resolveMattermostAccount(params) {
|
|
64
|
+
return resolveMattermostAccountWithMode({
|
|
65
|
+
...params,
|
|
66
|
+
mode: "strict"
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
function inspectMattermostAccount(params) {
|
|
70
|
+
return resolveMattermostAccountWithMode({
|
|
71
|
+
...params,
|
|
72
|
+
mode: "inspect"
|
|
73
|
+
});
|
|
74
|
+
}
|
|
60
75
|
/**
|
|
61
76
|
* Resolve the effective replyToMode for a given chat type.
|
|
62
77
|
* Direct messages stay flat unless explicitly opted into a per-chat-type mode.
|
|
@@ -68,4 +83,4 @@ function resolveMattermostReplyToMode(account, kind) {
|
|
|
68
83
|
return account.config.replyToMode ?? "off";
|
|
69
84
|
}
|
|
70
85
|
//#endregion
|
|
71
|
-
export {
|
|
86
|
+
export { resolveMattermostReplyToMode as a, resolveMattermostAccount as i, listMattermostAccountIds as n, buildSecretInputSchema as o, resolveDefaultMattermostAccountId as r, hasConfiguredSecretInput as s, inspectMattermostAccount as t };
|
package/dist/api.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { r as isMattermostSenderAllowed } from "./monitor-auth-
|
|
2
|
-
import { t as buildButtonAttachments } from "./interactions-
|
|
1
|
+
import { r as isMattermostSenderAllowed } from "./monitor-auth-rctDliGZ.js";
|
|
2
|
+
import { t as buildButtonAttachments } from "./interactions-BQXY_48h.js";
|
|
3
3
|
export { buildButtonAttachments, isMattermostSenderAllowed };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as isMattermostConfigured, i as mattermostSetupContract, l as mattermostConfigAdapter, n as mattermostSetupWizard, o as MattermostChannelConfigSchema, r as mattermostSetupAdapter, s as describeMattermostAccount, t as mattermostPlugin, u as mattermostMeta } from "./channel-plugin-runtime-
|
|
1
|
+
import { c as isMattermostConfigured, i as mattermostSetupContract, l as mattermostConfigAdapter, n as mattermostSetupWizard, o as MattermostChannelConfigSchema, r as mattermostSetupAdapter, s as describeMattermostAccount, t as mattermostPlugin, u as mattermostMeta } from "./channel-plugin-runtime-DlrMaSIu.js";
|
|
2
2
|
import { t as resolveMattermostGatewayAuthBypassPaths } from "./gateway-auth-bypass-CL1PxV3z.js";
|
|
3
3
|
//#region extensions/mattermost/src/channel.setup.ts
|
|
4
4
|
const mattermostSetupPlugin = {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as
|
|
1
|
+
import { m as normalizeMattermostBaseUrl } from "./client-CqqzTcno.js";
|
|
2
|
+
import { a as resolveMattermostReplyToMode, i as resolveMattermostAccount, n as listMattermostAccountIds, o as buildSecretInputSchema, r as resolveDefaultMattermostAccountId, s as hasConfiguredSecretInput, t as inspectMattermostAccount } from "./accounts-NaMdx9yF.js";
|
|
3
3
|
import { t as resolveMattermostGatewayAuthBypassPaths } from "./gateway-auth-bypass-CL1PxV3z.js";
|
|
4
4
|
import { n as normalizeCompatibilityConfig, t as legacyConfigRules } from "./doctor-contract-BaUvVh8e.js";
|
|
5
5
|
import { n as collectRuntimeConfigAssignments, r as secretTargetRegistryEntries } from "./secret-contract-B4R5Bmhv.js";
|
|
@@ -11,6 +11,8 @@ import { formatNormalizedAllowFromEntries } from "openclaw/plugin-sdk/allow-from
|
|
|
11
11
|
import { createLoggedPairingApprovalNotifier } from "openclaw/plugin-sdk/channel-pairing";
|
|
12
12
|
import { createAccountStatusSink, createChannelMessageAdapterFromOutbound } from "openclaw/plugin-sdk/channel-outbound";
|
|
13
13
|
import { DEFAULT_ACCOUNT_ID as DEFAULT_ACCOUNT_ID$1, buildChannelOutboundSessionRoute, buildThreadAwareOutboundSessionRoute, stripChannelTargetPrefix, stripTargetKindPrefix } from "openclaw/plugin-sdk/core";
|
|
14
|
+
import { jsonResult, readPositiveIntegerParam, readStringParam, withNormalizedTimestamp } from "openclaw/plugin-sdk/channel-actions";
|
|
15
|
+
import { adaptScopedAccountAccessor, createScopedChannelConfigAdapter } from "openclaw/plugin-sdk/channel-config-helpers";
|
|
14
16
|
import { createChannelConfigUiHints, createChatChannelPlugin } from "openclaw/plugin-sdk/channel-core";
|
|
15
17
|
import { buildChannelGroupsScopeTree, buildMutableAllowEntryDetector, collectStandardAllowlistLists, createDangerousNameMatchingMutableAllowlistWarningCollector, createRestrictSendersChannelSecurity, resolveScopeRequireMention } from "openclaw/plugin-sdk/channel-policy";
|
|
16
18
|
import { attachChannelToResult, createAttachedChannelResultAdapter } from "openclaw/plugin-sdk/channel-send-result";
|
|
@@ -23,7 +25,6 @@ import { chunkTextForOutbound, sanitizeAssistantVisibleText } from "openclaw/plu
|
|
|
23
25
|
import { createChannelApprovalAuth } from "openclaw/plugin-sdk/approval-auth-runtime";
|
|
24
26
|
import { describeAccountSnapshot } from "openclaw/plugin-sdk/account-helpers";
|
|
25
27
|
import { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "openclaw/plugin-sdk/account-id";
|
|
26
|
-
import { adaptScopedAccountAccessor, createScopedChannelConfigAdapter } from "openclaw/plugin-sdk/channel-config-helpers";
|
|
27
28
|
import { BlockStreamingCoalesceSchema, ChannelImplicitMentionsSchema, DmPolicySchema, GroupPolicySchema, MarkdownConfigSchema, buildChannelConfigSchema, buildGroupEntrySchema, buildMultiAccountChannelSchema, requireOpenAllowFrom } from "openclaw/plugin-sdk/channel-config-schema";
|
|
28
29
|
import { defineChannelSetupContract } from "openclaw/plugin-sdk/channel-setup";
|
|
29
30
|
import { applyAccountNameToChannelSection, applySetupAccountConfigPatch, baseUrlTextInput, createSetupTranslator, createStandardChannelSetupStatus, defineTokenCredential, formatDocsLink, migrateBaseNameToDefaultAccount, setSetupChannelEnabled } from "openclaw/plugin-sdk/setup";
|
|
@@ -87,7 +88,7 @@ const mattermostConfigAdapter = createScopedChannelConfigAdapter({
|
|
|
87
88
|
})
|
|
88
89
|
});
|
|
89
90
|
function isMattermostConfigured$1(account) {
|
|
90
|
-
return Boolean(account.botToken && account.baseUrl);
|
|
91
|
+
return (account.botTokenStatus ? account.botTokenStatus !== "missing" : Boolean(account.botToken)) && Boolean(account.baseUrl);
|
|
91
92
|
}
|
|
92
93
|
function describeMattermostAccount(account) {
|
|
93
94
|
return describeAccountSnapshot({
|
|
@@ -95,6 +96,7 @@ function describeMattermostAccount(account) {
|
|
|
95
96
|
configured: isMattermostConfigured$1(account),
|
|
96
97
|
extra: {
|
|
97
98
|
botTokenSource: account.botTokenSource,
|
|
99
|
+
botTokenStatus: account.botTokenStatus,
|
|
98
100
|
baseUrl: account.baseUrl
|
|
99
101
|
}
|
|
100
102
|
});
|
|
@@ -215,7 +217,10 @@ const MattermostChannelConfigSchema = buildChannelConfigSchema(buildMultiAccount
|
|
|
215
217
|
replyToMode: MattermostReplyToModeSchema.optional(),
|
|
216
218
|
replyToModeByChatType: MattermostReplyToModeByChatTypeSchema.optional(),
|
|
217
219
|
responsePrefix: z.string().optional(),
|
|
218
|
-
actions: z.object({
|
|
220
|
+
actions: z.object({
|
|
221
|
+
messages: z.boolean().optional(),
|
|
222
|
+
reactions: z.boolean().optional()
|
|
223
|
+
}).optional(),
|
|
219
224
|
commands: MattermostSlashCommandsSchema,
|
|
220
225
|
interactions: z.object({
|
|
221
226
|
callbackBaseUrl: z.string().optional(),
|
|
@@ -244,36 +249,17 @@ const MattermostChannelConfigSchema = buildChannelConfigSchema(buildMultiAccount
|
|
|
244
249
|
...createChannelConfigUiHints({
|
|
245
250
|
channelLabel: "Mattermost",
|
|
246
251
|
dmPolicy: { channelKey: "mattermost" },
|
|
247
|
-
implicitMentions: true
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
},
|
|
257
|
-
...createChannelConfigUiHints({
|
|
258
|
-
channelLabel: "Mattermost",
|
|
252
|
+
implicitMentions: true,
|
|
253
|
+
streaming: {
|
|
254
|
+
"": "Unified Mattermost stream preview mode: \"off\" | \"partial\" | \"block\" | \"progress\". \"progress\" keeps a single editable progress draft until final delivery.",
|
|
255
|
+
mode: "Canonical Mattermost preview mode: \"off\" | \"partial\" | \"block\" | \"progress\".",
|
|
256
|
+
"block.enabled": "Enable chunked block-style Mattermost preview delivery when channels.mattermost.streaming.mode=\"block\".",
|
|
257
|
+
"block.coalesce": "Merge streamed Mattermost block replies before final delivery.",
|
|
258
|
+
"preview.toolProgress": "Show tool/progress activity in the live draft preview post (default: true). Set false to hide interim tool updates while the draft preview stays active.",
|
|
259
|
+
"preview.commandText": "Command/exec detail in preview tool-progress lines: \"raw\" preserves released behavior; \"status\" shows only the tool label."
|
|
260
|
+
},
|
|
259
261
|
progress: {}
|
|
260
|
-
})
|
|
261
|
-
"streaming.preview.toolProgress": {
|
|
262
|
-
label: "Mattermost Draft Tool Progress",
|
|
263
|
-
help: "Show tool/progress activity in the live draft preview post (default: true). Set false to hide interim tool updates while the draft preview stays active."
|
|
264
|
-
},
|
|
265
|
-
"streaming.preview.commandText": {
|
|
266
|
-
label: "Mattermost Draft Command Text",
|
|
267
|
-
help: "Command/exec detail in preview tool-progress lines: \"raw\" preserves released behavior; \"status\" shows only the tool label."
|
|
268
|
-
},
|
|
269
|
-
"streaming.block.enabled": {
|
|
270
|
-
label: "Mattermost Block Streaming Enabled",
|
|
271
|
-
help: "Enable chunked block-style Mattermost preview delivery when channels.mattermost.streaming.mode=\"block\"."
|
|
272
|
-
},
|
|
273
|
-
"streaming.block.coalesce": {
|
|
274
|
-
label: "Mattermost Block Streaming Coalesce",
|
|
275
|
-
help: "Merge streamed Mattermost block replies before final delivery."
|
|
276
|
-
}
|
|
262
|
+
})
|
|
277
263
|
} });
|
|
278
264
|
const mattermostDoctor = {
|
|
279
265
|
legacyConfigRules,
|
|
@@ -335,6 +321,19 @@ function looksLikeMattermostTargetId(raw, _normalized) {
|
|
|
335
321
|
}
|
|
336
322
|
//#endregion
|
|
337
323
|
//#region extensions/mattermost/src/session-route.ts
|
|
324
|
+
/**
|
|
325
|
+
* Reads the peer chat-kind already recorded for `peerId` in an agent session
|
|
326
|
+
* key. Agent session keys are
|
|
327
|
+
* `agent:<agentId>:mattermost:<direct|group|channel>:<peerId>[:thread:...]`, so
|
|
328
|
+
* the segment right after `mattermost:` is the authoritative inbound chat kind.
|
|
329
|
+
*/
|
|
330
|
+
function mattermostSessionKeyPeerKind(sessionKey, peerId) {
|
|
331
|
+
if (!sessionKey || !peerId) return;
|
|
332
|
+
const match = /^agent:[^:]+:mattermost:(direct|group|channel):([^:]+)(?::thread:[^:]+)?$/i.exec(sessionKey);
|
|
333
|
+
const kind = match?.[1]?.toLowerCase();
|
|
334
|
+
if (!kind || match?.[2] !== peerId) return;
|
|
335
|
+
return kind;
|
|
336
|
+
}
|
|
338
337
|
function resolveMattermostOutboundSessionRoute(params) {
|
|
339
338
|
let trimmed = stripChannelTargetPrefix(params.target, "mattermost");
|
|
340
339
|
if (!trimmed) return null;
|
|
@@ -346,6 +345,8 @@ function resolveMattermostOutboundSessionRoute(params) {
|
|
|
346
345
|
if (!rawId) return null;
|
|
347
346
|
const hasExplicitUserKind = resolvedKind === "user" || lower.startsWith("user:");
|
|
348
347
|
const recipientSessionExact = isUser && hasExplicitUserKind && /^[a-z0-9]{26}$/.test(rawId);
|
|
348
|
+
const isGroup = !isUser && (resolvedKind === "group" || resolvedKind !== "channel" && (lower.startsWith("group:") || mattermostSessionKeyPeerKind(params.currentSessionKey, rawId) === "group"));
|
|
349
|
+
const kind = isUser ? "direct" : isGroup ? "group" : "channel";
|
|
349
350
|
return buildThreadAwareOutboundSessionRoute({
|
|
350
351
|
route: buildChannelOutboundSessionRoute({
|
|
351
352
|
cfg: params.cfg,
|
|
@@ -354,11 +355,11 @@ function resolveMattermostOutboundSessionRoute(params) {
|
|
|
354
355
|
accountId: params.accountId,
|
|
355
356
|
recipientSessionExact,
|
|
356
357
|
peer: {
|
|
357
|
-
kind
|
|
358
|
+
kind,
|
|
358
359
|
id: rawId
|
|
359
360
|
},
|
|
360
|
-
chatType:
|
|
361
|
-
from: isUser ? `mattermost:${rawId}` : `mattermost
|
|
361
|
+
chatType: kind,
|
|
362
|
+
from: isUser ? `mattermost:${rawId}` : `mattermost:${kind}:${rawId}`,
|
|
362
363
|
to: isUser ? `user:${rawId}` : `channel:${rawId}`
|
|
363
364
|
}),
|
|
364
365
|
replyToId: params.replyToId,
|
|
@@ -374,10 +375,9 @@ function isMattermostConfigured(account) {
|
|
|
374
375
|
return (Boolean(account.botToken?.trim()) || hasConfiguredSecretInput(account.config.botToken)) && Boolean(account.baseUrl);
|
|
375
376
|
}
|
|
376
377
|
function resolveMattermostAccountWithSecrets(cfg, accountId) {
|
|
377
|
-
return
|
|
378
|
+
return inspectMattermostAccount({
|
|
378
379
|
cfg,
|
|
379
|
-
accountId
|
|
380
|
-
allowUnresolvedSecretRef: true
|
|
380
|
+
accountId
|
|
381
381
|
});
|
|
382
382
|
}
|
|
383
383
|
function applyMattermostSetupConfigPatch(params) {
|
|
@@ -559,7 +559,7 @@ const mattermostSetupWizard = {
|
|
|
559
559
|
};
|
|
560
560
|
//#endregion
|
|
561
561
|
//#region extensions/mattermost/src/channel.ts
|
|
562
|
-
const loadMattermostChannelRuntime = createLazyRuntimeModule(() => import("./channel.runtime-
|
|
562
|
+
const loadMattermostChannelRuntime = createLazyRuntimeModule(() => import("./channel.runtime-DndW9G7T.js"));
|
|
563
563
|
function buildMattermostPresentationButtons(presentation) {
|
|
564
564
|
return presentation.blocks.filter((block) => block.type === "buttons").map((block) => block.buttons.flatMap((button) => {
|
|
565
565
|
if (button.action) return [];
|
|
@@ -587,8 +587,12 @@ function hasMattermostPresentationNavigation(presentation) {
|
|
|
587
587
|
return action?.type === "url" || action?.type === "web-app" && Boolean(action.url);
|
|
588
588
|
}));
|
|
589
589
|
}
|
|
590
|
+
function readMattermostPayloadData(payload) {
|
|
591
|
+
const data = payload.channelData?.mattermost;
|
|
592
|
+
return data && typeof data === "object" && !Array.isArray(data) ? data : void 0;
|
|
593
|
+
}
|
|
590
594
|
function readMattermostPresentationButtons(payload) {
|
|
591
|
-
const buttons = (payload
|
|
595
|
+
const buttons = readMattermostPayloadData(payload)?.presentationButtons;
|
|
592
596
|
return Array.isArray(buttons) ? buttons : void 0;
|
|
593
597
|
}
|
|
594
598
|
const mattermostSecurityAdapter = createRestrictSendersChannelSecurity({
|
|
@@ -604,29 +608,32 @@ const mattermostSecurityAdapter = createRestrictSendersChannelSecurity({
|
|
|
604
608
|
normalizeDmEntry: (raw) => normalizeMattermostAllowEntry(raw)
|
|
605
609
|
});
|
|
606
610
|
function describeMattermostMessageTool({ cfg, accountId }) {
|
|
607
|
-
const enabledAccounts = (accountId ? [
|
|
611
|
+
const enabledAccounts = (accountId ? [inspectMattermostAccount({
|
|
608
612
|
cfg,
|
|
609
613
|
accountId
|
|
610
|
-
})] : listMattermostAccountIds(cfg).map((listedAccountId) =>
|
|
614
|
+
})] : listMattermostAccountIds(cfg).map((listedAccountId) => inspectMattermostAccount({
|
|
611
615
|
cfg,
|
|
612
616
|
accountId: listedAccountId
|
|
613
617
|
}))).filter((account) => account.enabled).filter((account) => Boolean(account.botToken?.trim() && account.baseUrl?.trim()));
|
|
614
618
|
const actions = [];
|
|
615
619
|
if (enabledAccounts.length > 0) actions.push("send");
|
|
616
|
-
const
|
|
620
|
+
const actionsConfig = cfg.channels?.mattermost?.actions;
|
|
621
|
+
const baseMessages = actionsConfig?.messages;
|
|
622
|
+
const baseReactions = actionsConfig?.reactions;
|
|
617
623
|
if (enabledAccounts.some((account) => {
|
|
618
624
|
return account.config.actions?.reactions ?? baseReactions ?? true;
|
|
619
625
|
})) actions.push("react");
|
|
626
|
+
if (enabledAccounts.some((account) => account.config.actions?.messages ?? baseMessages ?? false)) actions.push("read");
|
|
620
627
|
return {
|
|
621
628
|
actions,
|
|
622
629
|
capabilities: enabledAccounts.length > 0 ? ["presentation"] : []
|
|
623
630
|
};
|
|
624
631
|
}
|
|
625
632
|
function hasConfiguredMattermostDirectoryAccount({ cfg, accountId }) {
|
|
626
|
-
return (accountId ? [
|
|
633
|
+
return (accountId ? [inspectMattermostAccount({
|
|
627
634
|
cfg,
|
|
628
635
|
accountId
|
|
629
|
-
})] : listMattermostAccountIds(cfg).map((listedAccountId) =>
|
|
636
|
+
})] : listMattermostAccountIds(cfg).map((listedAccountId) => inspectMattermostAccount({
|
|
630
637
|
cfg,
|
|
631
638
|
accountId: listedAccountId
|
|
632
639
|
}))).some((account) => Boolean(account.enabled && account.botToken?.trim() && account.baseUrl?.trim()));
|
|
@@ -719,10 +726,67 @@ const mattermostMessageActions = {
|
|
|
719
726
|
describeMessageTool: describeMattermostMessageTool,
|
|
720
727
|
extractToolSend: ({ args }) => extractMattermostToolSend(args),
|
|
721
728
|
extractToolSendResult: ({ result, send }) => extractMattermostToolSendResult(result, send),
|
|
729
|
+
prepareSendPayload: ({ ctx, payload }) => {
|
|
730
|
+
if (ctx.action !== "send") return null;
|
|
731
|
+
const mediaUrl = resolveMattermostSendAttachmentMedia(ctx.params);
|
|
732
|
+
const attachmentText = typeof ctx.params.attachmentText === "string" ? ctx.params.attachmentText : void 0;
|
|
733
|
+
const existingMattermostData = readMattermostPayloadData(payload);
|
|
734
|
+
return {
|
|
735
|
+
...payload,
|
|
736
|
+
...mediaUrl ? {
|
|
737
|
+
mediaUrl,
|
|
738
|
+
mediaUrls: [mediaUrl]
|
|
739
|
+
} : {},
|
|
740
|
+
...attachmentText !== void 0 ? { channelData: {
|
|
741
|
+
...payload.channelData,
|
|
742
|
+
mattermost: {
|
|
743
|
+
...existingMattermostData,
|
|
744
|
+
attachmentText
|
|
745
|
+
}
|
|
746
|
+
} } : {}
|
|
747
|
+
};
|
|
748
|
+
},
|
|
722
749
|
supportsAction: ({ action }) => {
|
|
723
|
-
return action === "send" || action === "react";
|
|
750
|
+
return action === "send" || action === "react" || action === "read";
|
|
724
751
|
},
|
|
725
|
-
handleAction: async ({ action, params, cfg, accountId, mediaAccess, mediaLocalRoots, mediaReadFile, conversationReadOrigin }) => {
|
|
752
|
+
handleAction: async ({ action, params, cfg, accountId, mediaAccess, mediaLocalRoots, mediaReadFile, conversationReadOrigin, requesterAccountId, toolContext }) => {
|
|
753
|
+
if (action === "read") {
|
|
754
|
+
const resolvedAccountId = accountId ?? resolveDefaultMattermostAccountId(cfg);
|
|
755
|
+
const mattermostConfig = cfg.channels?.mattermost;
|
|
756
|
+
const account = resolveMattermostAccount({
|
|
757
|
+
cfg,
|
|
758
|
+
accountId: resolvedAccountId
|
|
759
|
+
});
|
|
760
|
+
if (!account.enabled) throw new Error(`Mattermost account "${resolvedAccountId}" is disabled`);
|
|
761
|
+
if (!(account.config.actions?.messages ?? mattermostConfig?.actions?.messages ?? false)) throw new Error("Mattermost message reads are disabled in config");
|
|
762
|
+
const rawTarget = readStringParam(params, "to") ?? readStringParam(params, "channelId") ?? readStringParam(params, "target");
|
|
763
|
+
if (!rawTarget) throw new Error("Mattermost read requires target, to, or channelId.");
|
|
764
|
+
const normalizedTarget = normalizeMattermostMessagingTarget(rawTarget);
|
|
765
|
+
const channelId = normalizedTarget?.startsWith("channel:") ? normalizedTarget.slice(8).trim() : !rawTarget.includes(":") ? rawTarget : "";
|
|
766
|
+
if (!channelId) throw new Error("Mattermost read requires a channel target.");
|
|
767
|
+
const before = readStringParam(params, "before");
|
|
768
|
+
const after = readStringParam(params, "after");
|
|
769
|
+
if (before && after) throw new Error("Mattermost read accepts either before or after, not both.");
|
|
770
|
+
const result = await (await loadMattermostChannelRuntime()).readMattermostMessages({
|
|
771
|
+
cfg,
|
|
772
|
+
channelId,
|
|
773
|
+
limit: readPositiveIntegerParam(params, "limit", { message: "limit must be a positive integer." }),
|
|
774
|
+
before,
|
|
775
|
+
after,
|
|
776
|
+
accountId: resolvedAccountId,
|
|
777
|
+
context: {
|
|
778
|
+
conversationReadOrigin,
|
|
779
|
+
requesterAccountId,
|
|
780
|
+
toolContext
|
|
781
|
+
}
|
|
782
|
+
});
|
|
783
|
+
return jsonResult({
|
|
784
|
+
ok: true,
|
|
785
|
+
channelId,
|
|
786
|
+
messages: result.messages.map((message) => withNormalizedTimestamp(message, message.create_at)),
|
|
787
|
+
hasMore: result.hasMore
|
|
788
|
+
});
|
|
789
|
+
}
|
|
726
790
|
if (action === "react") {
|
|
727
791
|
const resolvedAccountId = accountId ?? resolveDefaultMattermostAccountId(cfg);
|
|
728
792
|
const mattermostConfig = cfg.channels?.mattermost;
|
|
@@ -779,9 +843,7 @@ const mattermostMessageActions = {
|
|
|
779
843
|
}) : typeof params.message === "string" ? params.message : "";
|
|
780
844
|
const replyToId = normalizeOptionalString(params.replyToId) ?? normalizeOptionalString(params.threadId) ?? normalizeOptionalString(params.replyTo);
|
|
781
845
|
const resolvedAccountId = accountId || void 0;
|
|
782
|
-
const
|
|
783
|
-
if (attachmentMedia.hasUnsupportedAttachmentPayload) throw new Error("Mattermost send attachments require media, mediaUrl, path, filePath, fileUrl, mediaUrls, or attachments[] with one of those fields; buffer/base64 payloads are not supported.");
|
|
784
|
-
if (attachmentMedia.mediaUrls.length > 1) throw new Error("Mattermost send supports one attachment per message; split multiple mediaUrls or attachments[] entries into separate sends.");
|
|
846
|
+
const mediaUrl = resolveMattermostSendAttachmentMedia(params);
|
|
785
847
|
const buttons = presentation ? buildMattermostPresentationButtons(presentation) : [];
|
|
786
848
|
const result = await (await loadMattermostChannelRuntime()).sendMessageMattermost(to, message, {
|
|
787
849
|
cfg,
|
|
@@ -789,11 +851,11 @@ const mattermostMessageActions = {
|
|
|
789
851
|
replyToId,
|
|
790
852
|
buttons: buttons.length > 0 ? buttons : void 0,
|
|
791
853
|
attachmentText: typeof params.attachmentText === "string" ? params.attachmentText : void 0,
|
|
792
|
-
mediaUrl
|
|
854
|
+
mediaUrl,
|
|
793
855
|
mediaLocalRoots: mediaLocalRoots ?? mediaAccess?.localRoots,
|
|
794
856
|
mediaReadFile: mediaReadFile ?? mediaAccess?.readFile,
|
|
795
857
|
...mediaAccess?.workspaceDir ? { workspaceDir: mediaAccess.workspaceDir } : {},
|
|
796
|
-
requireMediaUpload: requiresMattermostMediaUpload(
|
|
858
|
+
requireMediaUpload: requiresMattermostMediaUpload(mediaUrl) ? true : void 0
|
|
797
859
|
});
|
|
798
860
|
return {
|
|
799
861
|
content: [{
|
|
@@ -884,6 +946,17 @@ function collectMattermostAttachmentMedia(params) {
|
|
|
884
946
|
hasUnsupportedAttachmentPayload
|
|
885
947
|
};
|
|
886
948
|
}
|
|
949
|
+
function resolveMattermostSendAttachmentMedia(params) {
|
|
950
|
+
const attachmentMedia = collectMattermostAttachmentMedia(params);
|
|
951
|
+
if (attachmentMedia.hasUnsupportedAttachmentPayload) throw new Error("Mattermost send attachments require media, mediaUrl, path, filePath, fileUrl, mediaUrls, or attachments[] with one of those fields; buffer/base64 payloads are not supported.");
|
|
952
|
+
if (attachmentMedia.mediaUrls.length > 1) throw new Error("Mattermost send supports one attachment per message; split multiple mediaUrls or attachments[] entries into separate sends.");
|
|
953
|
+
return attachmentMedia.mediaUrls[0];
|
|
954
|
+
}
|
|
955
|
+
function createMattermostDeliveryProgressReporter(onDeliveryResult) {
|
|
956
|
+
return onDeliveryResult ? async (result) => {
|
|
957
|
+
await onDeliveryResult(attachChannelToResult("mattermost", result));
|
|
958
|
+
} : void 0;
|
|
959
|
+
}
|
|
887
960
|
const mattermostOutbound = {
|
|
888
961
|
deliveryMode: "direct",
|
|
889
962
|
chunker: chunkTextForOutbound,
|
|
@@ -921,7 +994,9 @@ const mattermostOutbound = {
|
|
|
921
994
|
},
|
|
922
995
|
sendPayload: async (ctx) => {
|
|
923
996
|
const buttons = readMattermostPresentationButtons(ctx.payload);
|
|
924
|
-
|
|
997
|
+
const rawAttachmentText = readMattermostPayloadData(ctx.payload)?.attachmentText;
|
|
998
|
+
const attachmentText = typeof rawAttachmentText === "string" ? rawAttachmentText : void 0;
|
|
999
|
+
if (buttons?.length || attachmentText !== void 0) {
|
|
925
1000
|
const mediaUrl = resolvePayloadMediaUrls({
|
|
926
1001
|
...ctx.payload,
|
|
927
1002
|
mediaUrl: ctx.payload.mediaUrl ?? ctx.mediaUrl
|
|
@@ -935,7 +1010,9 @@ const mattermostOutbound = {
|
|
|
935
1010
|
...ctx.mediaAccess?.workspaceDir ? { workspaceDir: ctx.mediaAccess.workspaceDir } : {},
|
|
936
1011
|
requireMediaUpload: requiresMattermostMediaUpload(mediaUrl) ? true : void 0,
|
|
937
1012
|
replyToId: ctx.replyToId ?? (ctx.threadId != null ? String(ctx.threadId) : void 0),
|
|
938
|
-
buttons
|
|
1013
|
+
buttons: buttons?.length ? buttons : void 0,
|
|
1014
|
+
attachmentText,
|
|
1015
|
+
onDeliveryResult: createMattermostDeliveryProgressReporter(ctx.onDeliveryResult)
|
|
939
1016
|
}));
|
|
940
1017
|
}
|
|
941
1018
|
return await sendTextMediaPayload({
|
|
@@ -957,12 +1034,13 @@ const mattermostOutbound = {
|
|
|
957
1034
|
},
|
|
958
1035
|
...createAttachedChannelResultAdapter({
|
|
959
1036
|
channel: "mattermost",
|
|
960
|
-
sendText: async ({ cfg, to, text, accountId, replyToId, threadId }) => await (await loadMattermostChannelRuntime()).sendMessageMattermost(to, text, {
|
|
1037
|
+
sendText: async ({ cfg, to, text, accountId, replyToId, threadId, onDeliveryResult }) => await (await loadMattermostChannelRuntime()).sendMessageMattermost(to, text, {
|
|
961
1038
|
cfg,
|
|
962
1039
|
accountId: accountId ?? void 0,
|
|
963
|
-
replyToId: replyToId ?? (threadId != null ? String(threadId) : void 0)
|
|
1040
|
+
replyToId: replyToId ?? (threadId != null ? String(threadId) : void 0),
|
|
1041
|
+
onDeliveryResult: createMattermostDeliveryProgressReporter(onDeliveryResult)
|
|
964
1042
|
}),
|
|
965
|
-
sendMedia: async ({ cfg, to, text, mediaUrl, mediaAccess, mediaLocalRoots, mediaReadFile, accountId, replyToId, threadId }) => await (await loadMattermostChannelRuntime()).sendMessageMattermost(to, text, {
|
|
1043
|
+
sendMedia: async ({ cfg, to, text, mediaUrl, mediaAccess, mediaLocalRoots, mediaReadFile, accountId, replyToId, threadId, onDeliveryResult }) => await (await loadMattermostChannelRuntime()).sendMessageMattermost(to, text, {
|
|
966
1044
|
cfg,
|
|
967
1045
|
accountId: accountId ?? void 0,
|
|
968
1046
|
mediaUrl,
|
|
@@ -970,7 +1048,8 @@ const mattermostOutbound = {
|
|
|
970
1048
|
mediaReadFile: mediaReadFile ?? mediaAccess?.readFile,
|
|
971
1049
|
...mediaAccess?.workspaceDir ? { workspaceDir: mediaAccess.workspaceDir } : {},
|
|
972
1050
|
requireMediaUpload: requiresMattermostMediaUpload(mediaUrl) ? true : void 0,
|
|
973
|
-
replyToId: replyToId ?? (threadId != null ? String(threadId) : void 0)
|
|
1051
|
+
replyToId: replyToId ?? (threadId != null ? String(threadId) : void 0),
|
|
1052
|
+
onDeliveryResult: createMattermostDeliveryProgressReporter(onDeliveryResult)
|
|
974
1053
|
})
|
|
975
1054
|
})
|
|
976
1055
|
};
|
|
@@ -1024,6 +1103,7 @@ const mattermostPlugin = createChatChannelPlugin({
|
|
|
1024
1103
|
configSchema: MattermostChannelConfigSchema,
|
|
1025
1104
|
config: {
|
|
1026
1105
|
...mattermostConfigAdapter,
|
|
1106
|
+
inspectAccount: adaptScopedAccountAccessor(inspectMattermostAccount),
|
|
1027
1107
|
isConfigured: isMattermostConfigured$1,
|
|
1028
1108
|
describeAccount: describeMattermostAccount
|
|
1029
1109
|
},
|
|
@@ -1102,6 +1182,7 @@ const mattermostPlugin = createChatChannelPlugin({
|
|
|
1102
1182
|
configured: Boolean(account.botToken && account.baseUrl),
|
|
1103
1183
|
extra: {
|
|
1104
1184
|
botTokenSource: account.botTokenSource,
|
|
1185
|
+
botTokenStatus: account.botTokenStatus,
|
|
1105
1186
|
baseUrl: account.baseUrl,
|
|
1106
1187
|
dmPolicy: account.config.dmPolicy ?? "pairing",
|
|
1107
1188
|
connected: runtime?.connected ?? false,
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as mattermostPlugin } from "./channel-plugin-runtime-
|
|
1
|
+
import { t as mattermostPlugin } from "./channel-plugin-runtime-DlrMaSIu.js";
|
|
2
2
|
export { mattermostPlugin };
|