@openclaw/mattermost 2026.7.2-beta.7 → 2026.7.34
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/{client-CqqzTcno.js → .setup/accounts-CkvUBI7I.mjs} +101 -55
- package/dist/.setup/channel-plugin-api-DQ6gNcH0.mjs +31 -0
- package/dist/.setup/channel-plugin-api-jFFWYXht.mjs +3 -0
- package/dist/{channel-plugin-runtime-DlrMaSIu.js → .setup/channel-plugin-runtime-BLOKRsgT.mjs} +260 -344
- package/dist/.setup/channel.runtime-CK6s04r7.mjs +2653 -0
- package/dist/.setup/doctor-contract-ttH0DCuq.mjs +7 -0
- package/dist/{gateway-auth-bypass-CL1PxV3z.js → .setup/gateway-auth-bypass-BIXLORHU.mjs} +2 -3
- package/dist/{monitor-auth-rctDliGZ.js → .setup/monitor-auth-CeakcTAO.mjs} +13 -14
- package/dist/.setup/secret-contract-Cx0LUNXy.mjs +44 -0
- package/dist/.setup/secret-contract-api-BLTnjVCZ.mjs +3 -0
- package/dist/{slash-state-DM8qmFJR.js → .setup/slash-state-D1e1_KaK.mjs} +572 -311
- package/dist/api.js +2 -3
- package/dist/channel-plugin-api.js +2 -38
- package/dist/channel-plugin-runtime.js +1 -1
- package/dist/doctor-contract-api.js +1 -1
- package/dist/gateway-auth-api.js +1 -1
- package/dist/policy-api.js +1 -1
- package/dist/runtime-api.js +3 -2
- package/dist/secret-contract-api.js +1 -1
- package/dist/setup-entry.js +3 -2
- package/dist/slash-route-api.js +1 -1
- package/node_modules/ws/lib/permessage-deflate.js +3 -1
- package/node_modules/ws/package.json +1 -1
- package/openclaw.plugin.json +231 -277
- package/package.json +6 -52
- package/dist/accounts-NaMdx9yF.js +0 -86
- package/dist/channel.runtime-DndW9G7T.js +0 -3207
- package/dist/doctor-contract-BaUvVh8e.js +0 -19
- package/dist/interactions-BQXY_48h.js +0 -375
- package/dist/secret-contract-B4R5Bmhv.js +0 -28
- /package/dist/{runtime-CNB4YGqJ.js → .setup/runtime-CNB4YGqJ.mjs} +0 -0
package/dist/{channel-plugin-runtime-DlrMaSIu.js → .setup/channel-plugin-runtime-BLOKRsgT.mjs}
RENAMED
|
@@ -1,50 +1,52 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { t as
|
|
4
|
-
import { n as
|
|
5
|
-
import { n as collectRuntimeConfigAssignments, r as secretTargetRegistryEntries } from "./secret-contract-B4R5Bmhv.js";
|
|
1
|
+
import { C as hasConfiguredSecretInput, S as buildSecretInputSchema, g as normalizeMattermostBaseUrl, i as resolveMattermostReplyToMode, n as resolveDefaultMattermostAccountId, r as resolveMattermostAccount, t as listMattermostAccountIds } from "./accounts-CkvUBI7I.mjs";
|
|
2
|
+
import { t as resolveMattermostGatewayAuthBypassPaths } from "./gateway-auth-bypass-BIXLORHU.mjs";
|
|
3
|
+
import { n as normalizeCompatibilityConfig, t as legacyConfigRules } from "./doctor-contract-ttH0DCuq.mjs";
|
|
4
|
+
import { n as collectRuntimeConfigAssignments, r as secretTargetRegistryEntries } from "./secret-contract-Cx0LUNXy.mjs";
|
|
6
5
|
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";
|
|
10
6
|
import { formatNormalizedAllowFromEntries } from "openclaw/plugin-sdk/allow-from";
|
|
11
7
|
import { createLoggedPairingApprovalNotifier } from "openclaw/plugin-sdk/channel-pairing";
|
|
12
8
|
import { createAccountStatusSink, createChannelMessageAdapterFromOutbound } from "openclaw/plugin-sdk/channel-outbound";
|
|
13
9
|
import { DEFAULT_ACCOUNT_ID as DEFAULT_ACCOUNT_ID$1, buildChannelOutboundSessionRoute, buildThreadAwareOutboundSessionRoute, stripChannelTargetPrefix, stripTargetKindPrefix } from "openclaw/plugin-sdk/core";
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import { createChannelConfigUiHints, createChatChannelPlugin } from "openclaw/plugin-sdk/channel-core";
|
|
17
|
-
import { buildChannelGroupsScopeTree, buildMutableAllowEntryDetector, collectStandardAllowlistLists, createDangerousNameMatchingMutableAllowlistWarningCollector, createRestrictSendersChannelSecurity, resolveScopeRequireMention } from "openclaw/plugin-sdk/channel-policy";
|
|
10
|
+
import { createChatChannelPlugin } from "openclaw/plugin-sdk/channel-core";
|
|
11
|
+
import { createDangerousNameMatchingMutableAllowlistWarningCollector, createRestrictSendersChannelSecurity, resolveChannelGroupRequireMention } from "openclaw/plugin-sdk/channel-policy";
|
|
18
12
|
import { attachChannelToResult, createAttachedChannelResultAdapter } from "openclaw/plugin-sdk/channel-send-result";
|
|
19
13
|
import { createChannelDirectoryAdapter } from "openclaw/plugin-sdk/directory-runtime";
|
|
20
|
-
import {
|
|
14
|
+
import { buildPassiveProbedChannelStatusSummary } from "openclaw/plugin-sdk/extension-shared";
|
|
15
|
+
import { normalizeMessagePresentation, renderMessagePresentationFallbackText, resolveMessagePresentationControlValue } from "openclaw/plugin-sdk/interactive-runtime";
|
|
21
16
|
import { createLazyRuntimeModule } from "openclaw/plugin-sdk/lazy-runtime";
|
|
22
17
|
import { resolvePayloadMediaUrls, sendTextMediaPayload } from "openclaw/plugin-sdk/reply-payload";
|
|
18
|
+
import { isPrivateNetworkOptInEnabled } from "openclaw/plugin-sdk/ssrf-runtime";
|
|
23
19
|
import { createComputedAccountStatusAdapter, createDefaultChannelRuntimeState } from "openclaw/plugin-sdk/status-helpers";
|
|
24
20
|
import { chunkTextForOutbound, sanitizeAssistantVisibleText } from "openclaw/plugin-sdk/text-chunking";
|
|
25
|
-
import {
|
|
21
|
+
import { createResolvedApproverActionAuthAdapter, resolveApprovalApprovers } from "openclaw/plugin-sdk/approval-auth-runtime";
|
|
26
22
|
import { describeAccountSnapshot } from "openclaw/plugin-sdk/account-helpers";
|
|
27
23
|
import { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "openclaw/plugin-sdk/account-id";
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
30
|
-
import {
|
|
24
|
+
import { z } from "zod";
|
|
25
|
+
import { adaptScopedAccountAccessor, createScopedChannelConfigAdapter } from "openclaw/plugin-sdk/channel-config-helpers";
|
|
26
|
+
import { BlockStreamingCoalesceSchema, DmPolicySchema, GroupPolicySchema, MarkdownConfigSchema, buildChannelConfigSchema, requireOpenAllowFrom } from "openclaw/plugin-sdk/channel-config-primitives";
|
|
27
|
+
import { applyAccountNameToChannelSection, applySetupAccountConfigPatch, createSetupTranslator, createStandardChannelSetupStatus, formatDocsLink, migrateBaseNameToDefaultAccount } from "openclaw/plugin-sdk/setup";
|
|
31
28
|
import { createSetupInputPresenceValidator } from "openclaw/plugin-sdk/setup-runtime";
|
|
32
29
|
//#region extensions/mattermost/src/approval-auth.ts
|
|
33
30
|
const MATTERMOST_USER_ID_RE = /^[a-z0-9]{26}$/;
|
|
34
31
|
function normalizeMattermostApproverId(value) {
|
|
35
|
-
const
|
|
32
|
+
const normalized = String(value).trim().replace(/^(mattermost|user):/i, "").replace(/^@/, "").trim();
|
|
33
|
+
const lowered = normalizeLowercaseStringOrEmpty(normalized);
|
|
36
34
|
return MATTERMOST_USER_ID_RE.test(lowered) ? lowered : void 0;
|
|
37
35
|
}
|
|
38
|
-
const mattermostApprovalAuth =
|
|
36
|
+
const mattermostApprovalAuth = createResolvedApproverActionAuthAdapter({
|
|
39
37
|
channelLabel: "Mattermost",
|
|
40
|
-
|
|
41
|
-
|
|
38
|
+
resolveApprovers: ({ cfg, accountId }) => {
|
|
39
|
+
const account = resolveMattermostAccount({
|
|
42
40
|
cfg,
|
|
43
41
|
accountId
|
|
44
|
-
}).config
|
|
42
|
+
}).config;
|
|
43
|
+
return resolveApprovalApprovers({
|
|
44
|
+
allowFrom: account.allowFrom,
|
|
45
|
+
normalizeApprover: normalizeMattermostApproverId
|
|
46
|
+
});
|
|
45
47
|
},
|
|
46
|
-
|
|
47
|
-
})
|
|
48
|
+
normalizeSenderId: (value) => normalizeMattermostApproverId(value)
|
|
49
|
+
});
|
|
48
50
|
//#endregion
|
|
49
51
|
//#region extensions/mattermost/src/channel-config-shared.ts
|
|
50
52
|
const mattermostMeta = {
|
|
@@ -88,7 +90,7 @@ const mattermostConfigAdapter = createScopedChannelConfigAdapter({
|
|
|
88
90
|
})
|
|
89
91
|
});
|
|
90
92
|
function isMattermostConfigured$1(account) {
|
|
91
|
-
return
|
|
93
|
+
return Boolean(account.botToken && account.baseUrl);
|
|
92
94
|
}
|
|
93
95
|
function describeMattermostAccount(account) {
|
|
94
96
|
return describeAccountSnapshot({
|
|
@@ -96,21 +98,15 @@ function describeMattermostAccount(account) {
|
|
|
96
98
|
configured: isMattermostConfigured$1(account),
|
|
97
99
|
extra: {
|
|
98
100
|
botTokenSource: account.botTokenSource,
|
|
99
|
-
botTokenStatus: account.botTokenStatus,
|
|
100
101
|
baseUrl: account.baseUrl
|
|
101
102
|
}
|
|
102
103
|
});
|
|
103
104
|
}
|
|
104
105
|
//#endregion
|
|
105
106
|
//#region extensions/mattermost/src/config-schema-core.ts
|
|
106
|
-
const MattermostGroupSchema =
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
skills: true,
|
|
110
|
-
enabled: true,
|
|
111
|
-
allowFrom: true,
|
|
112
|
-
systemPrompt: true
|
|
113
|
-
});
|
|
107
|
+
const MattermostGroupSchema = z.object({
|
|
108
|
+
/** Whether mentions are required to trigger the bot in this group. */
|
|
109
|
+
requireMention: z.boolean().optional() }).strict();
|
|
114
110
|
function requireMattermostOpenAllowFrom(params) {
|
|
115
111
|
requireOpenAllowFrom({
|
|
116
112
|
policy: params.policy,
|
|
@@ -160,38 +156,25 @@ const MattermostStreamingProgressSchema = z.object({
|
|
|
160
156
|
labels: z.array(z.string()).optional(),
|
|
161
157
|
maxLines: z.number().int().positive().optional(),
|
|
162
158
|
maxLineChars: z.number().int().positive().optional(),
|
|
163
|
-
toolProgress: z.boolean().optional()
|
|
164
|
-
commandText: z.enum(["raw", "status"]).optional()
|
|
165
|
-
}).strict();
|
|
166
|
-
const MattermostStreamingPreviewSchema = z.object({
|
|
167
|
-
toolProgress: z.boolean().optional(),
|
|
168
|
-
commandText: z.enum(["raw", "status"]).optional()
|
|
159
|
+
toolProgress: z.boolean().optional()
|
|
169
160
|
}).strict();
|
|
161
|
+
const MattermostStreamingPreviewSchema = z.object({ toolProgress: z.boolean().optional() }).strict();
|
|
170
162
|
const MattermostStreamingBlockSchema = z.object({
|
|
171
163
|
enabled: z.boolean().optional(),
|
|
172
164
|
coalesce: BlockStreamingCoalesceSchema.optional()
|
|
173
165
|
}).strict();
|
|
174
|
-
const MattermostStreamingSchema = z.
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
"all",
|
|
185
|
-
"batched"
|
|
166
|
+
const MattermostStreamingSchema = z.union([
|
|
167
|
+
MattermostStreamingModeSchema,
|
|
168
|
+
z.boolean(),
|
|
169
|
+
z.object({
|
|
170
|
+
mode: MattermostStreamingModeSchema.optional(),
|
|
171
|
+
chunkMode: z.enum(["length", "newline"]).optional(),
|
|
172
|
+
preview: MattermostStreamingPreviewSchema.optional(),
|
|
173
|
+
progress: MattermostStreamingProgressSchema.optional(),
|
|
174
|
+
block: MattermostStreamingBlockSchema.optional()
|
|
175
|
+
}).strict()
|
|
186
176
|
]);
|
|
187
|
-
const
|
|
188
|
-
direct: MattermostReplyToModeSchema.optional(),
|
|
189
|
-
group: MattermostReplyToModeSchema.optional(),
|
|
190
|
-
channel: MattermostReplyToModeSchema.optional()
|
|
191
|
-
}).strict();
|
|
192
|
-
//#endregion
|
|
193
|
-
//#region extensions/mattermost/src/config-surface.ts
|
|
194
|
-
const MattermostChannelConfigSchema = buildChannelConfigSchema(buildMultiAccountChannelSchema(z.object({
|
|
177
|
+
const MattermostAccountSchemaBase = z.object({
|
|
195
178
|
name: z.string().optional(),
|
|
196
179
|
capabilities: z.array(z.string()).optional(),
|
|
197
180
|
dangerouslyAllowNameMatching: z.boolean().optional(),
|
|
@@ -207,20 +190,23 @@ const MattermostChannelConfigSchema = buildChannelConfigSchema(buildMultiAccount
|
|
|
207
190
|
]).optional(),
|
|
208
191
|
oncharPrefixes: z.array(z.string()).optional(),
|
|
209
192
|
requireMention: z.boolean().optional(),
|
|
210
|
-
implicitMentions: ChannelImplicitMentionsSchema.optional(),
|
|
211
193
|
dmPolicy: DmPolicySchema.optional().default("pairing"),
|
|
212
194
|
allowFrom: z.array(z.union([z.string(), z.number()])).optional(),
|
|
213
195
|
groupAllowFrom: z.array(z.union([z.string(), z.number()])).optional(),
|
|
214
196
|
groupPolicy: GroupPolicySchema.optional().default("allowlist"),
|
|
215
197
|
textChunkLimit: z.number().int().positive().optional(),
|
|
198
|
+
chunkMode: z.enum(["length", "newline"]).optional(),
|
|
216
199
|
streaming: MattermostStreamingSchema.optional(),
|
|
217
|
-
|
|
218
|
-
|
|
200
|
+
blockStreaming: z.boolean().optional(),
|
|
201
|
+
blockStreamingCoalesce: BlockStreamingCoalesceSchema.optional(),
|
|
202
|
+
replyToMode: z.enum([
|
|
203
|
+
"off",
|
|
204
|
+
"first",
|
|
205
|
+
"all",
|
|
206
|
+
"batched"
|
|
207
|
+
]).optional(),
|
|
219
208
|
responsePrefix: z.string().optional(),
|
|
220
|
-
actions: z.object({
|
|
221
|
-
messages: z.boolean().optional(),
|
|
222
|
-
reactions: z.boolean().optional()
|
|
223
|
-
}).optional(),
|
|
209
|
+
actions: z.object({ reactions: z.boolean().optional() }).optional(),
|
|
224
210
|
commands: MattermostSlashCommandsSchema,
|
|
225
211
|
interactions: z.object({
|
|
226
212
|
callbackBaseUrl: z.string().optional(),
|
|
@@ -232,43 +218,109 @@ const MattermostChannelConfigSchema = buildChannelConfigSchema(buildMultiAccount
|
|
|
232
218
|
network: MattermostNetworkSchema,
|
|
233
219
|
/** Retry configuration for DM channel creation */
|
|
234
220
|
dmChannelRetry: DmChannelRetrySchema
|
|
235
|
-
}).strict()
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
221
|
+
}).strict();
|
|
222
|
+
const MattermostAccountSchema = MattermostAccountSchemaBase.superRefine((value, ctx) => {
|
|
223
|
+
requireMattermostOpenAllowFrom({
|
|
224
|
+
policy: value.dmPolicy,
|
|
225
|
+
allowFrom: value.allowFrom,
|
|
226
|
+
ctx
|
|
227
|
+
});
|
|
228
|
+
});
|
|
229
|
+
const MattermostConfigSchema = MattermostAccountSchemaBase.extend({
|
|
230
|
+
accounts: z.record(z.string(), MattermostAccountSchema.optional()).optional(),
|
|
231
|
+
defaultAccount: z.string().optional()
|
|
232
|
+
}).superRefine((value, ctx) => {
|
|
233
|
+
requireMattermostOpenAllowFrom({
|
|
234
|
+
policy: value.dmPolicy,
|
|
235
|
+
allowFrom: value.allowFrom,
|
|
236
|
+
ctx
|
|
237
|
+
});
|
|
238
|
+
});
|
|
239
|
+
//#endregion
|
|
240
|
+
//#region extensions/mattermost/src/config-surface.ts
|
|
241
|
+
const MattermostChannelConfigSchema = buildChannelConfigSchema(MattermostConfigSchema, { uiHints: {
|
|
245
242
|
"": {
|
|
246
243
|
label: "Mattermost",
|
|
247
244
|
help: "Mattermost channel provider configuration for bot auth, access policy, slash commands, and preview streaming."
|
|
248
245
|
},
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
246
|
+
dmPolicy: {
|
|
247
|
+
label: "Mattermost DM Policy",
|
|
248
|
+
help: "Direct message access control (\"pairing\" recommended). \"open\" requires channels.mattermost.allowFrom=[\"*\"]."
|
|
249
|
+
},
|
|
250
|
+
streaming: {
|
|
251
|
+
label: "Mattermost Streaming Mode",
|
|
252
|
+
help: "Unified Mattermost stream preview mode: \"off\" | \"partial\" | \"block\" | \"progress\". \"progress\" keeps a single editable progress draft until final delivery."
|
|
253
|
+
},
|
|
254
|
+
"streaming.mode": {
|
|
255
|
+
label: "Mattermost Streaming Mode",
|
|
256
|
+
help: "Canonical Mattermost preview mode: \"off\" | \"partial\" | \"block\" | \"progress\"."
|
|
257
|
+
},
|
|
258
|
+
"streaming.progress.label": {
|
|
259
|
+
label: "Mattermost Progress Label",
|
|
260
|
+
help: "Initial progress draft title. Use \"auto\" for built-in single-word labels, a custom string, or false to hide the title."
|
|
261
|
+
},
|
|
262
|
+
"streaming.progress.labels": {
|
|
263
|
+
label: "Mattermost Progress Label Pool",
|
|
264
|
+
help: "Candidate labels for streaming.progress.label=\"auto\". Leave unset to use OpenClaw built-in progress labels."
|
|
265
|
+
},
|
|
266
|
+
"streaming.progress.maxLines": {
|
|
267
|
+
label: "Mattermost Progress Max Lines",
|
|
268
|
+
help: "Maximum number of compact progress lines to keep below the draft label (default: 8)."
|
|
269
|
+
},
|
|
270
|
+
"streaming.progress.maxLineChars": {
|
|
271
|
+
label: "Mattermost Progress Max Line Chars",
|
|
272
|
+
help: "Maximum characters per compact progress line before truncation (default: 120). Prose cuts at word boundaries; commands and paths keep useful suffixes."
|
|
273
|
+
},
|
|
274
|
+
"streaming.progress.toolProgress": {
|
|
275
|
+
label: "Mattermost Progress Tool Lines",
|
|
276
|
+
help: "Show compact tool/progress lines in progress draft mode (default: true). Set false to keep only the label until final delivery."
|
|
277
|
+
},
|
|
278
|
+
"streaming.progress.commandText": {
|
|
279
|
+
label: "Mattermost Progress Command Text",
|
|
280
|
+
help: "Command/exec detail in progress draft lines: \"raw\" preserves released behavior; \"status\" shows only the tool label."
|
|
281
|
+
},
|
|
282
|
+
"streaming.preview.toolProgress": {
|
|
283
|
+
label: "Mattermost Draft Tool Progress",
|
|
284
|
+
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."
|
|
285
|
+
},
|
|
286
|
+
"streaming.preview.commandText": {
|
|
287
|
+
label: "Mattermost Draft Command Text",
|
|
288
|
+
help: "Command/exec detail in preview tool-progress lines: \"raw\" preserves released behavior; \"status\" shows only the tool label."
|
|
289
|
+
},
|
|
290
|
+
"streaming.block.enabled": {
|
|
291
|
+
label: "Mattermost Block Streaming Enabled",
|
|
292
|
+
help: "Enable chunked block-style Mattermost preview delivery when channels.mattermost.streaming.mode=\"block\"."
|
|
293
|
+
},
|
|
294
|
+
"streaming.block.coalesce": {
|
|
295
|
+
label: "Mattermost Block Streaming Coalesce",
|
|
296
|
+
help: "Merge streamed Mattermost block replies before final delivery."
|
|
297
|
+
}
|
|
263
298
|
} });
|
|
299
|
+
//#endregion
|
|
300
|
+
//#region extensions/mattermost/src/doctor.ts
|
|
301
|
+
function isMattermostMutableAllowEntry(raw) {
|
|
302
|
+
const text = raw.trim();
|
|
303
|
+
if (!text || text === "*") return false;
|
|
304
|
+
const normalized = text.replace(/^(mattermost|user):/i, "").replace(/^@/, "").trim();
|
|
305
|
+
const lowered = normalizeLowercaseStringOrEmpty(normalized);
|
|
306
|
+
if (/^[a-z0-9]{26}$/.test(lowered)) return false;
|
|
307
|
+
return true;
|
|
308
|
+
}
|
|
309
|
+
const collectMattermostMutableAllowlistWarnings = createDangerousNameMatchingMutableAllowlistWarningCollector({
|
|
310
|
+
channel: "mattermost",
|
|
311
|
+
detector: isMattermostMutableAllowEntry,
|
|
312
|
+
collectLists: (scope) => [{
|
|
313
|
+
pathLabel: `${scope.prefix}.allowFrom`,
|
|
314
|
+
list: scope.account.allowFrom
|
|
315
|
+
}, {
|
|
316
|
+
pathLabel: `${scope.prefix}.groupAllowFrom`,
|
|
317
|
+
list: scope.account.groupAllowFrom
|
|
318
|
+
}]
|
|
319
|
+
});
|
|
264
320
|
const mattermostDoctor = {
|
|
265
321
|
legacyConfigRules,
|
|
266
322
|
normalizeCompatibilityConfig,
|
|
267
|
-
collectMutableAllowlistWarnings:
|
|
268
|
-
channel: "mattermost",
|
|
269
|
-
detector: buildMutableAllowEntryDetector({ stableIdPattern: /^(?:(?:mattermost|user):)?@?[a-z0-9]{26}$/i }),
|
|
270
|
-
collectLists: (scope) => collectStandardAllowlistLists(scope)
|
|
271
|
-
})
|
|
323
|
+
collectMutableAllowlistWarnings: collectMattermostMutableAllowlistWarnings
|
|
272
324
|
};
|
|
273
325
|
//#endregion
|
|
274
326
|
//#region extensions/mattermost/src/group-mentions.ts
|
|
@@ -277,11 +329,13 @@ function resolveMattermostGroupRequireMention(params) {
|
|
|
277
329
|
cfg: params.cfg,
|
|
278
330
|
accountId: params.accountId
|
|
279
331
|
});
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
332
|
+
const requireMentionOverride = typeof params.requireMentionOverride === "boolean" ? params.requireMentionOverride : account.requireMention;
|
|
333
|
+
return resolveChannelGroupRequireMention({
|
|
334
|
+
cfg: params.cfg,
|
|
335
|
+
channel: "mattermost",
|
|
336
|
+
groupId: params.groupId,
|
|
337
|
+
accountId: params.accountId,
|
|
338
|
+
requireMentionOverride
|
|
285
339
|
});
|
|
286
340
|
}
|
|
287
341
|
//#endregion
|
|
@@ -321,19 +375,6 @@ function looksLikeMattermostTargetId(raw, _normalized) {
|
|
|
321
375
|
}
|
|
322
376
|
//#endregion
|
|
323
377
|
//#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
|
-
}
|
|
337
378
|
function resolveMattermostOutboundSessionRoute(params) {
|
|
338
379
|
let trimmed = stripChannelTargetPrefix(params.target, "mattermost");
|
|
339
380
|
if (!trimmed) return null;
|
|
@@ -345,23 +386,22 @@ function resolveMattermostOutboundSessionRoute(params) {
|
|
|
345
386
|
if (!rawId) return null;
|
|
346
387
|
const hasExplicitUserKind = resolvedKind === "user" || lower.startsWith("user:");
|
|
347
388
|
const recipientSessionExact = isUser && hasExplicitUserKind && /^[a-z0-9]{26}$/.test(rawId);
|
|
348
|
-
const
|
|
349
|
-
|
|
389
|
+
const baseRoute = buildChannelOutboundSessionRoute({
|
|
390
|
+
cfg: params.cfg,
|
|
391
|
+
agentId: params.agentId,
|
|
392
|
+
channel: "mattermost",
|
|
393
|
+
accountId: params.accountId,
|
|
394
|
+
recipientSessionExact,
|
|
395
|
+
peer: {
|
|
396
|
+
kind: isUser ? "direct" : "channel",
|
|
397
|
+
id: rawId
|
|
398
|
+
},
|
|
399
|
+
chatType: isUser ? "direct" : "channel",
|
|
400
|
+
from: isUser ? `mattermost:${rawId}` : `mattermost:channel:${rawId}`,
|
|
401
|
+
to: isUser ? `user:${rawId}` : `channel:${rawId}`
|
|
402
|
+
});
|
|
350
403
|
return buildThreadAwareOutboundSessionRoute({
|
|
351
|
-
route:
|
|
352
|
-
cfg: params.cfg,
|
|
353
|
-
agentId: params.agentId,
|
|
354
|
-
channel: "mattermost",
|
|
355
|
-
accountId: params.accountId,
|
|
356
|
-
recipientSessionExact,
|
|
357
|
-
peer: {
|
|
358
|
-
kind,
|
|
359
|
-
id: rawId
|
|
360
|
-
},
|
|
361
|
-
chatType: kind,
|
|
362
|
-
from: isUser ? `mattermost:${rawId}` : `mattermost:${kind}:${rawId}`,
|
|
363
|
-
to: isUser ? `user:${rawId}` : `channel:${rawId}`
|
|
364
|
-
}),
|
|
404
|
+
route: baseRoute,
|
|
365
405
|
replyToId: params.replyToId,
|
|
366
406
|
threadId: params.threadId,
|
|
367
407
|
currentSessionKey: params.currentSessionKey,
|
|
@@ -375,9 +415,10 @@ function isMattermostConfigured(account) {
|
|
|
375
415
|
return (Boolean(account.botToken?.trim()) || hasConfiguredSecretInput(account.config.botToken)) && Boolean(account.baseUrl);
|
|
376
416
|
}
|
|
377
417
|
function resolveMattermostAccountWithSecrets(cfg, accountId) {
|
|
378
|
-
return
|
|
418
|
+
return resolveMattermostAccount({
|
|
379
419
|
cfg,
|
|
380
|
-
accountId
|
|
420
|
+
accountId,
|
|
421
|
+
allowUnresolvedSecretRef: true
|
|
381
422
|
});
|
|
382
423
|
}
|
|
383
424
|
function applyMattermostSetupConfigPatch(params) {
|
|
@@ -387,11 +428,12 @@ function applyMattermostSetupConfigPatch(params) {
|
|
|
387
428
|
accountId: params.accountId,
|
|
388
429
|
name: params.name
|
|
389
430
|
});
|
|
431
|
+
const next = params.accountId !== DEFAULT_ACCOUNT_ID ? migrateBaseNameToDefaultAccount({
|
|
432
|
+
cfg: namedConfig,
|
|
433
|
+
channelKey: channel$1
|
|
434
|
+
}) : namedConfig;
|
|
390
435
|
return applySetupAccountConfigPatch({
|
|
391
|
-
cfg:
|
|
392
|
-
cfg: namedConfig,
|
|
393
|
-
channelKey: channel$1
|
|
394
|
-
}) : namedConfig,
|
|
436
|
+
cfg: next,
|
|
395
437
|
channelKey: channel$1,
|
|
396
438
|
accountId: params.accountId,
|
|
397
439
|
patch: params.patch
|
|
@@ -415,64 +457,27 @@ const mattermostSetupAdapter = {
|
|
|
415
457
|
message: "Mattermost requires --bot-token and --http-url (or --use-env)."
|
|
416
458
|
}],
|
|
417
459
|
validate: ({ input }) => {
|
|
418
|
-
const
|
|
419
|
-
const
|
|
420
|
-
|
|
421
|
-
if (
|
|
422
|
-
if (setupInput.httpUrl && !baseUrl) return "Mattermost --http-url must include a valid base URL.";
|
|
460
|
+
const token = input.botToken ?? input.token;
|
|
461
|
+
const baseUrl = normalizeMattermostBaseUrl(input.httpUrl);
|
|
462
|
+
if (!input.useEnv && (!token || !baseUrl)) return "Mattermost requires --bot-token and --http-url (or --use-env).";
|
|
463
|
+
if (input.httpUrl && !baseUrl) return "Mattermost --http-url must include a valid base URL.";
|
|
423
464
|
return null;
|
|
424
465
|
}
|
|
425
466
|
}),
|
|
426
467
|
applyAccountConfig: ({ cfg, accountId, input }) => {
|
|
427
|
-
const
|
|
428
|
-
const
|
|
429
|
-
const baseUrl = normalizeMattermostBaseUrl(setupInput.httpUrl);
|
|
468
|
+
const token = input.botToken ?? input.token;
|
|
469
|
+
const baseUrl = normalizeMattermostBaseUrl(input.httpUrl);
|
|
430
470
|
return applyMattermostSetupConfigPatch({
|
|
431
471
|
cfg,
|
|
432
472
|
accountId,
|
|
433
|
-
name:
|
|
434
|
-
patch:
|
|
473
|
+
name: input.name,
|
|
474
|
+
patch: input.useEnv ? {} : {
|
|
435
475
|
...token ? { botToken: token } : {},
|
|
436
476
|
...baseUrl ? { baseUrl } : {}
|
|
437
477
|
}
|
|
438
478
|
});
|
|
439
479
|
}
|
|
440
480
|
};
|
|
441
|
-
const mattermostSetupContract = defineChannelSetupContract({
|
|
442
|
-
fields: {
|
|
443
|
-
token: {
|
|
444
|
-
kind: "string",
|
|
445
|
-
sensitive: true,
|
|
446
|
-
cli: {
|
|
447
|
-
flags: "--token <token>",
|
|
448
|
-
description: "Mattermost bot token"
|
|
449
|
-
}
|
|
450
|
-
},
|
|
451
|
-
botToken: {
|
|
452
|
-
kind: "string",
|
|
453
|
-
sensitive: true,
|
|
454
|
-
cli: {
|
|
455
|
-
flags: "--bot-token <token>",
|
|
456
|
-
description: "Mattermost bot token"
|
|
457
|
-
}
|
|
458
|
-
},
|
|
459
|
-
httpUrl: {
|
|
460
|
-
kind: "string",
|
|
461
|
-
cli: {
|
|
462
|
-
flags: "--http-url <url>",
|
|
463
|
-
description: "Mattermost server URL"
|
|
464
|
-
}
|
|
465
|
-
},
|
|
466
|
-
useEnv: {
|
|
467
|
-
kind: "boolean",
|
|
468
|
-
cli: {
|
|
469
|
-
flags: "--use-env",
|
|
470
|
-
description: "Use Mattermost environment credentials"
|
|
471
|
-
}
|
|
472
|
-
}
|
|
473
|
-
},
|
|
474
|
-
legacyAdapter: mattermostSetupAdapter
|
|
475
|
-
});
|
|
476
481
|
//#endregion
|
|
477
482
|
//#region extensions/mattermost/src/setup-surface.ts
|
|
478
483
|
const t = createSetupTranslator();
|
|
@@ -516,50 +521,60 @@ const mattermostSetupWizard = {
|
|
|
516
521
|
patch: {}
|
|
517
522
|
})
|
|
518
523
|
},
|
|
519
|
-
credentials: [
|
|
524
|
+
credentials: [{
|
|
520
525
|
inputKey: "botToken",
|
|
521
|
-
configKey: "botToken",
|
|
522
526
|
providerHint: channel,
|
|
523
527
|
credentialLabel: t("wizard.mattermost.botToken"),
|
|
524
528
|
preferredEnvVar: "MATTERMOST_BOT_TOKEN",
|
|
525
529
|
envPrompt: t("wizard.mattermost.envPrompt"),
|
|
526
530
|
keepPrompt: t("wizard.mattermost.botTokenKeep"),
|
|
527
531
|
inputPrompt: t("wizard.mattermost.botTokenInput"),
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
532
|
+
inspect: ({ cfg, accountId }) => {
|
|
533
|
+
const resolvedAccount = resolveMattermostAccountWithSecrets(cfg, accountId);
|
|
534
|
+
return {
|
|
535
|
+
accountConfigured: isMattermostConfigured(resolvedAccount),
|
|
536
|
+
hasConfiguredValue: hasConfiguredSecretInput(resolvedAccount.config.botToken)
|
|
537
|
+
};
|
|
538
|
+
},
|
|
539
|
+
applySet: async ({ cfg, accountId, value }) => applyMattermostSetupConfigPatch({
|
|
531
540
|
cfg,
|
|
532
541
|
accountId,
|
|
533
|
-
patch
|
|
534
|
-
})
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
textInputs: [baseUrlTextInput({
|
|
542
|
+
patch: { botToken: value }
|
|
543
|
+
})
|
|
544
|
+
}],
|
|
545
|
+
textInputs: [{
|
|
538
546
|
inputKey: "httpUrl",
|
|
539
|
-
configKey: "baseUrl",
|
|
540
547
|
message: t("wizard.mattermost.baseUrlPrompt"),
|
|
541
548
|
confirmCurrentValue: false,
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
includeInitialValue: true,
|
|
549
|
+
currentValue: ({ cfg, accountId }) => resolveMattermostAccountWithSecrets(cfg, accountId).baseUrl ?? process.env.MATTERMOST_URL?.trim(),
|
|
550
|
+
initialValue: ({ cfg, accountId }) => resolveMattermostAccountWithSecrets(cfg, accountId).baseUrl ?? process.env.MATTERMOST_URL?.trim(),
|
|
545
551
|
shouldPrompt: ({ cfg, accountId, credentialValues, currentValue }) => {
|
|
546
552
|
const resolvedAccount = resolveMattermostAccountWithSecrets(cfg, accountId);
|
|
547
553
|
const tokenConfigured = Boolean(resolvedAccount.botToken?.trim()) || hasConfiguredSecretInput(resolvedAccount.config.botToken);
|
|
548
554
|
return Boolean(credentialValues.botToken) || !tokenConfigured || !currentValue;
|
|
549
555
|
},
|
|
550
|
-
validate: (value) => normalizeMattermostBaseUrl(value) ? void 0 : "Mattermost base URL must include a valid base URL.",
|
|
551
|
-
|
|
552
|
-
|
|
556
|
+
validate: ({ value }) => normalizeMattermostBaseUrl(value) ? void 0 : "Mattermost base URL must include a valid base URL.",
|
|
557
|
+
normalizeValue: ({ value }) => normalizeMattermostBaseUrl(value) ?? value.trim(),
|
|
558
|
+
applySet: async ({ cfg, accountId, value }) => applyMattermostSetupConfigPatch({
|
|
553
559
|
cfg,
|
|
554
560
|
accountId,
|
|
555
|
-
patch
|
|
561
|
+
patch: { baseUrl: value }
|
|
556
562
|
})
|
|
557
|
-
}
|
|
558
|
-
disable: (cfg) =>
|
|
563
|
+
}],
|
|
564
|
+
disable: (cfg) => ({
|
|
565
|
+
...cfg,
|
|
566
|
+
channels: {
|
|
567
|
+
...cfg.channels,
|
|
568
|
+
mattermost: {
|
|
569
|
+
...cfg.channels?.mattermost,
|
|
570
|
+
enabled: false
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
})
|
|
559
574
|
};
|
|
560
575
|
//#endregion
|
|
561
576
|
//#region extensions/mattermost/src/channel.ts
|
|
562
|
-
const loadMattermostChannelRuntime = createLazyRuntimeModule(() => import("./channel.runtime-
|
|
577
|
+
const loadMattermostChannelRuntime = createLazyRuntimeModule(() => import("./channel.runtime-CK6s04r7.mjs"));
|
|
563
578
|
function buildMattermostPresentationButtons(presentation) {
|
|
564
579
|
return presentation.blocks.filter((block) => block.type === "buttons").map((block) => block.buttons.flatMap((button) => {
|
|
565
580
|
if (button.action) return [];
|
|
@@ -581,18 +596,11 @@ const MATTERMOST_PRESENTATION_CAPABILITIES = {
|
|
|
581
596
|
divider: false,
|
|
582
597
|
limits: { text: { markdownDialect: "markdown" } }
|
|
583
598
|
};
|
|
584
|
-
function
|
|
585
|
-
return presentation.
|
|
586
|
-
const action = resolveMessagePresentationButtonAction(button);
|
|
587
|
-
return action?.type === "url" || action?.type === "web-app" && Boolean(action.url);
|
|
588
|
-
}));
|
|
589
|
-
}
|
|
590
|
-
function readMattermostPayloadData(payload) {
|
|
591
|
-
const data = payload.channelData?.mattermost;
|
|
592
|
-
return data && typeof data === "object" && !Array.isArray(data) ? data : void 0;
|
|
599
|
+
function hasMattermostPresentationButtons(presentation) {
|
|
600
|
+
return buildMattermostPresentationButtons(presentation).some((row) => row.length > 0);
|
|
593
601
|
}
|
|
594
602
|
function readMattermostPresentationButtons(payload) {
|
|
595
|
-
const buttons =
|
|
603
|
+
const buttons = (payload.channelData?.mattermost)?.presentationButtons;
|
|
596
604
|
return Array.isArray(buttons) ? buttons : void 0;
|
|
597
605
|
}
|
|
598
606
|
const mattermostSecurityAdapter = createRestrictSendersChannelSecurity({
|
|
@@ -608,32 +616,29 @@ const mattermostSecurityAdapter = createRestrictSendersChannelSecurity({
|
|
|
608
616
|
normalizeDmEntry: (raw) => normalizeMattermostAllowEntry(raw)
|
|
609
617
|
});
|
|
610
618
|
function describeMattermostMessageTool({ cfg, accountId }) {
|
|
611
|
-
const enabledAccounts = (accountId ? [
|
|
619
|
+
const enabledAccounts = (accountId ? [resolveMattermostAccount({
|
|
612
620
|
cfg,
|
|
613
621
|
accountId
|
|
614
|
-
})] : listMattermostAccountIds(cfg).map((listedAccountId) =>
|
|
622
|
+
})] : listMattermostAccountIds(cfg).map((listedAccountId) => resolveMattermostAccount({
|
|
615
623
|
cfg,
|
|
616
624
|
accountId: listedAccountId
|
|
617
625
|
}))).filter((account) => account.enabled).filter((account) => Boolean(account.botToken?.trim() && account.baseUrl?.trim()));
|
|
618
626
|
const actions = [];
|
|
619
627
|
if (enabledAccounts.length > 0) actions.push("send");
|
|
620
|
-
const
|
|
621
|
-
const baseMessages = actionsConfig?.messages;
|
|
622
|
-
const baseReactions = actionsConfig?.reactions;
|
|
628
|
+
const baseReactions = (cfg.channels?.mattermost?.actions)?.reactions;
|
|
623
629
|
if (enabledAccounts.some((account) => {
|
|
624
630
|
return account.config.actions?.reactions ?? baseReactions ?? true;
|
|
625
631
|
})) actions.push("react");
|
|
626
|
-
if (enabledAccounts.some((account) => account.config.actions?.messages ?? baseMessages ?? false)) actions.push("read");
|
|
627
632
|
return {
|
|
628
633
|
actions,
|
|
629
634
|
capabilities: enabledAccounts.length > 0 ? ["presentation"] : []
|
|
630
635
|
};
|
|
631
636
|
}
|
|
632
637
|
function hasConfiguredMattermostDirectoryAccount({ cfg, accountId }) {
|
|
633
|
-
return (accountId ? [
|
|
638
|
+
return (accountId ? [resolveMattermostAccount({
|
|
634
639
|
cfg,
|
|
635
640
|
accountId
|
|
636
|
-
})] : listMattermostAccountIds(cfg).map((listedAccountId) =>
|
|
641
|
+
})] : listMattermostAccountIds(cfg).map((listedAccountId) => resolveMattermostAccount({
|
|
637
642
|
cfg,
|
|
638
643
|
accountId: listedAccountId
|
|
639
644
|
}))).some((account) => Boolean(account.enabled && account.botToken?.trim() && account.baseUrl?.trim()));
|
|
@@ -698,10 +703,12 @@ function normalizeMattermostThreadId(value) {
|
|
|
698
703
|
return typeof value === "number" ? String(value) : normalizeOptionalString(value);
|
|
699
704
|
}
|
|
700
705
|
function buildMattermostThreadingToolContext(params) {
|
|
701
|
-
const
|
|
706
|
+
const account = resolveMattermostAccount({
|
|
702
707
|
cfg: params.cfg,
|
|
703
708
|
accountId: params.accountId ?? resolveDefaultMattermostAccountId(params.cfg)
|
|
704
|
-
})
|
|
709
|
+
});
|
|
710
|
+
const chatType = params.context.ChatType === "direct" || params.context.ChatType === "group" || params.context.ChatType === "channel" ? params.context.ChatType : "channel";
|
|
711
|
+
const configuredReplyToMode = resolveMattermostReplyToMode(account, chatType);
|
|
705
712
|
const currentThreadTs = normalizeMattermostThreadId(params.context.MessageThreadId) ?? normalizeMattermostThreadId(params.context.TransportThreadId) ?? normalizeOptionalString(params.context.ReplyToId);
|
|
706
713
|
const currentMessageId = normalizeMattermostThreadId(params.context.CurrentMessageId);
|
|
707
714
|
const hasExistingThread = Boolean(currentThreadTs) && (!currentMessageId || currentThreadTs !== currentMessageId);
|
|
@@ -726,86 +733,24 @@ const mattermostMessageActions = {
|
|
|
726
733
|
describeMessageTool: describeMattermostMessageTool,
|
|
727
734
|
extractToolSend: ({ args }) => extractMattermostToolSend(args),
|
|
728
735
|
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
|
-
},
|
|
749
736
|
supportsAction: ({ action }) => {
|
|
750
|
-
return action === "send" || action === "react"
|
|
737
|
+
return action === "send" || action === "react";
|
|
751
738
|
},
|
|
752
|
-
handleAction: async ({ action, params, cfg, accountId, mediaAccess, mediaLocalRoots, mediaReadFile
|
|
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
|
-
}
|
|
739
|
+
handleAction: async ({ action, params, cfg, accountId, mediaAccess, mediaLocalRoots, mediaReadFile }) => {
|
|
790
740
|
if (action === "react") {
|
|
791
741
|
const resolvedAccountId = accountId ?? resolveDefaultMattermostAccountId(cfg);
|
|
792
742
|
const mattermostConfig = cfg.channels?.mattermost;
|
|
793
|
-
|
|
743
|
+
if (!(resolveMattermostAccount({
|
|
794
744
|
cfg,
|
|
795
745
|
accountId: resolvedAccountId
|
|
796
|
-
});
|
|
797
|
-
if (!account.enabled) throw new Error(`Mattermost account "${resolvedAccountId}" is disabled`);
|
|
798
|
-
if (!(account.config.actions?.reactions ?? mattermostConfig?.actions?.reactions ?? true)) throw new Error("Mattermost reactions are disabled in config");
|
|
746
|
+
}).config.actions?.reactions ?? mattermostConfig?.actions?.reactions ?? true)) throw new Error("Mattermost reactions are disabled in config");
|
|
799
747
|
const { postId, emojiName, remove } = parseMattermostReactActionParams(params);
|
|
800
|
-
const authorizedTarget = normalizeOptionalString(params.to);
|
|
801
748
|
if (remove) {
|
|
802
749
|
const result = await (await loadMattermostChannelRuntime()).removeMattermostReaction({
|
|
803
750
|
cfg,
|
|
804
751
|
postId,
|
|
805
752
|
emojiName,
|
|
806
|
-
accountId: resolvedAccountId
|
|
807
|
-
authorizedTarget,
|
|
808
|
-
conversationReadOrigin
|
|
753
|
+
accountId: resolvedAccountId
|
|
809
754
|
});
|
|
810
755
|
if (!result.ok) throw new Error(result.error);
|
|
811
756
|
return {
|
|
@@ -820,9 +765,7 @@ const mattermostMessageActions = {
|
|
|
820
765
|
cfg,
|
|
821
766
|
postId,
|
|
822
767
|
emojiName,
|
|
823
|
-
accountId: resolvedAccountId
|
|
824
|
-
authorizedTarget,
|
|
825
|
-
conversationReadOrigin
|
|
768
|
+
accountId: resolvedAccountId
|
|
826
769
|
});
|
|
827
770
|
if (!result.ok) throw new Error(result.error);
|
|
828
771
|
return {
|
|
@@ -843,7 +786,9 @@ const mattermostMessageActions = {
|
|
|
843
786
|
}) : typeof params.message === "string" ? params.message : "";
|
|
844
787
|
const replyToId = normalizeOptionalString(params.replyToId) ?? normalizeOptionalString(params.threadId) ?? normalizeOptionalString(params.replyTo);
|
|
845
788
|
const resolvedAccountId = accountId || void 0;
|
|
846
|
-
const
|
|
789
|
+
const attachmentMedia = collectMattermostAttachmentMedia(params);
|
|
790
|
+
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.");
|
|
791
|
+
if (attachmentMedia.mediaUrls.length > 1) throw new Error("Mattermost send supports one attachment per message; split multiple mediaUrls or attachments[] entries into separate sends.");
|
|
847
792
|
const buttons = presentation ? buildMattermostPresentationButtons(presentation) : [];
|
|
848
793
|
const result = await (await loadMattermostChannelRuntime()).sendMessageMattermost(to, message, {
|
|
849
794
|
cfg,
|
|
@@ -851,11 +796,11 @@ const mattermostMessageActions = {
|
|
|
851
796
|
replyToId,
|
|
852
797
|
buttons: buttons.length > 0 ? buttons : void 0,
|
|
853
798
|
attachmentText: typeof params.attachmentText === "string" ? params.attachmentText : void 0,
|
|
854
|
-
mediaUrl,
|
|
799
|
+
mediaUrl: attachmentMedia.mediaUrls[0],
|
|
855
800
|
mediaLocalRoots: mediaLocalRoots ?? mediaAccess?.localRoots,
|
|
856
801
|
mediaReadFile: mediaReadFile ?? mediaAccess?.readFile,
|
|
857
802
|
...mediaAccess?.workspaceDir ? { workspaceDir: mediaAccess.workspaceDir } : {},
|
|
858
|
-
requireMediaUpload: requiresMattermostMediaUpload(
|
|
803
|
+
requireMediaUpload: requiresMattermostMediaUpload(attachmentMedia.mediaUrls[0]) ? true : void 0
|
|
859
804
|
});
|
|
860
805
|
return {
|
|
861
806
|
content: [{
|
|
@@ -934,29 +879,19 @@ function collectMattermostAttachmentMedia(params) {
|
|
|
934
879
|
readMattermostStringParam(params, "fileUrl")
|
|
935
880
|
];
|
|
936
881
|
mediaUrlCandidates.push(...readMattermostStringArrayParam(params, "mediaUrls"));
|
|
937
|
-
let hasUnsupportedAttachmentPayload =
|
|
882
|
+
let hasUnsupportedAttachmentPayload = typeof params.buffer === "string" || typeof params.base64 === "string";
|
|
938
883
|
if (Array.isArray(params.attachments)) for (const attachment of params.attachments) {
|
|
939
884
|
if (!attachment || typeof attachment !== "object" || Array.isArray(attachment)) continue;
|
|
940
885
|
const record = attachment;
|
|
941
886
|
mediaUrlCandidates.push(readMattermostStringParam(record, "media"), readMattermostStringParam(record, "mediaUrl"), readMattermostStringParam(record, "path"), readMattermostStringParam(record, "filePath"), readMattermostStringParam(record, "fileUrl"), readMattermostStringParam(record, "url"));
|
|
942
|
-
hasUnsupportedAttachmentPayload ||=
|
|
887
|
+
hasUnsupportedAttachmentPayload ||= typeof record.buffer === "string";
|
|
888
|
+
hasUnsupportedAttachmentPayload ||= typeof record.base64 === "string";
|
|
943
889
|
}
|
|
944
890
|
return {
|
|
945
891
|
mediaUrls: collectNonBlankStrings(mediaUrlCandidates),
|
|
946
892
|
hasUnsupportedAttachmentPayload
|
|
947
893
|
};
|
|
948
894
|
}
|
|
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
|
-
}
|
|
960
895
|
const mattermostOutbound = {
|
|
961
896
|
deliveryMode: "direct",
|
|
962
897
|
chunker: chunkTextForOutbound,
|
|
@@ -975,33 +910,30 @@ const mattermostOutbound = {
|
|
|
975
910
|
renderPresentation: ({ payload, presentation }) => {
|
|
976
911
|
if (payload.mediaUrls && payload.mediaUrls.length > 1) return null;
|
|
977
912
|
const buttons = buildMattermostPresentationButtons(presentation);
|
|
978
|
-
|
|
979
|
-
if (!hasButtons && !hasMattermostPresentationNavigation(presentation)) return null;
|
|
913
|
+
if (!hasMattermostPresentationButtons(presentation)) return null;
|
|
980
914
|
return {
|
|
981
915
|
...payload,
|
|
982
916
|
text: renderMessagePresentationFallbackText({
|
|
983
917
|
text: payload.text,
|
|
984
918
|
presentation
|
|
985
919
|
}),
|
|
986
|
-
|
|
920
|
+
channelData: {
|
|
987
921
|
...payload.channelData,
|
|
988
922
|
mattermost: {
|
|
989
923
|
...payload.channelData?.mattermost,
|
|
990
924
|
presentationButtons: buttons
|
|
991
925
|
}
|
|
992
|
-
}
|
|
926
|
+
}
|
|
993
927
|
};
|
|
994
928
|
},
|
|
995
929
|
sendPayload: async (ctx) => {
|
|
996
930
|
const buttons = readMattermostPresentationButtons(ctx.payload);
|
|
997
|
-
|
|
998
|
-
const attachmentText = typeof rawAttachmentText === "string" ? rawAttachmentText : void 0;
|
|
999
|
-
if (buttons?.length || attachmentText !== void 0) {
|
|
931
|
+
if (buttons?.length) {
|
|
1000
932
|
const mediaUrl = resolvePayloadMediaUrls({
|
|
1001
933
|
...ctx.payload,
|
|
1002
934
|
mediaUrl: ctx.payload.mediaUrl ?? ctx.mediaUrl
|
|
1003
935
|
}).map((url) => url.trim()).find(Boolean);
|
|
1004
|
-
|
|
936
|
+
const result = await (await loadMattermostChannelRuntime()).sendMessageMattermost(ctx.to, ctx.payload.text ?? ctx.text, {
|
|
1005
937
|
cfg: ctx.cfg,
|
|
1006
938
|
accountId: ctx.accountId ?? void 0,
|
|
1007
939
|
mediaUrl,
|
|
@@ -1010,10 +942,9 @@ const mattermostOutbound = {
|
|
|
1010
942
|
...ctx.mediaAccess?.workspaceDir ? { workspaceDir: ctx.mediaAccess.workspaceDir } : {},
|
|
1011
943
|
requireMediaUpload: requiresMattermostMediaUpload(mediaUrl) ? true : void 0,
|
|
1012
944
|
replyToId: ctx.replyToId ?? (ctx.threadId != null ? String(ctx.threadId) : void 0),
|
|
1013
|
-
buttons
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
}));
|
|
945
|
+
buttons
|
|
946
|
+
});
|
|
947
|
+
return attachChannelToResult("mattermost", result);
|
|
1017
948
|
}
|
|
1018
949
|
return await sendTextMediaPayload({
|
|
1019
950
|
channel: "mattermost",
|
|
@@ -1034,13 +965,12 @@ const mattermostOutbound = {
|
|
|
1034
965
|
},
|
|
1035
966
|
...createAttachedChannelResultAdapter({
|
|
1036
967
|
channel: "mattermost",
|
|
1037
|
-
sendText: async ({ cfg, to, text, accountId, replyToId, threadId
|
|
968
|
+
sendText: async ({ cfg, to, text, accountId, replyToId, threadId }) => await (await loadMattermostChannelRuntime()).sendMessageMattermost(to, text, {
|
|
1038
969
|
cfg,
|
|
1039
970
|
accountId: accountId ?? void 0,
|
|
1040
|
-
replyToId: replyToId ?? (threadId != null ? String(threadId) : void 0)
|
|
1041
|
-
onDeliveryResult: createMattermostDeliveryProgressReporter(onDeliveryResult)
|
|
971
|
+
replyToId: replyToId ?? (threadId != null ? String(threadId) : void 0)
|
|
1042
972
|
}),
|
|
1043
|
-
sendMedia: async ({ cfg, to, text, mediaUrl, mediaAccess, mediaLocalRoots, mediaReadFile, accountId, replyToId, threadId
|
|
973
|
+
sendMedia: async ({ cfg, to, text, mediaUrl, mediaAccess, mediaLocalRoots, mediaReadFile, accountId, replyToId, threadId }) => await (await loadMattermostChannelRuntime()).sendMessageMattermost(to, text, {
|
|
1044
974
|
cfg,
|
|
1045
975
|
accountId: accountId ?? void 0,
|
|
1046
976
|
mediaUrl,
|
|
@@ -1048,8 +978,7 @@ const mattermostOutbound = {
|
|
|
1048
978
|
mediaReadFile: mediaReadFile ?? mediaAccess?.readFile,
|
|
1049
979
|
...mediaAccess?.workspaceDir ? { workspaceDir: mediaAccess.workspaceDir } : {},
|
|
1050
980
|
requireMediaUpload: requiresMattermostMediaUpload(mediaUrl) ? true : void 0,
|
|
1051
|
-
replyToId: replyToId ?? (threadId != null ? String(threadId) : void 0)
|
|
1052
|
-
onDeliveryResult: createMattermostDeliveryProgressReporter(onDeliveryResult)
|
|
981
|
+
replyToId: replyToId ?? (threadId != null ? String(threadId) : void 0)
|
|
1053
982
|
})
|
|
1054
983
|
})
|
|
1055
984
|
};
|
|
@@ -1074,7 +1003,6 @@ const mattermostPlugin = createChatChannelPlugin({
|
|
|
1074
1003
|
id: "mattermost",
|
|
1075
1004
|
meta: { ...mattermostMeta },
|
|
1076
1005
|
setup: mattermostSetupAdapter,
|
|
1077
|
-
setupContract: mattermostSetupContract,
|
|
1078
1006
|
setupWizard: mattermostSetupWizard,
|
|
1079
1007
|
capabilities: {
|
|
1080
1008
|
chatTypes: [
|
|
@@ -1092,18 +1020,10 @@ const mattermostPlugin = createChatChannelPlugin({
|
|
|
1092
1020
|
minChars: 1500,
|
|
1093
1021
|
idleMs: 1e3
|
|
1094
1022
|
} },
|
|
1095
|
-
reload: {
|
|
1096
|
-
configPrefixes: ["channels.mattermost"],
|
|
1097
|
-
/**
|
|
1098
|
-
* accounts.default is promoted; named resolution merges only channel-wide fields
|
|
1099
|
-
* plus the selected account. Monitor debounce and durable ingress use accountId.
|
|
1100
|
-
*/
|
|
1101
|
-
accountScopedRestart: true
|
|
1102
|
-
},
|
|
1023
|
+
reload: { configPrefixes: ["channels.mattermost"] },
|
|
1103
1024
|
configSchema: MattermostChannelConfigSchema,
|
|
1104
1025
|
config: {
|
|
1105
1026
|
...mattermostConfigAdapter,
|
|
1106
|
-
inspectAccount: adaptScopedAccountAccessor(inspectMattermostAccount),
|
|
1107
1027
|
isConfigured: isMattermostConfigured$1,
|
|
1108
1028
|
describeAccount: describeMattermostAccount
|
|
1109
1029
|
},
|
|
@@ -1124,8 +1044,6 @@ const mattermostPlugin = createChatChannelPlugin({
|
|
|
1124
1044
|
}),
|
|
1125
1045
|
messaging: {
|
|
1126
1046
|
targetPrefixes: ["mattermost"],
|
|
1127
|
-
directTargetStyle: "user-prefixed",
|
|
1128
|
-
targetIdComparison: "case-sensitive",
|
|
1129
1047
|
defaultMarkdownTableMode: "off",
|
|
1130
1048
|
normalizeTarget: normalizeMattermostMessagingTarget,
|
|
1131
1049
|
resolveDeliveryTarget: ({ conversationId, parentConversationId }) => {
|
|
@@ -1182,7 +1100,6 @@ const mattermostPlugin = createChatChannelPlugin({
|
|
|
1182
1100
|
configured: Boolean(account.botToken && account.baseUrl),
|
|
1183
1101
|
extra: {
|
|
1184
1102
|
botTokenSource: account.botTokenSource,
|
|
1185
|
-
botTokenStatus: account.botTokenStatus,
|
|
1186
1103
|
baseUrl: account.baseUrl,
|
|
1187
1104
|
dmPolicy: account.config.dmPolicy ?? "pairing",
|
|
1188
1105
|
connected: runtime?.connected ?? false,
|
|
@@ -1192,7 +1109,7 @@ const mattermostPlugin = createChatChannelPlugin({
|
|
|
1192
1109
|
})
|
|
1193
1110
|
}),
|
|
1194
1111
|
gateway: {
|
|
1195
|
-
resolveGatewayAuthBypassPaths: resolveMattermostGatewayAuthBypassPaths,
|
|
1112
|
+
resolveGatewayAuthBypassPaths: ({ cfg }) => resolveMattermostGatewayAuthBypassPaths(cfg),
|
|
1196
1113
|
startAccount: async (ctx) => {
|
|
1197
1114
|
const account = ctx.account;
|
|
1198
1115
|
const statusSink = createAccountStatusSink({
|
|
@@ -1242,10 +1159,9 @@ const mattermostPlugin = createChatChannelPlugin({
|
|
|
1242
1159
|
}),
|
|
1243
1160
|
resolveReplyTransport: ({ threadId, replyToId, replyToIsExplicit, replyDelivery }) => {
|
|
1244
1161
|
const ambientThreadId = threadId != null ? String(threadId) : void 0;
|
|
1245
|
-
const
|
|
1246
|
-
const resolvedThreadId = isFlatDirect ? void 0 : replyDelivery ? replyToIsExplicit ? replyToId ?? ambientThreadId : ambientThreadId ?? replyToId ?? void 0 : ambientThreadId ?? replyToId;
|
|
1162
|
+
const resolvedThreadId = replyDelivery?.chatType === "direct" ? void 0 : replyDelivery ? replyToIsExplicit ? replyToId ?? ambientThreadId : ambientThreadId ?? replyToId ?? void 0 : ambientThreadId ?? replyToId;
|
|
1247
1163
|
return {
|
|
1248
|
-
replyToId:
|
|
1164
|
+
replyToId: replyDelivery?.chatType === "direct" ? null : resolvedThreadId,
|
|
1249
1165
|
threadId: resolvedThreadId ?? null
|
|
1250
1166
|
};
|
|
1251
1167
|
}
|
|
@@ -1254,4 +1170,4 @@ const mattermostPlugin = createChatChannelPlugin({
|
|
|
1254
1170
|
outbound: mattermostOutbound
|
|
1255
1171
|
});
|
|
1256
1172
|
//#endregion
|
|
1257
|
-
export {
|
|
1173
|
+
export { describeMattermostAccount as a, mattermostMeta as c, MattermostChannelConfigSchema as i, mattermostSetupWizard as n, isMattermostConfigured$1 as o, mattermostSetupAdapter as r, mattermostConfigAdapter as s, mattermostPlugin as t };
|