@openclaw/slack 2026.9.1-beta.1 → 2026.9.1
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/{account-inspect-CN2hBsim.js → account-inspect-C3sePHWa.js} +3 -3
- package/dist/account-inspect-api.js +1 -1
- package/dist/{action-runtime-BoSeX09X.js → action-runtime-DND4Pyp2.js} +84 -66
- package/dist/action-runtime.runtime-CEhbmS-Z.js +2 -0
- package/dist/{actions-XdQyjG_p.js → actions-fh66A6lc.js} +198 -54
- package/dist/api.js +14 -14
- package/dist/{approval-handler.runtime-DxXfGX_Z.js → approval-handler.runtime-D7d8sKM0.js} +18 -12
- package/dist/{channel-C_vnTgxo.js → channel-4m8IAdMD.js} +70 -128
- package/dist/channel-config-api.js +1 -1
- package/dist/channel-plugin-api.js +1 -1
- package/dist/{channel-type-j-2lalcC.js → channel-type-3-SqEMVc.js} +2 -2
- package/dist/{channel.setup-aal8tokM.js → channel.setup-t_ghLGb_.js} +23 -22
- package/dist/{config-schema-CN3XZRX5.js → config-schema-bP3eV2ra.js} +25 -16
- package/dist/{conversation-binding-route-DFVLUdYF.js → conversation-binding-route-Vee8Dgbf.js} +2 -2
- package/dist/{cursor-pages-eX7p8Wwt.js → cursor-pages-ByFwo-Py.js} +7 -1
- package/dist/{directory-config-DqfQ42OV.js → directory-config-Bmw4ykSy.js} +4 -3
- package/dist/directory-contract-api.js +1 -1
- package/dist/{directory-live-lC6X_Ru-.js → directory-live-q32AW7N1.js} +3 -8
- package/dist/{doctor-contract-BAy7-EUQ.js → doctor-contract-BNjw9bxb.js} +5 -4
- package/dist/doctor-contract-api.js +1 -1
- package/dist/{group-policy-CU1tEGpS.js → group-policy-BKjMqT-8.js} +161 -260
- package/dist/{message-tool-api-CWosHSi5.js → message-tool-api-uNEfQYGY.js} +19 -2
- package/dist/message-tool-api.js +1 -1
- package/dist/{monitor-DrNCGneD.js → monitor-Chwu_SiZ.js} +3 -3
- package/dist/{outbound-adapter-DkT2vUE9.js → outbound-adapter-BB8wAjm5.js} +95 -91
- package/dist/{pipeline.runtime-CRRng_Nw.js → pipeline.runtime-BklS_NEj.js} +347 -505
- package/dist/{policy-BoP6t88v.js → policy-D7PKkiet.js} +7 -4
- package/dist/{probe-4_aHtVT3.js → probe-gj5yQgN2.js} +210 -3
- package/dist/{provider-D4nDgxCh.js → provider-Do50wMWn.js} +168 -153
- package/dist/{relay-source-CEmze11m.js → relay-source-DWuduiJ2.js} +6 -4
- package/dist/{replies-D9XMM_S0.js → replies-Dc6WVh_Q.js} +20 -16
- package/dist/{resolve-channels-DSamDgVs.js → resolve-channels-CU7Bg5Ka.js} +6 -10
- package/dist/{resolve-users-CIzwbaJR.js → resolve-users-DrhttvRQ.js} +5 -4
- package/dist/runtime-api.js +10 -10
- package/dist/{scopes-BBrUzpBH.js → scopes-B9HRguDe.js} +1 -1
- package/dist/{send-DtjEnlLh.js → send-Djswy6lf.js} +24 -16
- package/dist/send-results-eeOu_HYm.js +23 -0
- package/dist/{send.runtime-DQeNKa2J.js → send.runtime-__WVTWLQ.js} +1 -1
- package/dist/setup-plugin-api.js +1 -1
- package/dist/{setup-surface-CsBCM4rP.js → setup-surface-DO0e-MMS.js} +5 -5
- package/dist/{shared-D9GeeR9K.js → shared-DEQBEKBL.js} +7 -5
- package/dist/{slash-dispatch.runtime-Chr3YHnT.js → slash-dispatch.runtime-C3B4h5ZM.js} +2 -2
- package/dist/{target-parsing-BnMD2ZqZ.js → target-parsing-PbxGDbr9.js} +11 -6
- package/dist/{targets-Cx5W_n3W.js → targets-7FexXJ62.js} +1 -1
- package/dist/{thread-ts-DUGhaYKq.js → thread-ts-CukseRVL.js} +5 -1
- package/node_modules/@slack/bolt/node_modules/negotiator/lib/accept.js +54 -0
- package/node_modules/@slack/bolt/node_modules/negotiator/lib/charset.js +10 -34
- package/node_modules/@slack/bolt/node_modules/negotiator/lib/encoding.js +9 -30
- package/node_modules/@slack/bolt/node_modules/negotiator/lib/language.js +15 -36
- package/node_modules/@slack/bolt/node_modules/negotiator/lib/mediaType.js +16 -134
- package/node_modules/@slack/bolt/node_modules/negotiator/node_modules/content-type/LICENSE +22 -0
- package/node_modules/@slack/bolt/node_modules/negotiator/node_modules/content-type/README.md +71 -0
- package/node_modules/@slack/bolt/node_modules/negotiator/node_modules/content-type/dist/index.d.ts +46 -0
- package/node_modules/@slack/bolt/node_modules/negotiator/node_modules/content-type/dist/index.js +176 -0
- package/node_modules/@slack/bolt/node_modules/negotiator/node_modules/content-type/dist/index.js.map +1 -0
- package/node_modules/@slack/bolt/node_modules/negotiator/node_modules/content-type/package.json +52 -0
- package/node_modules/@slack/bolt/node_modules/negotiator/package.json +16 -10
- package/node_modules/typebox/build/format/email.mjs +1 -1
- package/node_modules/typebox/build/format/idna/idn-hostname.mjs +19 -1
- package/node_modules/typebox/package.json +1 -1
- package/openclaw.plugin.json +15 -7
- package/package.json +5 -5
- package/dist/action-runtime.runtime-Dpa16J87.js +0 -2
- package/dist/slack-client-kind-hSfjXyUM.js +0 -94
- package/node_modules/@slack/bolt/node_modules/negotiator/HISTORY.md +0 -114
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { n as isSlackPluginAccountConfigured } from "./account-configured-sUohAxZr.js";
|
|
2
2
|
import { a as resolveSlackAccount, i as resolveDefaultSlackAccountId, n as listSlackAccountIds, o as resolveSlackAccountAllowFrom, r as mergeSlackAccountConfig } from "./accounts-Dm_H77gH.js";
|
|
3
|
-
import { a as parseSlackTarget, n as formatSlackTarget, t as canonicalizeSlackApiTargetId } from "./target-parsing-
|
|
4
|
-
import { t as slackContextTargetsMatch } from "./targets-
|
|
3
|
+
import { a as parseSlackTarget, n as formatSlackTarget, t as canonicalizeSlackApiTargetId } from "./target-parsing-PbxGDbr9.js";
|
|
4
|
+
import { t as slackContextTargetsMatch } from "./targets-7FexXJ62.js";
|
|
5
|
+
import { C as normalizeAllowListLower, D as resolveSlackUserAllowListForTeam, E as resolveSlackAllowListMatch } from "./probe-gj5yQgN2.js";
|
|
5
6
|
import { normalizeAccountId } from "openclaw/plugin-sdk/account-resolution";
|
|
6
|
-
import { asOptionalRecord, normalizeLowercaseStringOrEmpty,
|
|
7
|
+
import { asOptionalRecord, normalizeLowercaseStringOrEmpty, normalizeOptionalString, normalizeStringifiedOptionalString, readNonBlankString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
7
8
|
import { normalizeMessageChannel } from "openclaw/plugin-sdk/routing";
|
|
8
9
|
import { FormatCapabilityProfile, chunkTextForOutbound, markdownToIR, renderMarkdownIRChunksWithinLimit, renderMarkdownWithMarkers } from "openclaw/plugin-sdk/text-chunking";
|
|
9
10
|
import { isSingleUseReplyToMode } from "openclaw/plugin-sdk/reply-reference";
|
|
@@ -11,17 +12,17 @@ import { buildChannelKeyCandidates } from "openclaw/plugin-sdk/channel-targets";
|
|
|
11
12
|
import { createNativeApprovalChannelRouteGates, doesApprovalRequestSelectChannelAccount, resolveApprovalKind, resolveApprovalRequestSessionConversation } from "openclaw/plugin-sdk/approval-native-runtime";
|
|
12
13
|
import { createChannelApprovalAuth, resolveApprovalApprovers } from "openclaw/plugin-sdk/approval-auth-runtime";
|
|
13
14
|
import { createChannelExecApprovalProfile, isChannelExecApprovalClientEnabledFromConfig, isChannelExecApprovalTargetRecipient, matchesApprovalRequestFilters } from "openclaw/plugin-sdk/approval-client-runtime";
|
|
15
|
+
import { normalizeHyphenSlug } from "openclaw/plugin-sdk/string-normalization-runtime";
|
|
14
16
|
import { channelRouteTargetsMatchExact, stringifyRouteThreadId } from "openclaw/plugin-sdk/channel-route";
|
|
15
17
|
import { resolveGlobalMap } from "openclaw/plugin-sdk/global-singleton";
|
|
16
18
|
import { legacyInteractiveReplyToPresentation, normalizeMessagePresentation, renderMessagePresentationChartFallbackText, renderMessagePresentationFallbackText, renderMessagePresentationTableFallbackText, resolveMessagePresentationButtonAction, resolveMessagePresentationOptionAction } from "openclaw/plugin-sdk/interactive-runtime";
|
|
17
19
|
import { parseExecApprovalCommandText } from "openclaw/plugin-sdk/approval-reply-runtime";
|
|
20
|
+
import { resolveAskUserQuestionOptionIndex, resolveAskUserQuestionOptionIndices } from "openclaw/plugin-sdk/reply-payload";
|
|
18
21
|
import { buildApprovalResolutionRef } from "openclaw/plugin-sdk/approval-reference-runtime";
|
|
19
22
|
import { eastAsianWidthType } from "get-east-asian-width";
|
|
20
23
|
import { questionGatewayRuntime } from "openclaw/plugin-sdk/question-gateway-runtime";
|
|
21
24
|
import { sliceUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
|
|
22
25
|
import { readResponseTextLimited } from "openclaw/plugin-sdk/provider-http";
|
|
23
|
-
import { compileAllowlist, resolveCompiledAllowlistMatch } from "openclaw/plugin-sdk/allow-from";
|
|
24
|
-
import { normalizeHyphenSlug, normalizeStringEntries as normalizeStringEntries$1, normalizeStringEntriesLower } from "openclaw/plugin-sdk/string-normalization-runtime";
|
|
25
26
|
import { resolveScopeRequireMention, resolveScopeToolsPolicy } from "openclaw/plugin-sdk/channel-policy";
|
|
26
27
|
//#region extensions/slack/src/action-threading.ts
|
|
27
28
|
const SLACK_PRIVATE_ACTION_DELIVERY_RESULT = Symbol("slack.action.delivery-result");
|
|
@@ -43,14 +44,24 @@ function normalizeSlackUserLikeId(value) {
|
|
|
43
44
|
const upper = value.toUpperCase();
|
|
44
45
|
return /^[UW][A-Z0-9]+$/.test(upper) ? upper : void 0;
|
|
45
46
|
}
|
|
46
|
-
function
|
|
47
|
+
function normalizeSlackApproverTarget(value) {
|
|
47
48
|
const trimmed = normalizeStringifiedOptionalString(value);
|
|
48
49
|
if (!trimmed) return;
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
50
|
+
try {
|
|
51
|
+
const target = parseSlackTarget(trimmed, { defaultKind: "user" });
|
|
52
|
+
const id = target?.kind === "user" ? normalizeSlackUserLikeId(target.id) : void 0;
|
|
53
|
+
return target?.teamId && id ? formatSlackTarget({
|
|
54
|
+
kind: "user",
|
|
55
|
+
id,
|
|
56
|
+
teamId: target.teamId.toUpperCase()
|
|
57
|
+
}) : id;
|
|
58
|
+
} catch {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
function normalizeSlackApproverId(value) {
|
|
63
|
+
const target = normalizeSlackApproverTarget(value);
|
|
64
|
+
return target?.startsWith("team:") ? void 0 : target;
|
|
54
65
|
}
|
|
55
66
|
function resolveSlackOwnerApprovers(cfg) {
|
|
56
67
|
const ownerAllowFrom = cfg.commands?.ownerAllowFrom;
|
|
@@ -87,27 +98,40 @@ const resolveSlackExecApprovalTarget = slackExecApprovalProfile.resolveTarget;
|
|
|
87
98
|
const shouldSuppressLocalSlackExecApprovalPrompt = slackExecApprovalProfile.shouldSuppressLocalPrompt;
|
|
88
99
|
//#endregion
|
|
89
100
|
//#region extensions/slack/src/approval-auth.ts
|
|
101
|
+
function resolveSlackApprovalInputs(params) {
|
|
102
|
+
const account = resolveSlackAccount(params).config;
|
|
103
|
+
return {
|
|
104
|
+
allowFrom: resolveSlackAccountAllowFrom(params),
|
|
105
|
+
defaultTo: account.defaultTo
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
function slackApprovalTargetMatches(senderId, approvers) {
|
|
109
|
+
const sender = parseSlackTarget(senderId, { defaultKind: "user" });
|
|
110
|
+
return sender?.kind === "user" && resolveSlackAllowListMatch({
|
|
111
|
+
allowList: normalizeAllowListLower([...approvers]),
|
|
112
|
+
teamId: sender.teamId,
|
|
113
|
+
id: sender.id
|
|
114
|
+
}).allowed;
|
|
115
|
+
}
|
|
90
116
|
const slackApproval = createChannelApprovalAuth({
|
|
91
117
|
channelLabel: "Slack",
|
|
92
|
-
resolveInputs:
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
return {
|
|
98
|
-
allowFrom: resolveSlackAccountAllowFrom({
|
|
99
|
-
cfg,
|
|
100
|
-
accountId
|
|
101
|
-
}),
|
|
102
|
-
defaultTo: account.defaultTo
|
|
103
|
-
};
|
|
104
|
-
},
|
|
105
|
-
normalizeApprover: normalizeSlackApproverId,
|
|
106
|
-
normalizeDefaultTo: normalizeSlackApproverId,
|
|
107
|
-
isWildcardAuthorized: ({ purpose, senderId, inputs, approvers }) => purpose === "sender" && Boolean(senderId) && approvers.length === 0 && inputs.allowFrom?.some((entry) => String(entry).trim() === "*") === true
|
|
118
|
+
resolveInputs: resolveSlackApprovalInputs,
|
|
119
|
+
normalizeApprover: normalizeSlackApproverTarget,
|
|
120
|
+
normalizeDefaultTo: normalizeSlackApproverTarget,
|
|
121
|
+
normalizeSenderId: normalizeSlackApproverTarget,
|
|
122
|
+
isWildcardAuthorized: ({ purpose, senderId, inputs, approvers }) => Boolean(senderId && (slackApprovalTargetMatches(senderId, approvers) || purpose === "sender" && approvers.length === 0 && inputs.allowFrom?.some((entry) => String(entry).trim() === "*")))
|
|
108
123
|
});
|
|
109
124
|
const getSlackApprovalApprovers = slackApproval.resolveApprovers;
|
|
110
125
|
const isSlackApprovalAuthorizedSender = slackApproval.isAuthorizedSender;
|
|
126
|
+
function getSlackApprovalApproversForTeam(params) {
|
|
127
|
+
return resolveApprovalApprovers({
|
|
128
|
+
allowFrom: resolveSlackUserAllowListForTeam({
|
|
129
|
+
allowList: getSlackApprovalApprovers(params),
|
|
130
|
+
teamId: params.teamId
|
|
131
|
+
}),
|
|
132
|
+
normalizeApprover: normalizeSlackApproverTarget
|
|
133
|
+
});
|
|
134
|
+
}
|
|
111
135
|
//#endregion
|
|
112
136
|
//#region extensions/slack/src/installation-identity-state.ts
|
|
113
137
|
const slackInstallationStates = resolveGlobalMap(Symbol.for("openclaw.slack.installation-identities"), "close-and-restart");
|
|
@@ -142,7 +166,8 @@ const DEFAULT_APPROVAL_FORWARDING_MODE = "session";
|
|
|
142
166
|
const SLACK_DM_CHANNEL_ID_RE = /^D[A-Z0-9]{8,}$/i;
|
|
143
167
|
const SLACK_USER_ID_RE = /^[UW][A-Z0-9]{8,}$/i;
|
|
144
168
|
function isSlackApprovalTransportEnabled(params) {
|
|
145
|
-
|
|
169
|
+
const account = resolveSlackAccount(params);
|
|
170
|
+
return isSlackPluginAccountConfigured(account);
|
|
146
171
|
}
|
|
147
172
|
function resolveSlackNativeApprovalConfig(params) {
|
|
148
173
|
return resolveSlackAccount(params).config.execApprovals;
|
|
@@ -158,7 +183,8 @@ function normalizeComparableTarget(value) {
|
|
|
158
183
|
}
|
|
159
184
|
function extractSlackSessionKind(sessionKey) {
|
|
160
185
|
if (!sessionKey) return null;
|
|
161
|
-
const
|
|
186
|
+
const match = sessionKey.match(/slack:(direct|channel|group):/i);
|
|
187
|
+
const kind = normalizeLowercaseStringOrEmpty(match?.[1]);
|
|
162
188
|
return kind ? kind : null;
|
|
163
189
|
}
|
|
164
190
|
function resolveSlackTurnSourceDefaultKind(params) {
|
|
@@ -169,9 +195,10 @@ function resolveTurnSourceSlackOriginTarget(request) {
|
|
|
169
195
|
const turnSourceChannel = normalizeLowercaseStringOrEmpty(request.request.turnSourceChannel);
|
|
170
196
|
const turnSourceTo = normalizeOptionalString(request.request.turnSourceTo) ?? "";
|
|
171
197
|
if (turnSourceChannel !== "slack" || !turnSourceTo) return null;
|
|
198
|
+
const sessionKind = extractSlackSessionKind(request.request.sessionKey ?? void 0);
|
|
172
199
|
const parsed = parseSlackTarget(turnSourceTo, { defaultKind: resolveSlackTurnSourceDefaultKind({
|
|
173
200
|
turnSourceTo,
|
|
174
|
-
sessionKind
|
|
201
|
+
sessionKind
|
|
175
202
|
}) });
|
|
176
203
|
if (!parsed) return null;
|
|
177
204
|
return {
|
|
@@ -263,11 +290,12 @@ const { canApprovalPotentiallyRouteToChannel: canApprovalPotentiallyRouteToSlack
|
|
|
263
290
|
targetsMatch: slackTargetsMatch
|
|
264
291
|
});
|
|
265
292
|
function hasSlackPluginApprovers(params) {
|
|
266
|
-
return
|
|
293
|
+
return getSlackApprovalApproversForTeam(params).length > 0;
|
|
267
294
|
}
|
|
268
295
|
function isSlackPluginNativeApprovalClientConfigEnabled(params) {
|
|
296
|
+
const slackNativeConfig = resolveSlackNativeApprovalConfig(params);
|
|
269
297
|
return isChannelExecApprovalClientEnabledFromConfig({
|
|
270
|
-
enabled:
|
|
298
|
+
enabled: slackNativeConfig?.enabled,
|
|
271
299
|
approverCount: getSlackApprovalApprovers(params).length
|
|
272
300
|
});
|
|
273
301
|
}
|
|
@@ -304,7 +332,10 @@ function matchesSlackNativeApprovalFilters(params) {
|
|
|
304
332
|
}
|
|
305
333
|
function isSlackNativeApprovalAccountEligible(params) {
|
|
306
334
|
const config = resolveSlackNativeApprovalConfig(params);
|
|
307
|
-
const approverCount = params.approvalKind === "exec" ? getSlackExecApprovalApprovers(params).length :
|
|
335
|
+
const approverCount = params.approvalKind === "exec" ? getSlackExecApprovalApprovers(params).length : getSlackApprovalApproversForTeam({
|
|
336
|
+
...params,
|
|
337
|
+
teamId: resolveEnterpriseApprovalTeamId(params.request)
|
|
338
|
+
}).length;
|
|
308
339
|
return isSlackApprovalTransportEnabled(params) && isChannelExecApprovalClientEnabledFromConfig({
|
|
309
340
|
enabled: config?.enabled,
|
|
310
341
|
approverCount
|
|
@@ -568,58 +599,55 @@ function renderSlackMessagePresentationFallbackText(params) {
|
|
|
568
599
|
});
|
|
569
600
|
}
|
|
570
601
|
//#endregion
|
|
602
|
+
//#region extensions/slack/src/rich-text.ts
|
|
603
|
+
const RICH_TEXT_CONTAINER_TYPES = /* @__PURE__ */ new Set([
|
|
604
|
+
"rich_text_section",
|
|
605
|
+
"rich_text_preformatted",
|
|
606
|
+
"rich_text_quote",
|
|
607
|
+
"rich_text_list"
|
|
608
|
+
]);
|
|
609
|
+
function renderSlackRichText(value, mode, separator = "") {
|
|
610
|
+
if (!Array.isArray(value)) return "";
|
|
611
|
+
const table = mode === "table";
|
|
612
|
+
const read = table ? readNonBlankString : normalizeOptionalString;
|
|
613
|
+
const literal = table ? (text) => text : escapeSlackMrkdwn;
|
|
614
|
+
const reference = mode === "escaped" ? escapeSlackMrkdwn : (text) => text;
|
|
615
|
+
const formatReference = (raw, prefix, suffix) => {
|
|
616
|
+
const text = read(raw);
|
|
617
|
+
return text ? reference(`${prefix}${text}${suffix}`) : "";
|
|
618
|
+
};
|
|
619
|
+
return value.map((rawElement) => {
|
|
620
|
+
const element = asOptionalRecord(rawElement);
|
|
621
|
+
if (!element) return "";
|
|
622
|
+
if (Array.isArray(element.elements) && (table || RICH_TEXT_CONTAINER_TYPES.has(element.type))) return renderSlackRichText(element.elements, mode, element.type === "rich_text_list" ? "\n" : "");
|
|
623
|
+
if (table) {
|
|
624
|
+
if (element.type === "text" && typeof element.text === "string") return element.text;
|
|
625
|
+
const text = readNonBlankString(element.text);
|
|
626
|
+
if (text) return text;
|
|
627
|
+
}
|
|
628
|
+
switch (element.type) {
|
|
629
|
+
case "text": return typeof element.text === "string" ? literal(element.text) : "";
|
|
630
|
+
case "link": return literal(read(element.text) ?? read(element.url) ?? "");
|
|
631
|
+
case "user": return formatReference(element.user_id, "<@", ">");
|
|
632
|
+
case "channel": return formatReference(element.channel_id, "<#", ">");
|
|
633
|
+
case "usergroup": return formatReference(element.usergroup_id, "<!subteam^", ">");
|
|
634
|
+
case "broadcast": return formatReference(element.range, "<!", ">");
|
|
635
|
+
case "emoji": {
|
|
636
|
+
const name = read(element.name);
|
|
637
|
+
return name ? `:${name}:` : "";
|
|
638
|
+
}
|
|
639
|
+
case "date": return literal(read(element.fallback) ?? "");
|
|
640
|
+
default: return "";
|
|
641
|
+
}
|
|
642
|
+
}).filter(Boolean).join(separator);
|
|
643
|
+
}
|
|
644
|
+
//#endregion
|
|
571
645
|
//#region extensions/slack/src/data-table.ts
|
|
572
646
|
const SLACK_DATA_TABLE_COLUMNS_MAX = 20;
|
|
573
647
|
const SLACK_DATA_TABLE_ROWS_MAX = 100;
|
|
574
648
|
function countCharacters(value) {
|
|
575
649
|
return Array.from(value).length;
|
|
576
650
|
}
|
|
577
|
-
function readRichTextLeaf(record) {
|
|
578
|
-
if (record.type === "text" && typeof record.text === "string") return record.text;
|
|
579
|
-
const text = readNonBlankString(record.text);
|
|
580
|
-
if (text) return text;
|
|
581
|
-
switch (record.type) {
|
|
582
|
-
case "link": return readNonBlankString(record.url) ?? "";
|
|
583
|
-
case "user": {
|
|
584
|
-
const userId = readNonBlankString(record.user_id);
|
|
585
|
-
return userId ? `<@${userId}>` : "";
|
|
586
|
-
}
|
|
587
|
-
case "channel": {
|
|
588
|
-
const channelId = readNonBlankString(record.channel_id);
|
|
589
|
-
return channelId ? `<#${channelId}>` : "";
|
|
590
|
-
}
|
|
591
|
-
case "usergroup": {
|
|
592
|
-
const usergroupId = readNonBlankString(record.usergroup_id);
|
|
593
|
-
return usergroupId ? `<!subteam^${usergroupId}>` : "";
|
|
594
|
-
}
|
|
595
|
-
case "broadcast": {
|
|
596
|
-
const range = readNonBlankString(record.range);
|
|
597
|
-
return range ? `<!${range}>` : "";
|
|
598
|
-
}
|
|
599
|
-
case "emoji": {
|
|
600
|
-
const name = readNonBlankString(record.name);
|
|
601
|
-
return name ? `:${name}:` : "";
|
|
602
|
-
}
|
|
603
|
-
case "date": return readNonBlankString(record.fallback) ?? "";
|
|
604
|
-
default: return "";
|
|
605
|
-
}
|
|
606
|
-
}
|
|
607
|
-
function readRichTextElements(value, separator = "") {
|
|
608
|
-
if (!Array.isArray(value)) return "";
|
|
609
|
-
const parts = [];
|
|
610
|
-
for (const rawElement of value) {
|
|
611
|
-
const element = asOptionalRecord(rawElement);
|
|
612
|
-
if (!element) continue;
|
|
613
|
-
if (Array.isArray(element.elements)) {
|
|
614
|
-
const rendered = readRichTextElements(element.elements, element.type === "rich_text_list" ? "\n" : "");
|
|
615
|
-
if (rendered) parts.push(rendered);
|
|
616
|
-
continue;
|
|
617
|
-
}
|
|
618
|
-
const rendered = readRichTextLeaf(element);
|
|
619
|
-
if (rendered) parts.push(rendered);
|
|
620
|
-
}
|
|
621
|
-
return parts.join(separator);
|
|
622
|
-
}
|
|
623
651
|
function readSlackBasicTableCell(value) {
|
|
624
652
|
const cell = asOptionalRecord(value);
|
|
625
653
|
if (!cell) return "";
|
|
@@ -629,7 +657,7 @@ function readSlackBasicTableCell(value) {
|
|
|
629
657
|
if (typeof cell.value === "number" && Number.isFinite(cell.value)) return String(cell.value);
|
|
630
658
|
return typeof cell.value === "string" ? cell.value : "";
|
|
631
659
|
}
|
|
632
|
-
return cell.type === "rich_text" ?
|
|
660
|
+
return cell.type === "rich_text" ? renderSlackRichText(cell.elements, "table", "\n") : "";
|
|
633
661
|
}
|
|
634
662
|
function parseSlackBasicTableRows(value) {
|
|
635
663
|
const block = asOptionalRecord(value);
|
|
@@ -651,7 +679,7 @@ function readSlackDataTableCell(value, allowRichText) {
|
|
|
651
679
|
if (!cell) return;
|
|
652
680
|
if (cell.type === "raw_text") return readNonBlankString(cell.text);
|
|
653
681
|
if (cell.type === "raw_number") return typeof cell.value === "number" && Number.isFinite(cell.value) ? readNonBlankString(cell.text) : void 0;
|
|
654
|
-
if (allowRichText && cell.type === "rich_text") return readNonBlankString(
|
|
682
|
+
if (allowRichText && cell.type === "rich_text") return readNonBlankString(renderSlackRichText(cell.elements, "table"));
|
|
655
683
|
}
|
|
656
684
|
function parseSlackDataTable(value, options = {}) {
|
|
657
685
|
const block = asOptionalRecord(value);
|
|
@@ -1163,9 +1191,7 @@ function projectSlackMrkdwnVisibleText(text, dateDisplay) {
|
|
|
1163
1191
|
}
|
|
1164
1192
|
function protectSlackAssistantTranscriptRoleHeaders(text) {
|
|
1165
1193
|
if (text.startsWith(SLACK_ASSISTANT_TRANSCRIPT_PREFIX)) return text;
|
|
1166
|
-
|
|
1167
|
-
const fallbackProjection = projectSlackMrkdwnVisibleText(text, "fallback");
|
|
1168
|
-
if (!slackProjectionHasRoleHeader(tokenProjection) && !slackProjectionHasRoleHeader(fallbackProjection)) return text;
|
|
1194
|
+
if (!slackProjectionHasRoleHeader(projectSlackMrkdwnVisibleText(text, "token")) && (!text.includes("<!date^") || !slackProjectionHasRoleHeader(projectSlackMrkdwnVisibleText(text, "fallback")))) return text;
|
|
1169
1195
|
return `${SLACK_ASSISTANT_TRANSCRIPT_PREFIX}${text}`;
|
|
1170
1196
|
}
|
|
1171
1197
|
function buildSlackRenderOptions() {
|
|
@@ -1201,18 +1227,16 @@ function buildSlackRenderOptions() {
|
|
|
1201
1227
|
buildLink: buildSlackLink
|
|
1202
1228
|
};
|
|
1203
1229
|
}
|
|
1204
|
-
function
|
|
1205
|
-
|
|
1230
|
+
function normalizeSlackOutboundText(markdown, options = {}) {
|
|
1231
|
+
const ir = makeSlackEmphasisStylesSafe(markdownToIR(markdown ?? "", {
|
|
1206
1232
|
assistantTranscriptRoleHeaders: true,
|
|
1207
1233
|
linkify: false,
|
|
1208
1234
|
autolink: false,
|
|
1209
1235
|
headingStyle: "rich",
|
|
1210
1236
|
blockquotePrefix: "> ",
|
|
1211
1237
|
tableMode: options.tableMode
|
|
1212
|
-
}))
|
|
1213
|
-
|
|
1214
|
-
function normalizeSlackOutboundText(markdown) {
|
|
1215
|
-
return protectSlackAssistantTranscriptRoleHeaders(markdownToSlackMrkdwn(markdown ?? ""));
|
|
1238
|
+
}));
|
|
1239
|
+
return protectSlackAssistantTranscriptRoleHeaders(renderMarkdownWithMarkers(ir, buildSlackRenderOptions(), SLACK_FORMAT_PROFILE));
|
|
1216
1240
|
}
|
|
1217
1241
|
/** Chunk already-rendered Slack mrkdwn without splitting entities or code markers. */
|
|
1218
1242
|
function chunkSlackMrkdwnText(text, limit) {
|
|
@@ -1395,13 +1419,19 @@ function resolveSlackButtonStyle(style) {
|
|
|
1395
1419
|
if (style === "primary" || style === "danger") return style;
|
|
1396
1420
|
if (style === "success") return "primary";
|
|
1397
1421
|
}
|
|
1398
|
-
function resolveSlackActionTarget(action,
|
|
1422
|
+
function resolveSlackActionTarget(action, questionOptionIndices) {
|
|
1399
1423
|
if (!action) return;
|
|
1400
1424
|
if (action.type === "approval") return {
|
|
1401
1425
|
kind: "approval",
|
|
1402
1426
|
value: encodeSlackApprovalAction(action)
|
|
1403
1427
|
};
|
|
1404
1428
|
if (action.type === "question") {
|
|
1429
|
+
if ("intent" in action) return;
|
|
1430
|
+
const optionIndex = resolveAskUserQuestionOptionIndex({
|
|
1431
|
+
questionOptionIndices,
|
|
1432
|
+
questionId: action.questionId,
|
|
1433
|
+
optionValue: action.optionValue
|
|
1434
|
+
});
|
|
1405
1435
|
const value = optionIndex === void 0 ? void 0 : encodeSlackQuestionAction({
|
|
1406
1436
|
questionId: action.questionId,
|
|
1407
1437
|
optionIndex
|
|
@@ -1431,10 +1461,10 @@ function resolveSlackActionTarget(action, optionIndex) {
|
|
|
1431
1461
|
value: command
|
|
1432
1462
|
} : void 0;
|
|
1433
1463
|
}
|
|
1434
|
-
function resolveSlackButtonTarget(button,
|
|
1464
|
+
function resolveSlackButtonTarget(button, questionOptionIndices) {
|
|
1435
1465
|
if (button.action !== void 0) {
|
|
1436
1466
|
const action = resolveMessagePresentationButtonAction(button);
|
|
1437
|
-
return action ? resolveSlackActionTarget(action,
|
|
1467
|
+
return action ? resolveSlackActionTarget(action, questionOptionIndices) : void 0;
|
|
1438
1468
|
}
|
|
1439
1469
|
const legacyUrl = normalizeOptionalString(button.url ?? button.webApp?.url ?? button.web_app?.url);
|
|
1440
1470
|
if (legacyUrl && isWithinSlackLimit(legacyUrl, SLACK_BUTTON_URL_MAX)) return {
|
|
@@ -1451,6 +1481,10 @@ function resolveSlackButtonTarget(button, optionIndex) {
|
|
|
1451
1481
|
url: legacyUrl
|
|
1452
1482
|
} : void 0;
|
|
1453
1483
|
}
|
|
1484
|
+
function isSlackTextFallbackButton(button) {
|
|
1485
|
+
const action = resolveMessagePresentationButtonAction(button);
|
|
1486
|
+
return action?.type === "question" && "intent" in action && action.intent === "custom-input";
|
|
1487
|
+
}
|
|
1454
1488
|
function resolveSlackOptionTarget(option) {
|
|
1455
1489
|
if (option.action !== void 0) {
|
|
1456
1490
|
const action = resolveMessagePresentationOptionAction(option);
|
|
@@ -1546,7 +1580,7 @@ function buildSlackPresentationBlocks(presentation, options = {}) {
|
|
|
1546
1580
|
continue;
|
|
1547
1581
|
}
|
|
1548
1582
|
if (block.type === "buttons") {
|
|
1549
|
-
const rendered = buildSlackPresentationButtonBlock(block, buttonIndex + 1);
|
|
1583
|
+
const rendered = buildSlackPresentationButtonBlock(block, buttonIndex + 1, options.questionOptionIndices);
|
|
1550
1584
|
if (rendered) {
|
|
1551
1585
|
buttonIndex += 1;
|
|
1552
1586
|
blocks.push(rendered);
|
|
@@ -1593,9 +1627,9 @@ function buildSlackPresentationBlocks(presentation, options = {}) {
|
|
|
1593
1627
|
function buildSlackPresentationChartBlock(block) {
|
|
1594
1628
|
return buildSlackDataVisualizationBlock(block);
|
|
1595
1629
|
}
|
|
1596
|
-
function buildSlackPresentationButtonBlock(block, buttonIndex) {
|
|
1630
|
+
function buildSlackPresentationButtonBlock(block, buttonIndex, questionOptionIndices) {
|
|
1597
1631
|
const elements = block.buttons.flatMap((button, choiceIndex) => {
|
|
1598
|
-
const target = resolveSlackButtonTarget(button,
|
|
1632
|
+
const target = resolveSlackButtonTarget(button, questionOptionIndices);
|
|
1599
1633
|
if (!target || (target.kind === "link" ? !isWithinSlackLimit(target.url, SLACK_BUTTON_URL_MAX) : !isWithinSlackLimit(target.value, 2e3))) return [];
|
|
1600
1634
|
const style = resolveSlackButtonStyle(button.style);
|
|
1601
1635
|
return [{
|
|
@@ -1635,11 +1669,14 @@ function canRenderSlackPresentation(presentation, options = {}) {
|
|
|
1635
1669
|
for (const block of presentation.blocks) {
|
|
1636
1670
|
if (block.type === "text" || block.type === "context") continue;
|
|
1637
1671
|
if (block.type === "buttons") {
|
|
1638
|
-
|
|
1672
|
+
let nativeButtonCount = 0;
|
|
1673
|
+
if (!(block.buttons.every((button) => {
|
|
1674
|
+
if (isSlackTextFallbackButton(button)) return true;
|
|
1675
|
+
nativeButtonCount += 1;
|
|
1639
1676
|
if (!isWithinSlackLimit(button.label, 75)) return false;
|
|
1640
|
-
const target = resolveSlackButtonTarget(button,
|
|
1677
|
+
const target = resolveSlackButtonTarget(button, options.questionOptionIndices);
|
|
1641
1678
|
return target ? target.kind === "link" ? isWithinSlackLimit(target.url, SLACK_BUTTON_URL_MAX) : isWithinSlackLimit(target.value, 2e3) : false;
|
|
1642
|
-
}))) return false;
|
|
1679
|
+
}) && nativeButtonCount <= 25)) return false;
|
|
1643
1680
|
continue;
|
|
1644
1681
|
}
|
|
1645
1682
|
if (block.type === "select") {
|
|
@@ -1750,49 +1787,6 @@ function readTextObject(value, options = {}) {
|
|
|
1750
1787
|
function readTextValue(value, options = {}) {
|
|
1751
1788
|
return normalizeOptionalString(value) ?? readTextObject(value, options);
|
|
1752
1789
|
}
|
|
1753
|
-
function renderSlackRichTextLeaf(element) {
|
|
1754
|
-
switch (element.type) {
|
|
1755
|
-
case "text": return typeof element.text === "string" ? escapeSlackMrkdwn(element.text) : "";
|
|
1756
|
-
case "link": return escapeSlackMrkdwn(normalizeOptionalString(element.text) ?? normalizeOptionalString(element.url) ?? "");
|
|
1757
|
-
case "user": {
|
|
1758
|
-
const userId = normalizeOptionalString(element.user_id);
|
|
1759
|
-
return userId ? escapeSlackMrkdwn(`<@${userId}>`) : "";
|
|
1760
|
-
}
|
|
1761
|
-
case "channel": {
|
|
1762
|
-
const channelId = normalizeOptionalString(element.channel_id);
|
|
1763
|
-
return channelId ? escapeSlackMrkdwn(`<#${channelId}>`) : "";
|
|
1764
|
-
}
|
|
1765
|
-
case "usergroup": {
|
|
1766
|
-
const usergroupId = normalizeOptionalString(element.usergroup_id);
|
|
1767
|
-
return usergroupId ? escapeSlackMrkdwn(`<!subteam^${usergroupId}>`) : "";
|
|
1768
|
-
}
|
|
1769
|
-
case "broadcast": {
|
|
1770
|
-
const range = normalizeOptionalString(element.range);
|
|
1771
|
-
return range ? escapeSlackMrkdwn(`<!${range}>`) : "";
|
|
1772
|
-
}
|
|
1773
|
-
case "emoji": {
|
|
1774
|
-
const name = normalizeOptionalString(element.name);
|
|
1775
|
-
return name ? `:${name}:` : "";
|
|
1776
|
-
}
|
|
1777
|
-
case "date": return escapeSlackMrkdwn(normalizeOptionalString(element.fallback) ?? "");
|
|
1778
|
-
default: return "";
|
|
1779
|
-
}
|
|
1780
|
-
}
|
|
1781
|
-
function renderSlackRichTextElement(value) {
|
|
1782
|
-
const element = asOptionalRecord(value);
|
|
1783
|
-
if (!element) return "";
|
|
1784
|
-
switch (element.type) {
|
|
1785
|
-
case "rich_text_section":
|
|
1786
|
-
case "rich_text_preformatted":
|
|
1787
|
-
case "rich_text_quote": return renderSlackRichTextElements(element.elements, "");
|
|
1788
|
-
case "rich_text_list": return renderSlackRichTextElements(element.elements, "\n");
|
|
1789
|
-
default: return renderSlackRichTextLeaf(element);
|
|
1790
|
-
}
|
|
1791
|
-
}
|
|
1792
|
-
function renderSlackRichTextElements(value, separator) {
|
|
1793
|
-
if (!Array.isArray(value)) return "";
|
|
1794
|
-
return value.map(renderSlackRichTextElement).filter(Boolean).join(separator);
|
|
1795
|
-
}
|
|
1796
1790
|
function readImageText(block) {
|
|
1797
1791
|
const altText = normalizeOptionalString(block.alt_text);
|
|
1798
1792
|
return (altText ? escapeSlackMrkdwn(altText) : void 0) ?? readTextObject(block.title);
|
|
@@ -1842,7 +1836,7 @@ function renderSlackBlockFallbackText(raw, options = {}) {
|
|
|
1842
1836
|
const block = asOptionalRecord(raw);
|
|
1843
1837
|
if (!block) return;
|
|
1844
1838
|
switch (block.type) {
|
|
1845
|
-
case "rich_text": return normalizeOptionalString(
|
|
1839
|
+
case "rich_text": return normalizeOptionalString(renderSlackRichText(block.elements, options.nativeReferenceFormat === "plain" ? "native-reference" : "escaped", "\n"));
|
|
1846
1840
|
case "header": return readTextObject(block.text, options);
|
|
1847
1841
|
case "section": return readSectionText(block, options);
|
|
1848
1842
|
case "image": return readImageText(block) ?? "Shared an image";
|
|
@@ -1869,7 +1863,7 @@ function buildSlackCompleteBlocksFallbackText(blocks) {
|
|
|
1869
1863
|
//#endregion
|
|
1870
1864
|
//#region extensions/slack/src/native-data-blocks.ts
|
|
1871
1865
|
const SLACK_MALFORMED_NATIVE_DATA_FALLBACK = "Slack could not render this chart or table data.";
|
|
1872
|
-
const SLACK_RESPONSE_URL_BODY_LIMIT_BYTES =
|
|
1866
|
+
const SLACK_RESPONSE_URL_BODY_LIMIT_BYTES = 16384;
|
|
1873
1867
|
const SLACK_RESPONSE_URL_BODY_TIMEOUT_MS = 3e4;
|
|
1874
1868
|
/** Detect a native Slack chart or table block. */
|
|
1875
1869
|
function hasSlackNativeDataBlock(blocks) {
|
|
@@ -2034,7 +2028,10 @@ function resolveSlackReplyDeliveryMessages(params) {
|
|
|
2034
2028
|
...baseText ? { nativeDataFallbackBaseText: baseText } : {}
|
|
2035
2029
|
});
|
|
2036
2030
|
}
|
|
2037
|
-
if (outsideText) messages.push({
|
|
2031
|
+
if (outsideText) messages.push({
|
|
2032
|
+
text: outsideText,
|
|
2033
|
+
authoredTextPlacement: "outside-blocks"
|
|
2034
|
+
});
|
|
2038
2035
|
return messages;
|
|
2039
2036
|
}
|
|
2040
2037
|
function resolveSlackReplyText(payload, text = payload.text) {
|
|
@@ -2173,14 +2170,20 @@ function renderNativePresentation(presentation, options) {
|
|
|
2173
2170
|
const blocks = buildSlackPresentationBlocks(presentation, options);
|
|
2174
2171
|
return blocks.length > 0 ? blocks : void 0;
|
|
2175
2172
|
}
|
|
2176
|
-
function appendPresentationPart(segments, presentation) {
|
|
2173
|
+
function appendPresentationPart(segments, presentation, questionOptionIndices) {
|
|
2177
2174
|
const currentBlocks = readLastBlockSegment(segments);
|
|
2178
|
-
const currentRendered = renderNativePresentation(presentation,
|
|
2175
|
+
const currentRendered = renderNativePresentation(presentation, {
|
|
2176
|
+
...resolvePresentationRenderOptions(segments, "current"),
|
|
2177
|
+
questionOptionIndices
|
|
2178
|
+
});
|
|
2179
2179
|
if (currentRendered && currentBlocks.length + currentRendered.length <= 50) {
|
|
2180
2180
|
appendBlockSegment(segments, currentRendered);
|
|
2181
2181
|
return;
|
|
2182
2182
|
}
|
|
2183
|
-
const freshRendered = renderNativePresentation(presentation,
|
|
2183
|
+
const freshRendered = renderNativePresentation(presentation, {
|
|
2184
|
+
...resolvePresentationRenderOptions(segments, "new-message"),
|
|
2185
|
+
questionOptionIndices
|
|
2186
|
+
});
|
|
2184
2187
|
if (freshRendered) {
|
|
2185
2188
|
appendBlockSegment(segments, freshRendered, true);
|
|
2186
2189
|
return;
|
|
@@ -2256,15 +2259,19 @@ function resolveSlackReplyBlockResolution(payload, options = {}) {
|
|
|
2256
2259
|
}
|
|
2257
2260
|
if (compiledChannelBlocks.length > 0) appendBlockSegment(segments, compiledChannelBlocks);
|
|
2258
2261
|
const presentation = normalizeMessagePresentation(payload.presentation);
|
|
2262
|
+
const questionOptionIndices = resolveAskUserQuestionOptionIndices(payload);
|
|
2259
2263
|
const presentationBlockOffset = readAllNativeBlocks(segments).length;
|
|
2260
2264
|
if (presentation?.title) appendPresentationPart(segments, {
|
|
2261
2265
|
title: presentation.title,
|
|
2262
2266
|
blocks: []
|
|
2263
|
-
});
|
|
2264
|
-
for (const block of presentation?.blocks ?? []) appendPresentationPart(segments, { blocks: [block] });
|
|
2267
|
+
}, questionOptionIndices);
|
|
2268
|
+
for (const block of presentation?.blocks ?? []) appendPresentationPart(segments, { blocks: [block] }, questionOptionIndices);
|
|
2265
2269
|
const renderedPresentationBlocks = readAllNativeBlocks(segments).slice(presentationBlockOffset);
|
|
2266
2270
|
appendBlockSegment(segments, subtractMirroredSlackControlRows({
|
|
2267
|
-
interactiveBlocks: buildSlackInteractiveBlocks(payload.interactive,
|
|
2271
|
+
interactiveBlocks: buildSlackInteractiveBlocks(payload.interactive, {
|
|
2272
|
+
...resolveSlackBlockOffsets(readAllNativeBlocks(segments)),
|
|
2273
|
+
questionOptionIndices
|
|
2274
|
+
}),
|
|
2268
2275
|
presentationBlocks: renderedPresentationBlocks
|
|
2269
2276
|
}));
|
|
2270
2277
|
const renderedTextFragments = segments.flatMap((segment) => {
|
|
@@ -2293,113 +2300,6 @@ function assertSlackDetachedTargetAllowed(accountId, teamId) {
|
|
|
2293
2300
|
if (installationKind && installationKind !== "workspace" && !teamId) throw new Error("unsupported_enterprise_slack_delivery: detached Slack operations require team:<team-id>:channel:<channel-id> or team:<team-id>:user:<user-id> until a workspace install is authenticated");
|
|
2294
2301
|
}
|
|
2295
2302
|
//#endregion
|
|
2296
|
-
//#region extensions/slack/src/monitor/allow-list.ts
|
|
2297
|
-
const SLACK_SLUG_CACHE_MAX = 512;
|
|
2298
|
-
const SLACK_STABLE_USER_ID_RE = /^[ubw][a-z0-9]+$/;
|
|
2299
|
-
const slackSlugCache = /* @__PURE__ */ new Map();
|
|
2300
|
-
function normalizeSlackSlug(raw) {
|
|
2301
|
-
const key = raw ?? "";
|
|
2302
|
-
const cached = slackSlugCache.get(key);
|
|
2303
|
-
if (cached !== void 0) return cached;
|
|
2304
|
-
const normalized = normalizeHyphenSlug(raw);
|
|
2305
|
-
slackSlugCache.set(key, normalized);
|
|
2306
|
-
if (slackSlugCache.size > SLACK_SLUG_CACHE_MAX) {
|
|
2307
|
-
const oldest = slackSlugCache.keys().next();
|
|
2308
|
-
if (!oldest.done) slackSlugCache.delete(oldest.value);
|
|
2309
|
-
}
|
|
2310
|
-
return normalized;
|
|
2311
|
-
}
|
|
2312
|
-
function normalizeAllowList(list) {
|
|
2313
|
-
return normalizeStringEntries$1(list);
|
|
2314
|
-
}
|
|
2315
|
-
function normalizeAllowListLower(list) {
|
|
2316
|
-
return normalizeStringEntriesLower(list);
|
|
2317
|
-
}
|
|
2318
|
-
function normalizeSlackAllowOwnerEntry(entry) {
|
|
2319
|
-
const trimmed = normalizeOptionalLowercaseString(entry);
|
|
2320
|
-
if (!trimmed || trimmed === "*") return;
|
|
2321
|
-
try {
|
|
2322
|
-
const target = parseSlackTarget(trimmed);
|
|
2323
|
-
if (target?.kind === "user" && target.teamId) return target.id.toLowerCase();
|
|
2324
|
-
} catch {
|
|
2325
|
-
return;
|
|
2326
|
-
}
|
|
2327
|
-
const withoutPrefix = trimmed.replace(/^(slack:|user:)/, "");
|
|
2328
|
-
return SLACK_STABLE_USER_ID_RE.test(withoutPrefix) ? withoutPrefix : void 0;
|
|
2329
|
-
}
|
|
2330
|
-
function resolveSlackAllowListMatch(params) {
|
|
2331
|
-
const compiledAllowList = compileAllowlist(params.allowList);
|
|
2332
|
-
const teamId = normalizeOptionalLowercaseString(params.teamId);
|
|
2333
|
-
const id = normalizeOptionalLowercaseString(params.id);
|
|
2334
|
-
const name = normalizeOptionalLowercaseString(params.name);
|
|
2335
|
-
const slug = normalizeSlackSlug(name);
|
|
2336
|
-
const scopedCandidates = [{
|
|
2337
|
-
value: teamId && id ? `team:${teamId}:user:${id}` : void 0,
|
|
2338
|
-
source: "workspace-id"
|
|
2339
|
-
}];
|
|
2340
|
-
const unscopedCandidates = [
|
|
2341
|
-
{
|
|
2342
|
-
value: id,
|
|
2343
|
-
source: "id"
|
|
2344
|
-
},
|
|
2345
|
-
{
|
|
2346
|
-
value: id ? `slack:${id}` : void 0,
|
|
2347
|
-
source: "prefixed-id"
|
|
2348
|
-
},
|
|
2349
|
-
{
|
|
2350
|
-
value: id ? `user:${id}` : void 0,
|
|
2351
|
-
source: "prefixed-user"
|
|
2352
|
-
},
|
|
2353
|
-
...params.allowNameMatching === true ? [
|
|
2354
|
-
{
|
|
2355
|
-
value: name,
|
|
2356
|
-
source: "name"
|
|
2357
|
-
},
|
|
2358
|
-
{
|
|
2359
|
-
value: name ? `slack:${name}` : void 0,
|
|
2360
|
-
source: "prefixed-name"
|
|
2361
|
-
},
|
|
2362
|
-
{
|
|
2363
|
-
value: slug,
|
|
2364
|
-
source: "slug"
|
|
2365
|
-
}
|
|
2366
|
-
] : []
|
|
2367
|
-
];
|
|
2368
|
-
return resolveCompiledAllowlistMatch({
|
|
2369
|
-
compiledAllowlist: compiledAllowList,
|
|
2370
|
-
candidates: [...scopedCandidates, ...unscopedCandidates]
|
|
2371
|
-
});
|
|
2372
|
-
}
|
|
2373
|
-
function allowListMatches(params) {
|
|
2374
|
-
return resolveSlackAllowListMatch(params).allowed;
|
|
2375
|
-
}
|
|
2376
|
-
function resolveSlackUserAllowed(params) {
|
|
2377
|
-
const allowList = normalizeAllowListLower(params.allowList);
|
|
2378
|
-
if (allowList.length === 0) return true;
|
|
2379
|
-
return allowListMatches({
|
|
2380
|
-
allowList,
|
|
2381
|
-
teamId: params.teamId,
|
|
2382
|
-
id: params.userId,
|
|
2383
|
-
name: params.userName,
|
|
2384
|
-
allowNameMatching: params.allowNameMatching
|
|
2385
|
-
});
|
|
2386
|
-
}
|
|
2387
|
-
function resolveSlackUserAllowListForTeam(params) {
|
|
2388
|
-
const allowList = normalizeAllowListLower(params.allowList);
|
|
2389
|
-
const teamId = normalizeOptionalLowercaseString(params.teamId);
|
|
2390
|
-
return allowList.flatMap((entry) => {
|
|
2391
|
-
if (entry === "*") return [entry];
|
|
2392
|
-
if (!entry.startsWith("team:")) return [entry];
|
|
2393
|
-
try {
|
|
2394
|
-
const target = parseSlackTarget(entry);
|
|
2395
|
-
if (target?.kind === "user" && target.teamId?.toLowerCase() === teamId) return [entry];
|
|
2396
|
-
return params.preserveUnmatchedScopedEntries ? [entry] : [];
|
|
2397
|
-
} catch {
|
|
2398
|
-
return params.preserveUnmatchedScopedEntries ? [entry] : [];
|
|
2399
|
-
}
|
|
2400
|
-
});
|
|
2401
|
-
}
|
|
2402
|
-
//#endregion
|
|
2403
2303
|
//#region extensions/slack/src/monitor/workspace-routing.ts
|
|
2404
2304
|
function resolveSlackEnterpriseMainDmSessionKey(params) {
|
|
2405
2305
|
const accountId = encodeURIComponent(params.accountId).toLowerCase();
|
|
@@ -2455,8 +2355,9 @@ function resolveSlackGroupRequireMention(params) {
|
|
|
2455
2355
|
return resolveScopeRequireMention(resolveSlackGroupPolicyScope(params));
|
|
2456
2356
|
}
|
|
2457
2357
|
function resolveSlackGroupToolPolicy(params) {
|
|
2358
|
+
const scope = resolveSlackGroupPolicyScope(params);
|
|
2458
2359
|
return resolveScopeToolsPolicy({
|
|
2459
|
-
...
|
|
2360
|
+
...scope,
|
|
2460
2361
|
senderPolicyMode: params.senderPolicyMode,
|
|
2461
2362
|
senderId: params.senderId,
|
|
2462
2363
|
senderName: params.senderName,
|
|
@@ -2465,4 +2366,4 @@ function resolveSlackGroupToolPolicy(params) {
|
|
|
2465
2366
|
});
|
|
2466
2367
|
}
|
|
2467
2368
|
//#endregion
|
|
2468
|
-
export {
|
|
2369
|
+
export { renderSlackMessagePresentationFallbackText as $, SLACK_MESSAGE_TEXT_HARD_LIMIT as A, SLACK_PRIVATE_ACTION_DELIVERY_RESULT as At, SLACK_REPLY_BUTTON_ACTION_ID as B, isSlackNativeResponseUrlRejection as C, isSlackApprovalAuthorizedSender as Ct, renderSlackBlockFallbackText as D, normalizeSlackApproverId as Dt, buildSlackCompleteBlocksFallbackText as E, isSlackExecApprovalClientEnabled as Et, canRenderSlackPresentation as F, isSlackCallbackActionId as G, SLACK_REPLY_SELECT_ACTION_ID as H, countSlackTextUtf8Bytes as I, decodeSlackQuestionAction as J, isSlackQuestionActionId as K, truncateSlackText as L, SLACK_TEXT_LIMIT as M, buildSlackInteractiveBlocks as N, resolveSlackAuthoredTextPlacement as O, resolveSlackExecApprovalTarget as Ot, buildSlackPresentationBlocks as P, normalizeSlackOutboundText as Q, truncateSlackTextByUtf8Bytes as R, isSlackInvalidBlocksResponse as S, getSlackApprovalApproversForTeam as St, buildSlackBlocksFallbackText as T, isSlackExecApprovalAuthorizedSender as Tt, SLACK_SESSION_LINK_ACTION_ID as U, SLACK_REPLY_LINK_ACTION_ID as V, isSlackApprovalActionId as W, chunkSlackMrkdwnText as X, resolveSlackQuestionAction as Y, markdownToSlackMrkdwnChunks as Z, appendSlackNativeDataPlainTextFallback as _, shouldHandleSlackPluginViaForwardingSession as _t, qualifySlackConversationId as a, SLACK_MAX_BLOCKS as at, hasSlackNativeDataBlock as b, isSlackWorkspaceInstallation as bt, assertSlackDetachedTargetAllowed as c, hasSlackPluginApprovers as ct, resolveSlackReplyBlockResolution as d, normalizeSlackOriginTarget as dt, escapeSlackMrkdwn as et, resolveSlackReplyBlocks as f, resolveEnterpriseApprovalTeamId as ft, appendSlackNativeDataFallbackText as g, shouldHandleSlackNativeApprovalRequest as gt, SLACK_MALFORMED_NATIVE_DATA_FALLBACK as h, resolveTurnSourceSlackOriginTarget as ht, resolveSlackGroupToolPolicy as i, SLACK_SECTION_TEXT_MAX as it, SLACK_MESSAGE_TEXT_RECOMMENDED_LIMIT as j, resolveSlackAutoThreadId as jt, SLACK_EDIT_TEXT_MAX_BYTES as k, shouldSuppressLocalSlackExecApprovalPrompt as kt, hasSlackReplyStructuredContent as l, isSlackAnyNativeApprovalClientEnabled as lt, resolveSlackReplyRenderPlan as m, resolveSlackFallbackOriginTarget as mt, buildSlackChannelPolicyScope as n, decodeSlackApprovalAction as nt, qualifySlackRoutePeerId as o, parseSlackBlocksInput as ot, resolveSlackReplyDeliveryMessages as p, resolveSessionSlackOriginTarget as pt, resolveSlackQuestionActionIds as q, resolveSlackGroupRequireMention as r, SLACK_PRESENTATION_CAPABILITIES as rt, resolveSlackEnterpriseMainDmSessionKey as s, validateSlackBlocksArray as st, buildSlackChannelIdCandidates as t, SLACK_APPROVAL_HEADER_BLOCK_ID as tt, parseSlackReplyBlockSegments as u, normalizeSlackForwardTarget as ut, buildSlackNativeDataAccessibilityText as v, slackTargetsMatch as vt, stripSlackNativeDataBlocks as w, getSlackExecApprovalApprovers as wt, isSlackInvalidBlocksError as x, registerSlackInstallationState as xt, createSlackNativeDataBaseTextConsumer as y, getSlackInstallationKind as yt, SLACK_QUESTION_FINALIZATION_BLOCKS as z };
|