@openclaw/mattermost 2026.7.2-beta.1 → 2026.7.2-beta.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/accounts-B-GrNVwP.js +83 -0
- package/dist/api.js +3 -2
- package/dist/channel-plugin-api.js +9 -2
- package/dist/{channel-plugin-runtime-BkzZgYxP.js → channel-plugin-runtime-BfV83pya.js} +86 -92
- package/dist/channel-plugin-runtime.js +1 -1
- package/dist/{channel.runtime-Cbs451W2.js → channel.runtime-DbsfMgC4.js} +1352 -1144
- package/dist/{accounts-B2NRPlqr.js → client-w0lkxuKh.js} +13 -83
- package/dist/interactions-BIb5iJjA.js +375 -0
- package/dist/{monitor-auth-BiDuyvOc.js → monitor-auth-ynw9EnGC.js} +12 -9
- package/dist/policy-api.js +1 -1
- package/dist/slash-route-api.js +1 -1
- package/dist/{slash-state-Cr58Xd12.js → slash-state-N-zfDDSz.js} +45 -416
- package/npm-shrinkwrap.json +3 -3
- package/openclaw.plugin.json +74 -0
- package/package.json +4 -4
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { p as normalizeMattermostBaseUrl } from "./client-w0lkxuKh.js";
|
|
2
|
+
import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
3
|
+
import { resolveChannelPreviewStreamMode, resolveChannelStreamingBlockCoalesce, resolveChannelStreamingBlockEnabled, resolveChannelStreamingChunkMode } from "openclaw/plugin-sdk/channel-outbound";
|
|
4
|
+
import { createAccountListHelpers, hasConfiguredAccountValue } from "openclaw/plugin-sdk/account-helpers";
|
|
5
|
+
import { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "openclaw/plugin-sdk/account-id";
|
|
6
|
+
import { resolveMergedAccountConfig } from "openclaw/plugin-sdk/account-resolution";
|
|
7
|
+
import { buildSecretInputSchema, hasConfiguredSecretInput, normalizeResolvedSecretInputString, normalizeSecretInputString } from "openclaw/plugin-sdk/secret-input";
|
|
8
|
+
//#region extensions/mattermost/src/mattermost/accounts.ts
|
|
9
|
+
const mattermostAccountHelpers = createAccountListHelpers("mattermost", { hasImplicitDefaultAccount: (cfg) => {
|
|
10
|
+
const mattermost = cfg.channels?.mattermost;
|
|
11
|
+
return Boolean(mattermost?.baseUrl?.trim() && (hasConfiguredAccountValue(mattermost.botToken) || process.env.MATTERMOST_BOT_TOKEN?.trim()));
|
|
12
|
+
} });
|
|
13
|
+
function listMattermostAccountIds(cfg) {
|
|
14
|
+
return mattermostAccountHelpers.listAccountIds(cfg);
|
|
15
|
+
}
|
|
16
|
+
function resolveDefaultMattermostAccountId(cfg) {
|
|
17
|
+
return mattermostAccountHelpers.resolveDefaultAccountId(cfg);
|
|
18
|
+
}
|
|
19
|
+
function mergeMattermostAccountConfig(cfg, accountId) {
|
|
20
|
+
return resolveMergedAccountConfig({
|
|
21
|
+
channelConfig: cfg.channels?.mattermost,
|
|
22
|
+
accounts: cfg.channels?.mattermost?.accounts,
|
|
23
|
+
accountId,
|
|
24
|
+
omitKeys: ["defaultAccount"],
|
|
25
|
+
nestedObjectKeys: ["commands"]
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
function resolveMattermostRequireMention(config) {
|
|
29
|
+
if (config.chatmode === "oncall") return true;
|
|
30
|
+
if (config.chatmode === "onmessage") return false;
|
|
31
|
+
if (config.chatmode === "onchar") return true;
|
|
32
|
+
return config.requireMention;
|
|
33
|
+
}
|
|
34
|
+
function resolveMattermostAccount(params) {
|
|
35
|
+
const accountId = normalizeAccountId(params.accountId ?? resolveDefaultMattermostAccountId(params.cfg));
|
|
36
|
+
const baseEnabled = params.cfg.channels?.mattermost?.enabled !== false;
|
|
37
|
+
const merged = mergeMattermostAccountConfig(params.cfg, accountId);
|
|
38
|
+
const accountEnabled = merged.enabled !== false;
|
|
39
|
+
const enabled = baseEnabled && accountEnabled;
|
|
40
|
+
const allowEnv = accountId === DEFAULT_ACCOUNT_ID;
|
|
41
|
+
const envToken = allowEnv ? process.env.MATTERMOST_BOT_TOKEN?.trim() : void 0;
|
|
42
|
+
const envUrl = allowEnv ? process.env.MATTERMOST_URL?.trim() : void 0;
|
|
43
|
+
const configToken = params.allowUnresolvedSecretRef ? normalizeSecretInputString(merged.botToken) : normalizeResolvedSecretInputString({
|
|
44
|
+
value: merged.botToken,
|
|
45
|
+
path: `channels.mattermost.accounts.${accountId}.botToken`
|
|
46
|
+
});
|
|
47
|
+
const configUrl = merged.baseUrl?.trim();
|
|
48
|
+
const botToken = configToken || envToken;
|
|
49
|
+
const baseUrl = normalizeMattermostBaseUrl(configUrl || envUrl);
|
|
50
|
+
const requireMention = resolveMattermostRequireMention(merged);
|
|
51
|
+
const botTokenSource = configToken ? "config" : envToken ? "env" : "none";
|
|
52
|
+
const baseUrlSource = configUrl ? "config" : envUrl ? "env" : "none";
|
|
53
|
+
return {
|
|
54
|
+
accountId,
|
|
55
|
+
enabled,
|
|
56
|
+
name: normalizeOptionalString(merged.name),
|
|
57
|
+
botToken,
|
|
58
|
+
baseUrl,
|
|
59
|
+
botTokenSource,
|
|
60
|
+
baseUrlSource,
|
|
61
|
+
config: merged,
|
|
62
|
+
chatmode: merged.chatmode,
|
|
63
|
+
oncharPrefixes: merged.oncharPrefixes,
|
|
64
|
+
requireMention,
|
|
65
|
+
textChunkLimit: merged.textChunkLimit,
|
|
66
|
+
chunkMode: resolveChannelStreamingChunkMode(merged),
|
|
67
|
+
streamingMode: resolveChannelPreviewStreamMode(merged, "partial"),
|
|
68
|
+
blockStreaming: resolveChannelStreamingBlockEnabled(merged),
|
|
69
|
+
blockStreamingCoalesce: resolveChannelStreamingBlockCoalesce(merged)
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Resolve the effective replyToMode for a given chat type.
|
|
74
|
+
* Direct messages stay flat unless explicitly opted into a per-chat-type mode.
|
|
75
|
+
*/
|
|
76
|
+
function resolveMattermostReplyToMode(account, kind) {
|
|
77
|
+
const scopedMode = account.config.replyToModeByChatType?.[kind];
|
|
78
|
+
if (scopedMode !== void 0) return scopedMode;
|
|
79
|
+
if (kind === "direct") return "off";
|
|
80
|
+
return account.config.replyToMode ?? "off";
|
|
81
|
+
}
|
|
82
|
+
//#endregion
|
|
83
|
+
export { buildSecretInputSchema as a, resolveMattermostReplyToMode as i, resolveDefaultMattermostAccountId as n, hasConfiguredSecretInput as o, resolveMattermostAccount as r, listMattermostAccountIds as t };
|
package/dist/api.js
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import { r as isMattermostSenderAllowed } from "./monitor-auth-
|
|
2
|
-
|
|
1
|
+
import { r as isMattermostSenderAllowed } from "./monitor-auth-ynw9EnGC.js";
|
|
2
|
+
import { t as buildButtonAttachments } from "./interactions-BIb5iJjA.js";
|
|
3
|
+
export { buildButtonAttachments, isMattermostSenderAllowed };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as
|
|
1
|
+
import { a as MattermostChannelConfigSchema, c as mattermostConfigAdapter, l as mattermostMeta, n as mattermostSetupWizard, o as describeMattermostAccount, r as mattermostSetupAdapter, s as isMattermostConfigured, t as mattermostPlugin } from "./channel-plugin-runtime-BfV83pya.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 = {
|
|
@@ -16,7 +16,14 @@ const mattermostSetupPlugin = {
|
|
|
16
16
|
media: true,
|
|
17
17
|
nativeCommands: true
|
|
18
18
|
},
|
|
19
|
-
reload: {
|
|
19
|
+
reload: {
|
|
20
|
+
configPrefixes: ["channels.mattermost"],
|
|
21
|
+
/**
|
|
22
|
+
* accounts.default is promoted; named resolution merges only channel-wide fields
|
|
23
|
+
* plus the selected account. Runtime monitor, debounce, and ingress use accountId.
|
|
24
|
+
*/
|
|
25
|
+
accountScopedRestart: true
|
|
26
|
+
},
|
|
20
27
|
configSchema: MattermostChannelConfigSchema,
|
|
21
28
|
config: {
|
|
22
29
|
...mattermostConfigAdapter,
|
|
@@ -1,30 +1,31 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { p as normalizeMattermostBaseUrl } from "./client-w0lkxuKh.js";
|
|
2
|
+
import { a as buildSecretInputSchema, i as resolveMattermostReplyToMode, n as resolveDefaultMattermostAccountId, o as hasConfiguredSecretInput, r as resolveMattermostAccount, t as listMattermostAccountIds } from "./accounts-B-GrNVwP.js";
|
|
2
3
|
import { t as resolveMattermostGatewayAuthBypassPaths } from "./gateway-auth-bypass-CL1PxV3z.js";
|
|
3
4
|
import { n as normalizeCompatibilityConfig, t as legacyConfigRules } from "./doctor-contract-BaUvVh8e.js";
|
|
4
5
|
import { n as collectRuntimeConfigAssignments, r as secretTargetRegistryEntries } from "./secret-contract-B4R5Bmhv.js";
|
|
5
6
|
import { normalizeLowercaseStringOrEmpty, normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
7
|
+
import { buildPassiveProbedChannelStatusSummary } from "openclaw/plugin-sdk/extension-shared";
|
|
8
|
+
import { isPrivateNetworkOptInEnabled } from "openclaw/plugin-sdk/ssrf-runtime";
|
|
9
|
+
import { z } from "zod";
|
|
6
10
|
import { formatNormalizedAllowFromEntries } from "openclaw/plugin-sdk/allow-from";
|
|
7
11
|
import { createLoggedPairingApprovalNotifier } from "openclaw/plugin-sdk/channel-pairing";
|
|
8
12
|
import { createAccountStatusSink, createChannelMessageAdapterFromOutbound } from "openclaw/plugin-sdk/channel-outbound";
|
|
9
13
|
import { DEFAULT_ACCOUNT_ID as DEFAULT_ACCOUNT_ID$1, buildChannelOutboundSessionRoute, buildThreadAwareOutboundSessionRoute, stripChannelTargetPrefix, stripTargetKindPrefix } from "openclaw/plugin-sdk/core";
|
|
10
14
|
import { createChannelConfigUiHints, createChatChannelPlugin } from "openclaw/plugin-sdk/channel-core";
|
|
11
|
-
import { buildChannelGroupsScopeTree, createDangerousNameMatchingMutableAllowlistWarningCollector, createRestrictSendersChannelSecurity, resolveScopeRequireMention } from "openclaw/plugin-sdk/channel-policy";
|
|
15
|
+
import { buildChannelGroupsScopeTree, buildMutableAllowEntryDetector, collectStandardAllowlistLists, createDangerousNameMatchingMutableAllowlistWarningCollector, createRestrictSendersChannelSecurity, resolveScopeRequireMention } from "openclaw/plugin-sdk/channel-policy";
|
|
12
16
|
import { attachChannelToResult, createAttachedChannelResultAdapter } from "openclaw/plugin-sdk/channel-send-result";
|
|
13
17
|
import { createChannelDirectoryAdapter } from "openclaw/plugin-sdk/directory-runtime";
|
|
14
|
-
import { buildPassiveProbedChannelStatusSummary } from "openclaw/plugin-sdk/extension-shared";
|
|
15
18
|
import { normalizeMessagePresentation, renderMessagePresentationFallbackText, resolveMessagePresentationButtonAction, resolveMessagePresentationControlValue } from "openclaw/plugin-sdk/interactive-runtime";
|
|
16
19
|
import { createLazyRuntimeModule } from "openclaw/plugin-sdk/lazy-runtime";
|
|
17
20
|
import { resolvePayloadMediaUrls, sendTextMediaPayload } from "openclaw/plugin-sdk/reply-payload";
|
|
18
|
-
import { isPrivateNetworkOptInEnabled } from "openclaw/plugin-sdk/ssrf-runtime";
|
|
19
21
|
import { createComputedAccountStatusAdapter, createDefaultChannelRuntimeState } from "openclaw/plugin-sdk/status-helpers";
|
|
20
22
|
import { chunkTextForOutbound, sanitizeAssistantVisibleText } from "openclaw/plugin-sdk/text-chunking";
|
|
21
23
|
import { createChannelApprovalAuth } from "openclaw/plugin-sdk/approval-auth-runtime";
|
|
22
24
|
import { describeAccountSnapshot } from "openclaw/plugin-sdk/account-helpers";
|
|
23
25
|
import { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "openclaw/plugin-sdk/account-id";
|
|
24
|
-
import { z } from "zod";
|
|
25
26
|
import { adaptScopedAccountAccessor, createScopedChannelConfigAdapter } from "openclaw/plugin-sdk/channel-config-helpers";
|
|
26
|
-
import { BlockStreamingCoalesceSchema, DmPolicySchema, GroupPolicySchema, MarkdownConfigSchema, buildChannelConfigSchema, requireOpenAllowFrom } from "openclaw/plugin-sdk/channel-config-schema";
|
|
27
|
-
import { applyAccountNameToChannelSection, applySetupAccountConfigPatch, createSetupTranslator, createStandardChannelSetupStatus, formatDocsLink, migrateBaseNameToDefaultAccount } from "openclaw/plugin-sdk/setup";
|
|
27
|
+
import { BlockStreamingCoalesceSchema, ChannelImplicitMentionsSchema, DmPolicySchema, GroupPolicySchema, MarkdownConfigSchema, buildChannelConfigSchema, buildGroupEntrySchema, buildMultiAccountChannelSchema, requireOpenAllowFrom } from "openclaw/plugin-sdk/channel-config-schema";
|
|
28
|
+
import { applyAccountNameToChannelSection, applySetupAccountConfigPatch, baseUrlTextInput, createSetupTranslator, createStandardChannelSetupStatus, defineTokenCredential, formatDocsLink, migrateBaseNameToDefaultAccount, setSetupChannelEnabled } from "openclaw/plugin-sdk/setup";
|
|
28
29
|
import { createSetupInputPresenceValidator } from "openclaw/plugin-sdk/setup-runtime";
|
|
29
30
|
//#region extensions/mattermost/src/approval-auth.ts
|
|
30
31
|
const MATTERMOST_USER_ID_RE = /^[a-z0-9]{26}$/;
|
|
@@ -99,9 +100,14 @@ function describeMattermostAccount(account) {
|
|
|
99
100
|
}
|
|
100
101
|
//#endregion
|
|
101
102
|
//#region extensions/mattermost/src/config-schema-core.ts
|
|
102
|
-
const MattermostGroupSchema =
|
|
103
|
-
|
|
104
|
-
|
|
103
|
+
const MattermostGroupSchema = buildGroupEntrySchema().omit({
|
|
104
|
+
tools: true,
|
|
105
|
+
toolsBySender: true,
|
|
106
|
+
skills: true,
|
|
107
|
+
enabled: true,
|
|
108
|
+
allowFrom: true,
|
|
109
|
+
systemPrompt: true
|
|
110
|
+
});
|
|
105
111
|
function requireMattermostOpenAllowFrom(params) {
|
|
106
112
|
requireOpenAllowFrom({
|
|
107
113
|
policy: params.policy,
|
|
@@ -151,9 +157,13 @@ const MattermostStreamingProgressSchema = z.object({
|
|
|
151
157
|
labels: z.array(z.string()).optional(),
|
|
152
158
|
maxLines: z.number().int().positive().optional(),
|
|
153
159
|
maxLineChars: z.number().int().positive().optional(),
|
|
154
|
-
toolProgress: z.boolean().optional()
|
|
160
|
+
toolProgress: z.boolean().optional(),
|
|
161
|
+
commandText: z.enum(["raw", "status"]).optional()
|
|
162
|
+
}).strict();
|
|
163
|
+
const MattermostStreamingPreviewSchema = z.object({
|
|
164
|
+
toolProgress: z.boolean().optional(),
|
|
165
|
+
commandText: z.enum(["raw", "status"]).optional()
|
|
155
166
|
}).strict();
|
|
156
|
-
const MattermostStreamingPreviewSchema = z.object({ toolProgress: z.boolean().optional() }).strict();
|
|
157
167
|
const MattermostStreamingBlockSchema = z.object({
|
|
158
168
|
enabled: z.boolean().optional(),
|
|
159
169
|
coalesce: BlockStreamingCoalesceSchema.optional()
|
|
@@ -176,7 +186,9 @@ const MattermostReplyToModeByChatTypeSchema = z.object({
|
|
|
176
186
|
group: MattermostReplyToModeSchema.optional(),
|
|
177
187
|
channel: MattermostReplyToModeSchema.optional()
|
|
178
188
|
}).strict();
|
|
179
|
-
|
|
189
|
+
//#endregion
|
|
190
|
+
//#region extensions/mattermost/src/config-surface.ts
|
|
191
|
+
const MattermostChannelConfigSchema = buildChannelConfigSchema(buildMultiAccountChannelSchema(z.object({
|
|
180
192
|
name: z.string().optional(),
|
|
181
193
|
capabilities: z.array(z.string()).optional(),
|
|
182
194
|
dangerouslyAllowNameMatching: z.boolean().optional(),
|
|
@@ -192,6 +204,7 @@ const MattermostAccountSchemaBase = z.object({
|
|
|
192
204
|
]).optional(),
|
|
193
205
|
oncharPrefixes: z.array(z.string()).optional(),
|
|
194
206
|
requireMention: z.boolean().optional(),
|
|
207
|
+
implicitMentions: ChannelImplicitMentionsSchema.optional(),
|
|
195
208
|
dmPolicy: DmPolicySchema.optional().default("pairing"),
|
|
196
209
|
allowFrom: z.array(z.union([z.string(), z.number()])).optional(),
|
|
197
210
|
groupAllowFrom: z.array(z.union([z.string(), z.number()])).optional(),
|
|
@@ -213,25 +226,15 @@ const MattermostAccountSchemaBase = z.object({
|
|
|
213
226
|
network: MattermostNetworkSchema,
|
|
214
227
|
/** Retry configuration for DM channel creation */
|
|
215
228
|
dmChannelRetry: DmChannelRetrySchema
|
|
216
|
-
}).strict()
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
});
|
|
224
|
-
|
|
225
|
-
//#region extensions/mattermost/src/config-surface.ts
|
|
226
|
-
const MattermostChannelConfigSchema = buildChannelConfigSchema(MattermostAccountSchemaBase.extend({
|
|
227
|
-
accounts: z.record(z.string(), MattermostAccountSchema.optional()).optional(),
|
|
228
|
-
defaultAccount: z.string().optional()
|
|
229
|
-
}).superRefine((value, ctx) => {
|
|
230
|
-
requireMattermostOpenAllowFrom({
|
|
231
|
-
policy: value.dmPolicy,
|
|
232
|
-
allowFrom: value.allowFrom,
|
|
233
|
-
ctx
|
|
234
|
-
});
|
|
229
|
+
}).strict(), {
|
|
230
|
+
optionalAccount: true,
|
|
231
|
+
refine: (value, ctx) => {
|
|
232
|
+
requireMattermostOpenAllowFrom({
|
|
233
|
+
policy: value.dmPolicy,
|
|
234
|
+
allowFrom: value.allowFrom,
|
|
235
|
+
ctx
|
|
236
|
+
});
|
|
237
|
+
}
|
|
235
238
|
}), { uiHints: {
|
|
236
239
|
"": {
|
|
237
240
|
label: "Mattermost",
|
|
@@ -239,7 +242,8 @@ const MattermostChannelConfigSchema = buildChannelConfigSchema(MattermostAccount
|
|
|
239
242
|
},
|
|
240
243
|
...createChannelConfigUiHints({
|
|
241
244
|
channelLabel: "Mattermost",
|
|
242
|
-
dmPolicy: { channelKey: "mattermost" }
|
|
245
|
+
dmPolicy: { channelKey: "mattermost" },
|
|
246
|
+
implicitMentions: true
|
|
243
247
|
}),
|
|
244
248
|
streaming: {
|
|
245
249
|
label: "Mattermost Streaming Mode",
|
|
@@ -270,28 +274,13 @@ const MattermostChannelConfigSchema = buildChannelConfigSchema(MattermostAccount
|
|
|
270
274
|
help: "Merge streamed Mattermost block replies before final delivery."
|
|
271
275
|
}
|
|
272
276
|
} });
|
|
273
|
-
//#endregion
|
|
274
|
-
//#region extensions/mattermost/src/doctor.ts
|
|
275
|
-
function isMattermostMutableAllowEntry(raw) {
|
|
276
|
-
const text = raw.trim();
|
|
277
|
-
if (!text || text === "*") return false;
|
|
278
|
-
const lowered = normalizeLowercaseStringOrEmpty(text.replace(/^(mattermost|user):/i, "").replace(/^@/, "").trim());
|
|
279
|
-
if (/^[a-z0-9]{26}$/.test(lowered)) return false;
|
|
280
|
-
return true;
|
|
281
|
-
}
|
|
282
277
|
const mattermostDoctor = {
|
|
283
278
|
legacyConfigRules,
|
|
284
279
|
normalizeCompatibilityConfig,
|
|
285
280
|
collectMutableAllowlistWarnings: createDangerousNameMatchingMutableAllowlistWarningCollector({
|
|
286
281
|
channel: "mattermost",
|
|
287
|
-
detector:
|
|
288
|
-
collectLists: (scope) =>
|
|
289
|
-
pathLabel: `${scope.prefix}.allowFrom`,
|
|
290
|
-
list: scope.account.allowFrom
|
|
291
|
-
}, {
|
|
292
|
-
pathLabel: `${scope.prefix}.groupAllowFrom`,
|
|
293
|
-
list: scope.account.groupAllowFrom
|
|
294
|
-
}]
|
|
282
|
+
detector: buildMutableAllowEntryDetector({ stableIdPattern: /^(?:(?:mattermost|user):)?@?[a-z0-9]{26}$/i }),
|
|
283
|
+
collectLists: (scope) => collectStandardAllowlistLists(scope)
|
|
295
284
|
})
|
|
296
285
|
};
|
|
297
286
|
//#endregion
|
|
@@ -489,60 +478,50 @@ const mattermostSetupWizard = {
|
|
|
489
478
|
patch: {}
|
|
490
479
|
})
|
|
491
480
|
},
|
|
492
|
-
credentials: [{
|
|
481
|
+
credentials: [defineTokenCredential({
|
|
493
482
|
inputKey: "botToken",
|
|
483
|
+
configKey: "botToken",
|
|
494
484
|
providerHint: channel,
|
|
495
485
|
credentialLabel: t("wizard.mattermost.botToken"),
|
|
496
486
|
preferredEnvVar: "MATTERMOST_BOT_TOKEN",
|
|
497
487
|
envPrompt: t("wizard.mattermost.envPrompt"),
|
|
498
488
|
keepPrompt: t("wizard.mattermost.botTokenKeep"),
|
|
499
489
|
inputPrompt: t("wizard.mattermost.botTokenInput"),
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
accountConfigured: isMattermostConfigured(resolvedAccount),
|
|
504
|
-
hasConfiguredValue: hasConfiguredSecretInput(resolvedAccount.config.botToken)
|
|
505
|
-
};
|
|
506
|
-
},
|
|
507
|
-
applySet: async ({ cfg, accountId, value }) => applyMattermostSetupConfigPatch({
|
|
490
|
+
resolveAccount: ({ cfg, accountId }) => resolveMattermostAccountWithSecrets(cfg, accountId),
|
|
491
|
+
accountConfigured: isMattermostConfigured,
|
|
492
|
+
patchAccount: ({ cfg, accountId, patch }) => applyMattermostSetupConfigPatch({
|
|
508
493
|
cfg,
|
|
509
494
|
accountId,
|
|
510
|
-
patch
|
|
511
|
-
})
|
|
512
|
-
|
|
513
|
-
|
|
495
|
+
patch
|
|
496
|
+
}),
|
|
497
|
+
set: {}
|
|
498
|
+
})],
|
|
499
|
+
textInputs: [baseUrlTextInput({
|
|
514
500
|
inputKey: "httpUrl",
|
|
501
|
+
configKey: "baseUrl",
|
|
515
502
|
message: t("wizard.mattermost.baseUrlPrompt"),
|
|
516
503
|
confirmCurrentValue: false,
|
|
517
|
-
|
|
518
|
-
|
|
504
|
+
resolveAccount: ({ cfg, accountId }) => resolveMattermostAccountWithSecrets(cfg, accountId),
|
|
505
|
+
currentValue: (account) => account.baseUrl ?? process.env.MATTERMOST_URL?.trim(),
|
|
506
|
+
includeInitialValue: true,
|
|
519
507
|
shouldPrompt: ({ cfg, accountId, credentialValues, currentValue }) => {
|
|
520
508
|
const resolvedAccount = resolveMattermostAccountWithSecrets(cfg, accountId);
|
|
521
509
|
const tokenConfigured = Boolean(resolvedAccount.botToken?.trim()) || hasConfiguredSecretInput(resolvedAccount.config.botToken);
|
|
522
510
|
return Boolean(credentialValues.botToken) || !tokenConfigured || !currentValue;
|
|
523
511
|
},
|
|
524
|
-
validate: (
|
|
525
|
-
|
|
526
|
-
|
|
512
|
+
validate: (value) => normalizeMattermostBaseUrl(value) ? void 0 : "Mattermost base URL must include a valid base URL.",
|
|
513
|
+
normalize: (value) => normalizeMattermostBaseUrl(value) ?? value.trim(),
|
|
514
|
+
patchAccount: ({ cfg, accountId, patch }) => applyMattermostSetupConfigPatch({
|
|
527
515
|
cfg,
|
|
528
516
|
accountId,
|
|
529
|
-
patch
|
|
517
|
+
patch
|
|
530
518
|
})
|
|
531
|
-
}],
|
|
532
|
-
disable: (cfg) => (
|
|
533
|
-
...cfg,
|
|
534
|
-
channels: {
|
|
535
|
-
...cfg.channels,
|
|
536
|
-
mattermost: {
|
|
537
|
-
...cfg.channels?.mattermost,
|
|
538
|
-
enabled: false
|
|
539
|
-
}
|
|
540
|
-
}
|
|
541
|
-
})
|
|
519
|
+
})],
|
|
520
|
+
disable: (cfg) => setSetupChannelEnabled(cfg, channel, false)
|
|
542
521
|
};
|
|
543
522
|
//#endregion
|
|
544
523
|
//#region extensions/mattermost/src/channel.ts
|
|
545
|
-
const loadMattermostChannelRuntime = createLazyRuntimeModule(() => import("./channel.runtime-
|
|
524
|
+
const loadMattermostChannelRuntime = createLazyRuntimeModule(() => import("./channel.runtime-DbsfMgC4.js"));
|
|
546
525
|
function buildMattermostPresentationButtons(presentation) {
|
|
547
526
|
return presentation.blocks.filter((block) => block.type === "buttons").map((block) => block.buttons.flatMap((button) => {
|
|
548
527
|
if (button.action) return [];
|
|
@@ -567,7 +546,7 @@ const MATTERMOST_PRESENTATION_CAPABILITIES = {
|
|
|
567
546
|
function hasMattermostPresentationNavigation(presentation) {
|
|
568
547
|
return presentation.blocks.some((block) => block.type === "buttons" && block.buttons.some((button) => {
|
|
569
548
|
const action = resolveMessagePresentationButtonAction(button);
|
|
570
|
-
return action?.type === "url" || action?.type === "web-app";
|
|
549
|
+
return action?.type === "url" || action?.type === "web-app" && Boolean(action.url);
|
|
571
550
|
}));
|
|
572
551
|
}
|
|
573
552
|
function readMattermostPresentationButtons(payload) {
|
|
@@ -705,21 +684,26 @@ const mattermostMessageActions = {
|
|
|
705
684
|
supportsAction: ({ action }) => {
|
|
706
685
|
return action === "send" || action === "react";
|
|
707
686
|
},
|
|
708
|
-
handleAction: async ({ action, params, cfg, accountId, mediaAccess, mediaLocalRoots, mediaReadFile }) => {
|
|
687
|
+
handleAction: async ({ action, params, cfg, accountId, mediaAccess, mediaLocalRoots, mediaReadFile, conversationReadOrigin }) => {
|
|
709
688
|
if (action === "react") {
|
|
710
689
|
const resolvedAccountId = accountId ?? resolveDefaultMattermostAccountId(cfg);
|
|
711
690
|
const mattermostConfig = cfg.channels?.mattermost;
|
|
712
|
-
|
|
691
|
+
const account = resolveMattermostAccount({
|
|
713
692
|
cfg,
|
|
714
693
|
accountId: resolvedAccountId
|
|
715
|
-
})
|
|
694
|
+
});
|
|
695
|
+
if (!account.enabled) throw new Error(`Mattermost account "${resolvedAccountId}" is disabled`);
|
|
696
|
+
if (!(account.config.actions?.reactions ?? mattermostConfig?.actions?.reactions ?? true)) throw new Error("Mattermost reactions are disabled in config");
|
|
716
697
|
const { postId, emojiName, remove } = parseMattermostReactActionParams(params);
|
|
698
|
+
const authorizedTarget = normalizeOptionalString(params.to);
|
|
717
699
|
if (remove) {
|
|
718
700
|
const result = await (await loadMattermostChannelRuntime()).removeMattermostReaction({
|
|
719
701
|
cfg,
|
|
720
702
|
postId,
|
|
721
703
|
emojiName,
|
|
722
|
-
accountId: resolvedAccountId
|
|
704
|
+
accountId: resolvedAccountId,
|
|
705
|
+
authorizedTarget,
|
|
706
|
+
conversationReadOrigin
|
|
723
707
|
});
|
|
724
708
|
if (!result.ok) throw new Error(result.error);
|
|
725
709
|
return {
|
|
@@ -734,7 +718,9 @@ const mattermostMessageActions = {
|
|
|
734
718
|
cfg,
|
|
735
719
|
postId,
|
|
736
720
|
emojiName,
|
|
737
|
-
accountId: resolvedAccountId
|
|
721
|
+
accountId: resolvedAccountId,
|
|
722
|
+
authorizedTarget,
|
|
723
|
+
conversationReadOrigin
|
|
738
724
|
});
|
|
739
725
|
if (!result.ok) throw new Error(result.error);
|
|
740
726
|
return {
|
|
@@ -848,13 +834,12 @@ function collectMattermostAttachmentMedia(params) {
|
|
|
848
834
|
readMattermostStringParam(params, "fileUrl")
|
|
849
835
|
];
|
|
850
836
|
mediaUrlCandidates.push(...readMattermostStringArrayParam(params, "mediaUrls"));
|
|
851
|
-
let hasUnsupportedAttachmentPayload =
|
|
837
|
+
let hasUnsupportedAttachmentPayload = Boolean(readMattermostStringParam(params, "buffer") ?? readMattermostStringParam(params, "base64"));
|
|
852
838
|
if (Array.isArray(params.attachments)) for (const attachment of params.attachments) {
|
|
853
839
|
if (!attachment || typeof attachment !== "object" || Array.isArray(attachment)) continue;
|
|
854
840
|
const record = attachment;
|
|
855
841
|
mediaUrlCandidates.push(readMattermostStringParam(record, "media"), readMattermostStringParam(record, "mediaUrl"), readMattermostStringParam(record, "path"), readMattermostStringParam(record, "filePath"), readMattermostStringParam(record, "fileUrl"), readMattermostStringParam(record, "url"));
|
|
856
|
-
hasUnsupportedAttachmentPayload ||=
|
|
857
|
-
hasUnsupportedAttachmentPayload ||= typeof record.base64 === "string";
|
|
842
|
+
hasUnsupportedAttachmentPayload ||= Boolean(readMattermostStringParam(record, "buffer") ?? readMattermostStringParam(record, "base64"));
|
|
858
843
|
}
|
|
859
844
|
return {
|
|
860
845
|
mediaUrls: collectNonBlankStrings(mediaUrlCandidates),
|
|
@@ -989,7 +974,14 @@ const mattermostPlugin = createChatChannelPlugin({
|
|
|
989
974
|
minChars: 1500,
|
|
990
975
|
idleMs: 1e3
|
|
991
976
|
} },
|
|
992
|
-
reload: {
|
|
977
|
+
reload: {
|
|
978
|
+
configPrefixes: ["channels.mattermost"],
|
|
979
|
+
/**
|
|
980
|
+
* accounts.default is promoted; named resolution merges only channel-wide fields
|
|
981
|
+
* plus the selected account. Monitor debounce and durable ingress use accountId.
|
|
982
|
+
*/
|
|
983
|
+
accountScopedRestart: true
|
|
984
|
+
},
|
|
993
985
|
configSchema: MattermostChannelConfigSchema,
|
|
994
986
|
config: {
|
|
995
987
|
...mattermostConfigAdapter,
|
|
@@ -1013,6 +1005,8 @@ const mattermostPlugin = createChatChannelPlugin({
|
|
|
1013
1005
|
}),
|
|
1014
1006
|
messaging: {
|
|
1015
1007
|
targetPrefixes: ["mattermost"],
|
|
1008
|
+
directTargetStyle: "user-prefixed",
|
|
1009
|
+
targetIdComparison: "case-sensitive",
|
|
1016
1010
|
defaultMarkdownTableMode: "off",
|
|
1017
1011
|
normalizeTarget: normalizeMattermostMessagingTarget,
|
|
1018
1012
|
resolveDeliveryTarget: ({ conversationId, parentConversationId }) => {
|
|
@@ -1140,4 +1134,4 @@ const mattermostPlugin = createChatChannelPlugin({
|
|
|
1140
1134
|
outbound: mattermostOutbound
|
|
1141
1135
|
});
|
|
1142
1136
|
//#endregion
|
|
1143
|
-
export {
|
|
1137
|
+
export { MattermostChannelConfigSchema as a, mattermostConfigAdapter as c, normalizeMattermostMessagingTarget as i, mattermostMeta as l, mattermostSetupWizard as n, describeMattermostAccount as o, mattermostSetupAdapter as r, isMattermostConfigured$1 as s, mattermostPlugin as t };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as mattermostPlugin } from "./channel-plugin-runtime-
|
|
1
|
+
import { t as mattermostPlugin } from "./channel-plugin-runtime-BfV83pya.js";
|
|
2
2
|
export { mattermostPlugin };
|