@openclaw/slack 2026.7.1 → 2026.7.2-beta.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/accounts.runtime-KvftRRek.js +2 -0
- package/dist/{action-runtime-DoQGk_8D.js → action-runtime-p6M2ULpv.js} +205 -29
- package/dist/action-runtime.runtime-DQstDkHG.js +2 -0
- package/dist/{actions-DMpDmKEA.js → actions-DkTcWmpT.js} +87 -138
- package/dist/{actions.runtime-C103_BPW.js → actions.runtime-BSxpwgUc.js} +1 -1
- package/dist/api.js +14 -13
- package/dist/{approval-handler.runtime-CIUbOt5T.js → approval-handler.runtime-UGbnz9OC.js} +3 -3
- package/dist/{channel-BjlsaGHn.js → channel-B0_j6C6z.js} +116 -140
- package/dist/channel-config-api.js +1 -1
- package/dist/channel-plugin-api.js +1 -1
- package/dist/channel-type-BpeTezY4.js +109 -0
- package/dist/{channel.setup-Dq6syTNU.js → channel.setup-BQFut21T.js} +2 -2
- package/dist/{client-DGxwSL7f.js → client-D2F6m8CP.js} +38 -2
- package/dist/config-api-Df9a1B8C.js +3 -0
- package/dist/{config-schema-BzqzFW__.js → config-schema-DYI01PV2.js} +20 -37
- package/dist/cursor-pages-DSmTg0su.js +13 -0
- package/dist/{directory-config-BZuS8141.js → directory-config-DRkFujwG.js} +2 -2
- package/dist/directory-contract-api.js +1 -1
- package/dist/{directory-live-BNsxCgqP.js → directory-live-DX7yFsM-.js} +2 -2
- package/dist/{doctor-contract-XL6HeNCb.js → doctor-contract-DddfkMlF.js} +25 -38
- package/dist/doctor-contract-api.js +1 -1
- package/dist/group-policy-C-b2ZnSl.js +2332 -0
- package/dist/{interactive-replies-CXpT-vA_.js → interactive-replies-BilWUdcI.js} +5 -1
- package/dist/interactive-replies-api.js +1 -1
- package/dist/{message-tool-api-BgWKyu2r.js → message-tool-api-CA9jZrCY.js} +1 -1
- package/dist/message-tool-api.js +1 -1
- package/dist/{monitor-Ux-wzUWI.js → monitor-BN_uuvrQ.js} +3 -3
- package/dist/outbound-adapter-ECl0go7d.js +228 -0
- package/dist/{pipeline.runtime-rpVpay59.js → pipeline.runtime-f0eJJoJL.js} +492 -178
- package/dist/{policy-Dj-puVPb.js → policy-f8b0edSi.js} +1 -1
- package/dist/preflight-audio.runtime-D5Bgags0.js +3 -0
- package/dist/{probe-CuwRDE5j.js → probe-CfALk0l4.js} +2 -2
- package/dist/{provider-C1-DFSpw.js → provider-Ds-y-imP.js} +658 -192
- package/dist/{relay-source-D2jv1iGg.js → relay-source-B-6LFUdz.js} +6 -17
- package/dist/replies-BMvf3ihj.js +420 -0
- package/dist/{resolve-channels-CstkChBE.js → resolve-channels-DOMgNCWb.js} +17 -6
- package/dist/{resolve-users-C3NP2c-Q.js → resolve-users-aL6-Ssee.js} +11 -6
- package/dist/{runtime-BOk7xkOl.js → runtime-CauEvswP.js} +1 -1
- package/dist/{runtime-api-CEmqYxR-.js → runtime-api-CVb6CQjX.js} +3 -3
- package/dist/runtime-api.js +11 -11
- package/dist/runtime-setter-api.js +1 -1
- package/dist/{scopes-DCWVD5-8.js → scopes-Dw8wbU0j.js} +2 -2
- package/dist/{secret-contract-C3ChHo5A.js → secret-contract-CMohXFWS.js} +18 -113
- package/dist/secret-contract-api.js +1 -1
- package/dist/{send-DKDXoeoV.js → send-NEfJ0GvM.js} +662 -325
- package/dist/{send.runtime-GPRa63l1.js → send.runtime-BkKpitPu.js} +1 -1
- package/dist/setup-plugin-api.js +1 -1
- package/dist/{setup-surface-Dv2fIJNB.js → setup-surface-BN2WeG5c.js} +3 -3
- package/dist/{shared-CosfcFri.js → shared-BLnB9R1T.js} +7 -5
- package/dist/{slash-dispatch.runtime-CcMbbT3_.js → slash-dispatch.runtime-C0Otuf_T.js} +1 -1
- package/dist/{streaming-compat-DjlgH-Be.js → streaming-compat-3_X-21wW.js} +1 -0
- package/dist/{target-parsing-3jYH8LfB.js → target-parsing-N6lHogYZ.js} +16 -3
- package/dist/{targets-Dll4NJgs.js → targets-KmjP2E8s.js} +1 -1
- package/node_modules/p-map/index.d.ts +155 -0
- package/node_modules/p-map/index.js +284 -0
- package/node_modules/p-map/license +9 -0
- package/node_modules/p-map/package.json +57 -0
- package/node_modules/p-map/readme.md +190 -0
- package/npm-shrinkwrap.json +16 -3
- package/openclaw.plugin.json +16 -0
- package/package.json +6 -4
- package/dist/accounts.runtime-DWvaCb-X.js +0 -2
- package/dist/action-runtime.runtime-BABj3aM-.js +0 -2
- package/dist/config-api-DnT9ohtE.js +0 -2
- package/dist/format-YCNoNkM2.js +0 -107
- package/dist/outbound-adapter-DVoBfBW5.js +0 -272
- package/dist/replies-DpF38e1y.js +0 -287
- package/dist/reply-blocks-BGQ6zSqM.js +0 -877
- package/dist/resolve-allowlist-common-CP8SH0Zf.js +0 -43
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import { a as resolveSlackAccount, i as resolveDefaultSlackAccountId, l as resolveSlackOperationToken, n as listSlackAccountIds, o as resolveSlackAccountAllowFrom, u as resolveSlackReplyToMode } from "./accounts-BOJJiHSr.js";
|
|
2
|
-
import {
|
|
3
|
-
import { t as slackContextTargetsMatch } from "./targets-
|
|
4
|
-
import {
|
|
1
|
+
import { a as resolveSlackAccount, i as resolveDefaultSlackAccountId, l as resolveSlackOperationToken, n as listSlackAccountIds, o as resolveSlackAccountAllowFrom, r as mergeSlackAccountConfig, u as resolveSlackReplyToMode } from "./accounts-BOJJiHSr.js";
|
|
2
|
+
import { a as resolveSlackChannelId, i as parseSlackTarget, n as looksLikeSlackTargetId, r as normalizeSlackMessagingTarget, t as canonicalizeSlackApiTargetId } from "./target-parsing-N6lHogYZ.js";
|
|
3
|
+
import { t as slackContextTargetsMatch } from "./targets-KmjP2E8s.js";
|
|
4
|
+
import { $ as isSlackAnyNativeApprovalClientEnabled, F as SLACK_TEXT_LIMIT, G as renderSlackMessagePresentationFallbackText, J as SLACK_PRESENTATION_CAPABILITIES, L as buildSlackPresentationBlocks, N as SLACK_EDIT_TEXT_LIMIT, Q as hasSlackPluginApprovers, R as canRenderSlackPresentation, at as shouldHandleSlackNativeApprovalRequest, ct as getSlackApprovalApprovers, dt as isSlackExecApprovalAuthorizedSender, et as normalizeSlackForwardTarget, ft as isSlackExecApprovalClientEnabled, g as resolveSlackReplyDeliveryMessages, h as resolveSlackReplyBlocks, ht as shouldSuppressLocalSlackExecApprovalPrompt, i as assertSlackDirectSendAllowed, it as resolveTurnSourceSlackOriginTarget, lt as isSlackApprovalAuthorizedSender, m as resolveSlackReplyBlockResolution, mt as resolveSlackExecApprovalTarget, n as resolveSlackGroupToolPolicy, nt as resolveSessionSlackOriginTarget, ot as shouldHandleSlackPluginViaForwardingSession, r as formatSlackError, rt as resolveSlackFallbackOriginTarget, st as slackTargetsMatch, t as resolveSlackGroupRequireMention, tt as normalizeSlackOriginTarget, ut as getSlackExecApprovalApprovers } from "./group-policy-C-b2ZnSl.js";
|
|
5
5
|
import { t as isSlackPluginAccountConfigured } from "./account-configured-DzC407uv.js";
|
|
6
6
|
import { n as resolveSlackThreadTsValue, t as normalizeSlackThreadTsCandidate } from "./thread-ts-DUGhaYKq.js";
|
|
7
|
-
import { n as extractSlackToolSend, t as describeSlackMessageTool } from "./message-tool-api-
|
|
8
|
-
import { n as isSlackInteractiveRepliesEnabled, t as compileSlackInteractiveReplies } from "./interactive-replies-
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
7
|
+
import { n as extractSlackToolSend, t as describeSlackMessageTool } from "./message-tool-api-CA9jZrCY.js";
|
|
8
|
+
import { n as isSlackInteractiveRepliesEnabled, t as compileSlackInteractiveReplies } from "./interactive-replies-BilWUdcI.js";
|
|
9
|
+
import { f as DEFAULT_ACCOUNT_ID$1, g as resolveConfiguredFromRequiredCredentialStatuses, h as projectCredentialSnapshotFields, i as createSlackWebClient, p as PAIRING_APPROVED_MESSAGE } from "./client-D2F6m8CP.js";
|
|
10
|
+
import { i as resolveSlackConversationInfo, r as resolveSlackChannelType } from "./channel-type-BpeTezY4.js";
|
|
11
|
+
import { t as getOptionalSlackRuntime } from "./runtime-CauEvswP.js";
|
|
12
|
+
import { n as slackConfigAdapter, r as slackSecurityAdapter, t as createSlackPluginBase } from "./shared-BLnB9R1T.js";
|
|
12
13
|
import { i as SLACK_CHANNEL, n as createSlackSetupWizardProxy, r as slackSetupAdapter } from "./setup-core-fGd6Gquy.js";
|
|
13
14
|
import { normalizeAccountId } from "openclaw/plugin-sdk/account-resolution";
|
|
14
15
|
import { normalizeLowercaseStringOrEmpty, normalizeOptionalLowercaseString, normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
@@ -31,7 +32,6 @@ import { readBooleanParam } from "openclaw/plugin-sdk/boolean-param";
|
|
|
31
32
|
import { resolveReactionMessageId } from "openclaw/plugin-sdk/channel-actions";
|
|
32
33
|
import { normalizeInteractiveReply, normalizeMessagePresentation } from "openclaw/plugin-sdk/interactive-runtime";
|
|
33
34
|
import { readPositiveIntegerParam, readStringParam } from "openclaw/plugin-sdk/param-readers";
|
|
34
|
-
import { pruneMapToMaxSize } from "openclaw/plugin-sdk/collection-runtime";
|
|
35
35
|
//#region extensions/slack/src/action-threading.ts
|
|
36
36
|
function resolveSlackAutoThreadId(params) {
|
|
37
37
|
const context = params.toolContext;
|
|
@@ -57,9 +57,10 @@ function shouldConsiderSlackNativeForwardingSuppression(input) {
|
|
|
57
57
|
}
|
|
58
58
|
const resolveSlackOriginTarget = createChannelNativeOriginTargetResolver({
|
|
59
59
|
channel: "slack",
|
|
60
|
-
shouldHandleRequest: ({ cfg, accountId, request }) => shouldHandleSlackNativeApprovalRequest({
|
|
60
|
+
shouldHandleRequest: ({ cfg, accountId, approvalKind, request }) => shouldHandleSlackNativeApprovalRequest({
|
|
61
61
|
cfg,
|
|
62
62
|
accountId,
|
|
63
|
+
approvalKind,
|
|
63
64
|
request
|
|
64
65
|
}),
|
|
65
66
|
resolveTurnSourceTarget: resolveTurnSourceSlackOriginTarget,
|
|
@@ -131,13 +132,13 @@ const baseSlackApprovalCapability = createApproverRestrictedNativeApprovalCapabi
|
|
|
131
132
|
cfg,
|
|
132
133
|
accountId
|
|
133
134
|
}),
|
|
134
|
-
shouldHandle: ({ cfg, accountId, request }) => shouldHandleSlackNativeApprovalRequest({
|
|
135
|
+
shouldHandle: ({ cfg, accountId, approvalKind, request }) => shouldHandleSlackNativeApprovalRequest({
|
|
135
136
|
cfg,
|
|
136
137
|
accountId,
|
|
137
|
-
approvalKind
|
|
138
|
+
approvalKind,
|
|
138
139
|
request
|
|
139
140
|
}),
|
|
140
|
-
load: async () => (await import("./approval-handler.runtime-
|
|
141
|
+
load: async () => (await import("./approval-handler.runtime-UGbnz9OC.js")).slackApprovalNativeRuntime
|
|
141
142
|
})
|
|
142
143
|
});
|
|
143
144
|
const baseSlackNativeAdapter = baseSlackApprovalCapability.native;
|
|
@@ -188,6 +189,22 @@ const slackApprovalCapability = {
|
|
|
188
189
|
};
|
|
189
190
|
//#endregion
|
|
190
191
|
//#region extensions/slack/src/message-action-dispatch.ts
|
|
192
|
+
function resolveSlackPresentationText(content, presentation) {
|
|
193
|
+
return presentation?.blocks.some((block) => block.type === "chart" || block.type === "table") ? renderSlackMessagePresentationFallbackText({
|
|
194
|
+
text: content,
|
|
195
|
+
presentation
|
|
196
|
+
}) : content ?? "";
|
|
197
|
+
}
|
|
198
|
+
function renderSlackActionPresentation(presentation) {
|
|
199
|
+
if (!presentation) return { usesPresentationTextFallback: false };
|
|
200
|
+
const renderedBlocks = canRenderSlackPresentation(presentation) ? buildSlackPresentationBlocks(presentation) : void 0;
|
|
201
|
+
const usesPresentationTextFallback = !renderedBlocks || renderedBlocks.length > 50;
|
|
202
|
+
const blocks = usesPresentationTextFallback ? void 0 : renderedBlocks;
|
|
203
|
+
return {
|
|
204
|
+
...blocks?.length ? { blocks } : {},
|
|
205
|
+
usesPresentationTextFallback
|
|
206
|
+
};
|
|
207
|
+
}
|
|
191
208
|
/** Translate generic channel action requests into Slack-specific tool invocations and payload shapes. */
|
|
192
209
|
async function handleSlackMessageAction(params) {
|
|
193
210
|
const { providerId, ctx, invoke, normalizeChannelId, includeReadThreadId = false } = params;
|
|
@@ -206,16 +223,27 @@ async function handleSlackMessageAction(params) {
|
|
|
206
223
|
const mediaUrl = readStringParam(actionParams, "media", { trim: false });
|
|
207
224
|
const presentation = normalizeMessagePresentation(actionParams.presentation);
|
|
208
225
|
const interactive = normalizeInteractiveReply(actionParams.interactive);
|
|
209
|
-
const
|
|
210
|
-
const
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
226
|
+
const hasStructuredContent = Boolean(presentation || interactive?.blocks.length);
|
|
227
|
+
const resolution = resolveSlackReplyBlockResolution({
|
|
228
|
+
text: content,
|
|
229
|
+
presentation,
|
|
230
|
+
interactive
|
|
231
|
+
}, { materializeAuthoredText: hasStructuredContent });
|
|
232
|
+
const preparedMessages = resolution.segments.length > 0 ? resolveSlackReplyDeliveryMessages({
|
|
233
|
+
authoredTextPlacement: resolution.authoredTextPlacement,
|
|
234
|
+
segments: resolution.segments,
|
|
235
|
+
text: content
|
|
236
|
+
}) : [];
|
|
237
|
+
if (!content && preparedMessages.length === 0 && !mediaUrl) throw new Error("Slack send requires message, blocks, or media.");
|
|
214
238
|
const replyBroadcast = readBooleanParam(actionParams, "replyBroadcast");
|
|
215
239
|
if (replyBroadcast && mediaUrl) throw new Error("Slack replyBroadcast is only supported for text or block thread replies.");
|
|
216
240
|
const threadId = readStringParam(actionParams, "threadId");
|
|
217
241
|
const replyTo = readStringParam(actionParams, "replyTo");
|
|
218
242
|
const topLevel = readBooleanParam(actionParams, "topLevel") === true || actionParams.threadId === null;
|
|
243
|
+
const toolContext = preparedMessages.length > 0 ? {
|
|
244
|
+
...ctx.toolContext,
|
|
245
|
+
preparedMessages
|
|
246
|
+
} : ctx.toolContext;
|
|
219
247
|
return await invoke({
|
|
220
248
|
action: "sendMessage",
|
|
221
249
|
to,
|
|
@@ -224,9 +252,8 @@ async function handleSlackMessageAction(params) {
|
|
|
224
252
|
accountId,
|
|
225
253
|
threadTs: threadId ?? replyTo ?? void 0,
|
|
226
254
|
...topLevel ? { topLevel: true } : {},
|
|
227
|
-
...replyBroadcast ? { replyBroadcast } : {}
|
|
228
|
-
|
|
229
|
-
}, cfg, ctx.toolContext);
|
|
255
|
+
...replyBroadcast ? { replyBroadcast } : {}
|
|
256
|
+
}, cfg, toolContext);
|
|
230
257
|
}
|
|
231
258
|
if (action === "react") {
|
|
232
259
|
const messageIdRaw = resolveReactionMessageId({
|
|
@@ -244,7 +271,7 @@ async function handleSlackMessageAction(params) {
|
|
|
244
271
|
emoji,
|
|
245
272
|
remove,
|
|
246
273
|
accountId
|
|
247
|
-
}, cfg);
|
|
274
|
+
}, cfg, ctx.toolContext);
|
|
248
275
|
}
|
|
249
276
|
if (action === "reactions") {
|
|
250
277
|
const messageId = readStringParam(actionParams, "messageId", { required: true });
|
|
@@ -255,7 +282,7 @@ async function handleSlackMessageAction(params) {
|
|
|
255
282
|
messageId,
|
|
256
283
|
limit,
|
|
257
284
|
accountId
|
|
258
|
-
}, cfg);
|
|
285
|
+
}, cfg, ctx.toolContext);
|
|
259
286
|
}
|
|
260
287
|
if (action === "read") {
|
|
261
288
|
const limit = readPositiveIntegerParam(actionParams, "limit", { message: "limit must be a positive integer." });
|
|
@@ -269,22 +296,28 @@ async function handleSlackMessageAction(params) {
|
|
|
269
296
|
accountId
|
|
270
297
|
};
|
|
271
298
|
if (includeReadThreadId) readAction.threadId = readStringParam(actionParams, "threadId");
|
|
272
|
-
return await invoke(readAction, cfg);
|
|
299
|
+
return await invoke(readAction, cfg, ctx.toolContext);
|
|
273
300
|
}
|
|
274
301
|
if (action === "edit") {
|
|
275
302
|
const messageId = readStringParam(actionParams, "messageId", { required: true });
|
|
276
303
|
const content = readStringParam(actionParams, "message", { allowEmpty: true });
|
|
277
304
|
const presentation = normalizeMessagePresentation(actionParams.presentation);
|
|
278
|
-
const
|
|
279
|
-
|
|
305
|
+
const renderedPresentation = renderSlackActionPresentation(presentation);
|
|
306
|
+
const blocks = renderedPresentation.usesPresentationTextFallback ? void 0 : renderedPresentation.blocks;
|
|
307
|
+
const accessibleContent = renderedPresentation.usesPresentationTextFallback ? renderSlackMessagePresentationFallbackText({
|
|
308
|
+
text: content,
|
|
309
|
+
presentation
|
|
310
|
+
}) : resolveSlackPresentationText(content, presentation);
|
|
311
|
+
if (renderedPresentation.usesPresentationTextFallback && accessibleContent.length > 4e3) throw new Error(`Slack presentation fallback exceeds the ${String(SLACK_EDIT_TEXT_LIMIT)}-character edit limit. Send a new message instead.`);
|
|
312
|
+
if (!accessibleContent && !blocks) throw new Error("Slack edit requires message or blocks.");
|
|
280
313
|
return await invoke({
|
|
281
314
|
action: "editMessage",
|
|
282
315
|
channelId: resolveChannelId(),
|
|
283
316
|
messageId,
|
|
284
|
-
content:
|
|
317
|
+
content: accessibleContent,
|
|
285
318
|
blocks,
|
|
286
319
|
accountId
|
|
287
|
-
}, cfg);
|
|
320
|
+
}, cfg, ctx.toolContext);
|
|
288
321
|
}
|
|
289
322
|
if (action === "delete") {
|
|
290
323
|
const messageId = readStringParam(actionParams, "messageId", { required: true });
|
|
@@ -293,7 +326,7 @@ async function handleSlackMessageAction(params) {
|
|
|
293
326
|
channelId: resolveChannelId(),
|
|
294
327
|
messageId,
|
|
295
328
|
accountId
|
|
296
|
-
}, cfg);
|
|
329
|
+
}, cfg, ctx.toolContext);
|
|
297
330
|
}
|
|
298
331
|
if (action === "pin" || action === "unpin" || action === "list-pins") {
|
|
299
332
|
const messageId = action === "list-pins" ? void 0 : readStringParam(actionParams, "messageId", { required: true });
|
|
@@ -302,7 +335,7 @@ async function handleSlackMessageAction(params) {
|
|
|
302
335
|
channelId: resolveChannelId(),
|
|
303
336
|
messageId,
|
|
304
337
|
accountId
|
|
305
|
-
}, cfg);
|
|
338
|
+
}, cfg, ctx.toolContext);
|
|
306
339
|
}
|
|
307
340
|
if (action === "member-info") {
|
|
308
341
|
const requesterAccountId = ctx.requesterAccountId ? normalizeAccountId(ctx.requesterAccountId) : void 0;
|
|
@@ -314,13 +347,13 @@ async function handleSlackMessageAction(params) {
|
|
|
314
347
|
action: "memberInfo",
|
|
315
348
|
userId,
|
|
316
349
|
accountId
|
|
317
|
-
}, cfg);
|
|
350
|
+
}, cfg, ctx.toolContext);
|
|
318
351
|
}
|
|
319
352
|
if (action === "emoji-list") return await invoke({
|
|
320
353
|
action: "emojiList",
|
|
321
354
|
limit: readPositiveIntegerParam(actionParams, "limit", { message: "limit must be a positive integer." }),
|
|
322
355
|
accountId
|
|
323
|
-
}, cfg);
|
|
356
|
+
}, cfg, ctx.toolContext);
|
|
324
357
|
if (action === "download-file") {
|
|
325
358
|
const fileIdParam = readStringParam(actionParams, "fileId");
|
|
326
359
|
const messageIdParam = readStringParam(actionParams, "messageId") ?? readStringParam(actionParams, "message_id");
|
|
@@ -368,13 +401,16 @@ const SLACK_TOOL_DELIVERY_ACTIONS = /* @__PURE__ */ new Set([
|
|
|
368
401
|
"unpinMessage",
|
|
369
402
|
"uploadFile"
|
|
370
403
|
]);
|
|
371
|
-
const loadSlackActionRuntime$1 = createLazyRuntimeModule(() => import("./action-runtime.runtime-
|
|
404
|
+
const loadSlackActionRuntime$1 = createLazyRuntimeModule(() => import("./action-runtime.runtime-DQstDkHG.js"));
|
|
372
405
|
function resolveSlackActionContext(params) {
|
|
373
|
-
if (!params.toolContext && !params.mediaLocalRoots && !params.mediaReadFile) return;
|
|
406
|
+
if (!params.toolContext && !params.mediaLocalRoots && !params.mediaReadFile && !params.conversationReadOrigin && !params.requesterAccountId && !params.requesterSenderId) return;
|
|
374
407
|
return {
|
|
375
408
|
...params.toolContext,
|
|
376
409
|
...params.mediaLocalRoots ? { mediaLocalRoots: params.mediaLocalRoots } : {},
|
|
377
|
-
...params.mediaReadFile ? { mediaReadFile: params.mediaReadFile } : {}
|
|
410
|
+
...params.mediaReadFile ? { mediaReadFile: params.mediaReadFile } : {},
|
|
411
|
+
conversationReadOrigin: params.conversationReadOrigin,
|
|
412
|
+
requesterAccountId: params.requesterAccountId ?? void 0,
|
|
413
|
+
requesterSenderId: params.requesterSenderId ?? void 0
|
|
378
414
|
};
|
|
379
415
|
}
|
|
380
416
|
function createSlackActions(providerId, options) {
|
|
@@ -393,7 +429,10 @@ function createSlackActions(providerId, options) {
|
|
|
393
429
|
const actionContext = resolveSlackActionContext({
|
|
394
430
|
toolContext,
|
|
395
431
|
mediaLocalRoots: ctx.mediaLocalRoots,
|
|
396
|
-
mediaReadFile: ctx.mediaReadFile
|
|
432
|
+
mediaReadFile: ctx.mediaReadFile,
|
|
433
|
+
conversationReadOrigin: ctx.conversationReadOrigin,
|
|
434
|
+
requesterAccountId: ctx.requesterAccountId,
|
|
435
|
+
requesterSenderId: ctx.requesterSenderId
|
|
397
436
|
});
|
|
398
437
|
return await (options?.invoke ? options.invoke(action, cfg, actionContext) : (await loadSlackActionRuntime$1()).handleSlackAction(action, cfg, actionContext));
|
|
399
438
|
}
|
|
@@ -402,88 +441,6 @@ function createSlackActions(providerId, options) {
|
|
|
402
441
|
};
|
|
403
442
|
}
|
|
404
443
|
//#endregion
|
|
405
|
-
//#region extensions/slack/src/channel-type.ts
|
|
406
|
-
const SLACK_CONVERSATION_INFO_CACHE_MAX_ENTRIES = 1024;
|
|
407
|
-
const SLACK_CONVERSATION_INFO_CACHE = /* @__PURE__ */ new Map();
|
|
408
|
-
function getCachedSlackConversationInfo(cacheKey) {
|
|
409
|
-
const cached = SLACK_CONVERSATION_INFO_CACHE.get(cacheKey);
|
|
410
|
-
if (cached) {
|
|
411
|
-
SLACK_CONVERSATION_INFO_CACHE.delete(cacheKey);
|
|
412
|
-
SLACK_CONVERSATION_INFO_CACHE.set(cacheKey, cached);
|
|
413
|
-
}
|
|
414
|
-
return cached;
|
|
415
|
-
}
|
|
416
|
-
function setCachedSlackConversationInfo(cacheKey, conversationInfo) {
|
|
417
|
-
SLACK_CONVERSATION_INFO_CACHE.delete(cacheKey);
|
|
418
|
-
SLACK_CONVERSATION_INFO_CACHE.set(cacheKey, conversationInfo);
|
|
419
|
-
pruneMapToMaxSize(SLACK_CONVERSATION_INFO_CACHE, SLACK_CONVERSATION_INFO_CACHE_MAX_ENTRIES);
|
|
420
|
-
}
|
|
421
|
-
async function resolveSlackConversationInfo(params) {
|
|
422
|
-
const channelId = params.channelId.trim();
|
|
423
|
-
if (!channelId) return { type: "unknown" };
|
|
424
|
-
const account = resolveSlackAccount({
|
|
425
|
-
cfg: params.cfg,
|
|
426
|
-
accountId: params.accountId
|
|
427
|
-
});
|
|
428
|
-
const cacheKey = `${account.accountId}:${channelId}`;
|
|
429
|
-
const cached = getCachedSlackConversationInfo(cacheKey);
|
|
430
|
-
if (cached) return cached;
|
|
431
|
-
const isNativeImChannel = /^D/i.test(channelId);
|
|
432
|
-
const groupChannels = normalizeAllowListLower(account.dm?.groupChannels);
|
|
433
|
-
const channelIdLower = normalizeLowercaseStringOrEmpty(channelId);
|
|
434
|
-
if (!isNativeImChannel && (groupChannels.includes(channelIdLower) || groupChannels.includes(`slack:${channelIdLower}`) || groupChannels.includes(`channel:${channelIdLower}`) || groupChannels.includes(`group:${channelIdLower}`) || groupChannels.includes(`mpim:${channelIdLower}`))) {
|
|
435
|
-
const result = { type: "group" };
|
|
436
|
-
setCachedSlackConversationInfo(cacheKey, result);
|
|
437
|
-
return result;
|
|
438
|
-
}
|
|
439
|
-
const channelKeys = Object.keys(account.channels ?? {});
|
|
440
|
-
if (!isNativeImChannel && channelKeys.some((key) => {
|
|
441
|
-
const normalized = normalizeLowercaseStringOrEmpty(key);
|
|
442
|
-
return normalized === channelIdLower || normalized === `channel:${channelIdLower}` || normalized.replace(/^#/, "") === channelIdLower;
|
|
443
|
-
})) {
|
|
444
|
-
const result = { type: "channel" };
|
|
445
|
-
setCachedSlackConversationInfo(cacheKey, result);
|
|
446
|
-
return result;
|
|
447
|
-
}
|
|
448
|
-
const token = normalizeOptionalString(account.botToken) ?? normalizeOptionalString(account.config.userToken) ?? "";
|
|
449
|
-
if (!token) {
|
|
450
|
-
const result = { type: isNativeImChannel ? "dm" : "unknown" };
|
|
451
|
-
if (!isNativeImChannel) setCachedSlackConversationInfo(cacheKey, result);
|
|
452
|
-
return result;
|
|
453
|
-
}
|
|
454
|
-
try {
|
|
455
|
-
const client = createSlackWebClient(token);
|
|
456
|
-
if (isNativeImChannel) {
|
|
457
|
-
const opened = await client.conversations.open({
|
|
458
|
-
channel: channelId,
|
|
459
|
-
prevent_creation: true,
|
|
460
|
-
return_im: true
|
|
461
|
-
});
|
|
462
|
-
const user = typeof opened.channel?.user === "string" && opened.channel.user.trim() ? opened.channel.user.trim() : void 0;
|
|
463
|
-
const result = user ? {
|
|
464
|
-
type: "dm",
|
|
465
|
-
user
|
|
466
|
-
} : { type: "dm" };
|
|
467
|
-
if (user) setCachedSlackConversationInfo(cacheKey, result);
|
|
468
|
-
return result;
|
|
469
|
-
}
|
|
470
|
-
const channel = (await client.conversations.info({ channel: channelId })).channel;
|
|
471
|
-
const result = { type: channel?.is_im ? "dm" : channel?.is_mpim ? "group" : "channel" };
|
|
472
|
-
setCachedSlackConversationInfo(cacheKey, result);
|
|
473
|
-
return result;
|
|
474
|
-
} catch {
|
|
475
|
-
const result = { type: isNativeImChannel ? "dm" : "unknown" };
|
|
476
|
-
if (!isNativeImChannel) setCachedSlackConversationInfo(cacheKey, result);
|
|
477
|
-
return result;
|
|
478
|
-
}
|
|
479
|
-
}
|
|
480
|
-
async function resolveSlackChannelType(params) {
|
|
481
|
-
return (await resolveSlackConversationInfo(params)).type;
|
|
482
|
-
}
|
|
483
|
-
function resetSlackChannelTypeCacheForTest() {
|
|
484
|
-
SLACK_CONVERSATION_INFO_CACHE.clear();
|
|
485
|
-
}
|
|
486
|
-
//#endregion
|
|
487
444
|
//#region extensions/slack/src/threading-tool-context.ts
|
|
488
445
|
function buildSlackThreadingToolContext(params) {
|
|
489
446
|
const account = resolveSlackAccount({
|
|
@@ -495,7 +452,7 @@ function buildSlackThreadingToolContext(params) {
|
|
|
495
452
|
const transportThreadTs = normalizeSlackThreadTsCandidate(params.context.TransportThreadId);
|
|
496
453
|
const replyToThreadTs = normalizeSlackThreadTsCandidate(params.context.ReplyToId);
|
|
497
454
|
const currentMessageTs = normalizeSlackThreadTsCandidate(params.context.CurrentMessageId);
|
|
498
|
-
const currentThreadTs = messageThreadTs ?? transportThreadTs ?? replyToThreadTs;
|
|
455
|
+
const currentThreadTs = messageThreadTs ?? transportThreadTs ?? replyToThreadTs ?? currentMessageTs;
|
|
499
456
|
const hasExplicitThreadTarget = messageThreadTs != null || transportThreadTs != null || replyToThreadTs != null && currentMessageTs != null && replyToThreadTs !== currentMessageTs;
|
|
500
457
|
const effectiveReplyToMode = hasExplicitThreadTarget ? "all" : configuredReplyToMode;
|
|
501
458
|
const currentMessagingTarget = normalizeOptionalString(params.context.To);
|
|
@@ -514,29 +471,30 @@ const EXTENSION_SHARED_MODULE_ID = "openclaw/plugin-sdk/extension-shared";
|
|
|
514
471
|
const TARGET_RESOLVER_RUNTIME_MODULE_ID = "openclaw/plugin-sdk/target-resolver-runtime";
|
|
515
472
|
const loadExtensionSharedSdk = createLazyRuntimeModule(() => import(EXTENSION_SHARED_MODULE_ID));
|
|
516
473
|
const loadTargetResolverRuntimeSdk = createLazyRuntimeModule(() => import(TARGET_RESOLVER_RUNTIME_MODULE_ID));
|
|
517
|
-
const loadSlackSetupSurfaceModule = createLazyRuntimeModule(() => import("./setup-surface-
|
|
518
|
-
const loadSlackScopesModule = createLazyRuntimeModule(() => import("./scopes-
|
|
519
|
-
const loadSlackOutboundAdapterModule = createLazyRuntimeModule(() => import("./outbound-adapter-
|
|
474
|
+
const loadSlackSetupSurfaceModule = createLazyRuntimeModule(() => import("./setup-surface-BN2WeG5c.js"));
|
|
475
|
+
const loadSlackScopesModule = createLazyRuntimeModule(() => import("./scopes-Dw8wbU0j.js"));
|
|
476
|
+
const loadSlackOutboundAdapterModule = createLazyRuntimeModule(() => import("./outbound-adapter-ECl0go7d.js"));
|
|
520
477
|
async function resolveSlackHandleAction() {
|
|
521
478
|
return getOptionalSlackRuntime()?.channel?.slack?.handleSlackAction ?? (await loadSlackActionRuntime()).handleSlackAction;
|
|
522
479
|
}
|
|
523
480
|
function shouldTreatSlackDeliveredTextAsVisible(params) {
|
|
524
481
|
return params.kind === "block" && typeof params.text === "string" && params.text.trim().length > 0;
|
|
525
482
|
}
|
|
526
|
-
const loadSlackDirectoryConfigModule = createLazyRuntimeModule(() => import("./directory-config-
|
|
527
|
-
const loadSlackResolveChannelsModule = createLazyRuntimeModule(() => import("./resolve-channels-
|
|
528
|
-
const loadSlackResolveUsersModule = createLazyRuntimeModule(() => import("./resolve-users-
|
|
529
|
-
const loadSlackActionRuntime = createLazyRuntimeModule(() => import("./action-runtime.runtime-
|
|
530
|
-
const loadSlackSendRuntime = createLazyRuntimeModule(() => import("./send.runtime-
|
|
531
|
-
const loadSlackProbeModule = createLazyRuntimeModule(() => import("./probe-
|
|
532
|
-
const loadSlackMonitorModule = createLazyRuntimeModule(() => import("./monitor-
|
|
533
|
-
const loadSlackDirectoryLiveModule = createLazyRuntimeModule(() => import("./directory-live-
|
|
483
|
+
const loadSlackDirectoryConfigModule = createLazyRuntimeModule(() => import("./directory-config-DRkFujwG.js").then((n) => n.t));
|
|
484
|
+
const loadSlackResolveChannelsModule = createLazyRuntimeModule(() => import("./resolve-channels-DOMgNCWb.js").then((n) => n.n));
|
|
485
|
+
const loadSlackResolveUsersModule = createLazyRuntimeModule(() => import("./resolve-users-aL6-Ssee.js").then((n) => n.n));
|
|
486
|
+
const loadSlackActionRuntime = createLazyRuntimeModule(() => import("./action-runtime.runtime-DQstDkHG.js"));
|
|
487
|
+
const loadSlackSendRuntime = createLazyRuntimeModule(() => import("./send.runtime-BkKpitPu.js"));
|
|
488
|
+
const loadSlackProbeModule = createLazyRuntimeModule(() => import("./probe-CfALk0l4.js").then((n) => n.n));
|
|
489
|
+
const loadSlackMonitorModule = createLazyRuntimeModule(() => import("./monitor-BN_uuvrQ.js").then((n) => n.t));
|
|
490
|
+
const loadSlackDirectoryLiveModule = createLazyRuntimeModule(() => import("./directory-live-DX7yFsM-.js").then((n) => n.t));
|
|
534
491
|
async function resolveSlackSendContext(params) {
|
|
535
|
-
const send = resolveOutboundSendDep(params.deps, "slack") ?? (await loadSlackSendRuntime()).sendMessageSlack;
|
|
536
492
|
const account = resolveSlackAccount({
|
|
537
493
|
cfg: params.cfg,
|
|
538
494
|
accountId: params.accountId
|
|
539
495
|
});
|
|
496
|
+
assertSlackDirectSendAllowed(account);
|
|
497
|
+
const send = resolveOutboundSendDep(params.deps, "slack") ?? (await loadSlackSendRuntime()).sendMessageSlack;
|
|
540
498
|
const token = resolveSlackOperationToken(account, "write");
|
|
541
499
|
const botToken = account.botToken?.trim();
|
|
542
500
|
const tokenOverride = token && token !== botToken ? token : void 0;
|
|
@@ -554,13 +512,15 @@ async function setSlackHeartbeatThreadStatus(params) {
|
|
|
554
512
|
cfg: params.cfg,
|
|
555
513
|
accountId: params.accountId
|
|
556
514
|
});
|
|
515
|
+
assertSlackDirectSendAllowed(account);
|
|
557
516
|
const botToken = normalizeOptionalString(account.botToken);
|
|
558
517
|
if (!botToken) return;
|
|
559
518
|
try {
|
|
560
519
|
const client = createSlackWebClient(botToken);
|
|
561
|
-
const
|
|
520
|
+
const apiTargetId = canonicalizeSlackApiTargetId(target.kind, target.id, params.to);
|
|
521
|
+
const channelId = target.kind === "channel" ? apiTargetId : await (await loadSlackSendRuntime()).resolveSlackDmChannelId({
|
|
562
522
|
client,
|
|
563
|
-
userId:
|
|
523
|
+
userId: apiTargetId,
|
|
564
524
|
accountId: account.accountId,
|
|
565
525
|
token: botToken
|
|
566
526
|
});
|
|
@@ -627,6 +587,7 @@ function shouldRecoverSlackThreadFromCurrentSession(params) {
|
|
|
627
587
|
async function resolveSlackOutboundSessionRoute(params) {
|
|
628
588
|
const parsed = parseSlackTarget(params.target, { defaultKind: "channel" });
|
|
629
589
|
if (!parsed) return null;
|
|
590
|
+
const apiTargetId = canonicalizeSlackApiTargetId(parsed.kind, parsed.id, params.target);
|
|
630
591
|
const isDm = parsed.kind === "user";
|
|
631
592
|
let peerKind = isDm ? "direct" : "channel";
|
|
632
593
|
let peerId = parsed.id;
|
|
@@ -635,7 +596,7 @@ async function resolveSlackOutboundSessionRoute(params) {
|
|
|
635
596
|
const conversation = await resolveSlackConversationInfo({
|
|
636
597
|
cfg: params.cfg,
|
|
637
598
|
accountId: params.accountId,
|
|
638
|
-
channelId:
|
|
599
|
+
channelId: apiTargetId
|
|
639
600
|
});
|
|
640
601
|
if (conversation.type !== "dm" || !conversation.user) return null;
|
|
641
602
|
peerKind = "direct";
|
|
@@ -645,7 +606,7 @@ async function resolveSlackOutboundSessionRoute(params) {
|
|
|
645
606
|
const channelType = await resolveSlackChannelType({
|
|
646
607
|
cfg: params.cfg,
|
|
647
608
|
accountId: params.accountId,
|
|
648
|
-
channelId:
|
|
609
|
+
channelId: apiTargetId
|
|
649
610
|
});
|
|
650
611
|
if (channelType === "group") peerKind = "group";
|
|
651
612
|
if (channelType === "dm") peerKind = "direct";
|
|
@@ -720,6 +681,7 @@ const slackChannelOutbound = {
|
|
|
720
681
|
messageSendingHooks: true
|
|
721
682
|
} },
|
|
722
683
|
shouldTreatDeliveredTextAsVisible: shouldTreatSlackDeliveredTextAsVisible,
|
|
684
|
+
preferFinalAssistantVisibleText: true,
|
|
723
685
|
shouldSuppressLocalPayloadPrompt: ({ cfg, accountId, payload }) => shouldSuppressLocalSlackExecApprovalPrompt({
|
|
724
686
|
cfg,
|
|
725
687
|
accountId,
|
|
@@ -797,7 +759,8 @@ const slackChannelOutbound = {
|
|
|
797
759
|
deps: withSlackSendOverride({
|
|
798
760
|
deps: ctx.deps,
|
|
799
761
|
send,
|
|
800
|
-
tokenOverride
|
|
762
|
+
tokenOverride,
|
|
763
|
+
onPlatformSendDispatch: ctx.onPlatformSendDispatch
|
|
801
764
|
})
|
|
802
765
|
});
|
|
803
766
|
}
|
|
@@ -826,6 +789,12 @@ const slackMessageAdapter = {
|
|
|
826
789
|
...slackMessageAdapterBase.durableFinal?.capabilities,
|
|
827
790
|
reconcileUnknownSend: true
|
|
828
791
|
},
|
|
792
|
+
admitDeferredDelivery: ({ cfg, accountId }) => {
|
|
793
|
+
return mergeSlackAccountConfig(cfg, normalizeOptionalString(accountId) ?? resolveDefaultSlackAccountId(cfg)).enterpriseOrgInstall === true ? {
|
|
794
|
+
status: "permanent_rejection",
|
|
795
|
+
reason: "unsupported_enterprise_slack_delivery"
|
|
796
|
+
} : { status: "allowed" };
|
|
797
|
+
},
|
|
829
798
|
reconcileUnknownSendKinds: { text: true },
|
|
830
799
|
reconcileUnknownSend: async (ctx) => await (await loadSlackSendRuntime()).reconcileSlackUnknownSend(ctx)
|
|
831
800
|
}
|
|
@@ -867,6 +836,10 @@ const slackPlugin = createChatChannelPlugin({
|
|
|
867
836
|
parentConversationId
|
|
868
837
|
})
|
|
869
838
|
},
|
|
839
|
+
conversationBindings: { isCurrentConversationBindingSupported: ({ accountId }) => {
|
|
840
|
+
const cfg = getOptionalSlackRuntime()?.config.current();
|
|
841
|
+
return cfg ? mergeSlackAccountConfig(cfg, accountId).enterpriseOrgInstall !== true : false;
|
|
842
|
+
} },
|
|
870
843
|
messaging: {
|
|
871
844
|
targetPrefixes: ["slack"],
|
|
872
845
|
normalizeTarget: normalizeSlackMessagingTarget,
|
|
@@ -874,11 +847,13 @@ const slackPlugin = createChatChannelPlugin({
|
|
|
874
847
|
const parent = parentConversationId?.trim();
|
|
875
848
|
const child = conversationId.trim();
|
|
876
849
|
return parent && parent !== child ? {
|
|
877
|
-
to: `channel:${parent}
|
|
850
|
+
to: normalizeSlackMessagingTarget(`channel:${parent}`),
|
|
878
851
|
threadId: child
|
|
879
852
|
} : { to: normalizeSlackMessagingTarget(`channel:${child}`) };
|
|
880
853
|
},
|
|
881
|
-
resolveSessionTarget: ({ id }) =>
|
|
854
|
+
resolveSessionTarget: ({ id }) => {
|
|
855
|
+
return normalizeSlackMessagingTarget(`channel:${id}`);
|
|
856
|
+
},
|
|
882
857
|
inferTargetChatType: ({ to }) => resolveSlackRouteTarget(to)?.chatType,
|
|
883
858
|
resolveOutboundSessionRoute: async (params) => await resolveSlackOutboundSessionRoute(params),
|
|
884
859
|
transformReplyPayload: ({ payload, cfg, accountId }) => isSlackInteractiveRepliesEnabled({
|
|
@@ -1077,6 +1052,7 @@ const slackPlugin = createChatChannelPlugin({
|
|
|
1077
1052
|
cfg,
|
|
1078
1053
|
accountId: resolveDefaultSlackAccountId(cfg)
|
|
1079
1054
|
});
|
|
1055
|
+
assertSlackDirectSendAllowed(account);
|
|
1080
1056
|
const { sendMessageSlack } = await loadSlackSendRuntime();
|
|
1081
1057
|
const token = resolveSlackOperationToken(account, "write");
|
|
1082
1058
|
await sendMessageSlack(`user:${id}`, message, {
|
|
@@ -1115,4 +1091,4 @@ const slackPlugin = createChatChannelPlugin({
|
|
|
1115
1091
|
outbound: slackChannelOutbound
|
|
1116
1092
|
});
|
|
1117
1093
|
//#endregion
|
|
1118
|
-
export {
|
|
1094
|
+
export { buildSlackThreadingToolContext as n, resolveSlackAutoThreadId as r, slackPlugin as t };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as SlackChannelConfigSchema } from "./config-schema-
|
|
1
|
+
import { t as SlackChannelConfigSchema } from "./config-schema-DYI01PV2.js";
|
|
2
2
|
export { SlackChannelConfigSchema };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as slackPlugin } from "./channel-
|
|
1
|
+
import { t as slackPlugin } from "./channel-B0_j6C6z.js";
|
|
2
2
|
export { slackPlugin };
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.js";
|
|
2
|
+
import { a as resolveSlackAccount, l as resolveSlackOperationToken } from "./accounts-BOJJiHSr.js";
|
|
3
|
+
import { s as normalizeAllowListLower } from "./group-policy-C-b2ZnSl.js";
|
|
4
|
+
import { i as createSlackWebClient } from "./client-D2F6m8CP.js";
|
|
5
|
+
import { normalizeLowercaseStringOrEmpty, normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
6
|
+
import { createHash } from "node:crypto";
|
|
7
|
+
import { pruneMapToMaxSize } from "openclaw/plugin-sdk/collection-runtime";
|
|
8
|
+
//#region extensions/slack/src/channel-type.ts
|
|
9
|
+
var channel_type_exports = /* @__PURE__ */ __exportAll({
|
|
10
|
+
__resetSlackChannelTypeCacheForTest: () => resetSlackChannelTypeCacheForTest,
|
|
11
|
+
resetSlackChannelTypeCacheForTest: () => resetSlackChannelTypeCacheForTest,
|
|
12
|
+
resolveSlackChannelType: () => resolveSlackChannelType,
|
|
13
|
+
resolveSlackConversationInfo: () => resolveSlackConversationInfo
|
|
14
|
+
});
|
|
15
|
+
const SLACK_CONVERSATION_INFO_CACHE_MAX_ENTRIES = 1024;
|
|
16
|
+
const SLACK_CONVERSATION_INFO_CACHE = /* @__PURE__ */ new Map();
|
|
17
|
+
function getCachedSlackConversationInfo(cacheKey) {
|
|
18
|
+
const cached = SLACK_CONVERSATION_INFO_CACHE.get(cacheKey);
|
|
19
|
+
if (cached) {
|
|
20
|
+
SLACK_CONVERSATION_INFO_CACHE.delete(cacheKey);
|
|
21
|
+
SLACK_CONVERSATION_INFO_CACHE.set(cacheKey, cached);
|
|
22
|
+
}
|
|
23
|
+
return cached;
|
|
24
|
+
}
|
|
25
|
+
function setCachedSlackConversationInfo(cacheKey, conversationInfo) {
|
|
26
|
+
SLACK_CONVERSATION_INFO_CACHE.delete(cacheKey);
|
|
27
|
+
SLACK_CONVERSATION_INFO_CACHE.set(cacheKey, conversationInfo);
|
|
28
|
+
pruneMapToMaxSize(SLACK_CONVERSATION_INFO_CACHE, SLACK_CONVERSATION_INFO_CACHE_MAX_ENTRIES);
|
|
29
|
+
}
|
|
30
|
+
function fingerprintSlackCredential(token) {
|
|
31
|
+
return createHash("sha256").update(token).digest("hex");
|
|
32
|
+
}
|
|
33
|
+
function resolveConfiguredSlackConversationInfo(params) {
|
|
34
|
+
if (/^D/i.test(params.channelId)) return { type: "dm" };
|
|
35
|
+
const channelIdLower = normalizeLowercaseStringOrEmpty(params.channelId);
|
|
36
|
+
const groupChannels = normalizeAllowListLower(params.account.dm?.groupChannels);
|
|
37
|
+
if (groupChannels.includes(channelIdLower) || groupChannels.includes(`slack:${channelIdLower}`) || groupChannels.includes(`channel:${channelIdLower}`) || groupChannels.includes(`group:${channelIdLower}`) || groupChannels.includes(`mpim:${channelIdLower}`)) return { type: "group" };
|
|
38
|
+
return { type: Object.keys(params.account.channels ?? {}).some((key) => {
|
|
39
|
+
const normalized = normalizeLowercaseStringOrEmpty(key);
|
|
40
|
+
return normalized === channelIdLower || normalized === `channel:${channelIdLower}` || normalized.replace(/^#/, "") === channelIdLower;
|
|
41
|
+
}) ? "channel" : "unknown" };
|
|
42
|
+
}
|
|
43
|
+
async function resolveSlackConversationInfo(params) {
|
|
44
|
+
const channelId = params.channelId.trim();
|
|
45
|
+
if (!channelId) return { type: "unknown" };
|
|
46
|
+
const account = resolveSlackAccount({
|
|
47
|
+
cfg: params.cfg,
|
|
48
|
+
accountId: params.accountId
|
|
49
|
+
});
|
|
50
|
+
const operation = params.operation ?? "read";
|
|
51
|
+
const token = resolveSlackOperationToken(account, operation);
|
|
52
|
+
const userToken = normalizeOptionalString(account.userToken);
|
|
53
|
+
const credentialRole = token ? token === userToken ? "user" : "bot" : "none";
|
|
54
|
+
const credentialFingerprint = token ? fingerprintSlackCredential(token) : "none";
|
|
55
|
+
const cacheKey = `${account.accountId}:${operation}:${credentialRole}:${credentialFingerprint}:${channelId}`;
|
|
56
|
+
if (!params.requireFreshName) {
|
|
57
|
+
const cached = getCachedSlackConversationInfo(cacheKey);
|
|
58
|
+
if (cached) return cached;
|
|
59
|
+
}
|
|
60
|
+
const isNativeImChannel = /^D/i.test(channelId);
|
|
61
|
+
const configuredInfo = resolveConfiguredSlackConversationInfo({
|
|
62
|
+
account,
|
|
63
|
+
channelId
|
|
64
|
+
});
|
|
65
|
+
if (token) try {
|
|
66
|
+
const client = createSlackWebClient(token);
|
|
67
|
+
if (isNativeImChannel && operation === "write") {
|
|
68
|
+
const opened = await client.conversations.open({
|
|
69
|
+
channel: channelId,
|
|
70
|
+
prevent_creation: true,
|
|
71
|
+
return_im: true
|
|
72
|
+
});
|
|
73
|
+
const user = typeof opened.channel?.user === "string" && opened.channel.user.trim() ? opened.channel.user.trim() : void 0;
|
|
74
|
+
const result = user ? {
|
|
75
|
+
type: "dm",
|
|
76
|
+
user
|
|
77
|
+
} : { type: "dm" };
|
|
78
|
+
if (user) setCachedSlackConversationInfo(cacheKey, result);
|
|
79
|
+
return result;
|
|
80
|
+
}
|
|
81
|
+
const channel = (await client.conversations.info({ channel: channelId })).channel;
|
|
82
|
+
const type = channel?.is_im ? "dm" : channel?.is_mpim ? "group" : "channel";
|
|
83
|
+
const name = normalizeOptionalString(channel?.name);
|
|
84
|
+
const user = normalizeOptionalString(channel?.user);
|
|
85
|
+
const result = {
|
|
86
|
+
type,
|
|
87
|
+
...name ? { name } : {},
|
|
88
|
+
...user ? { user } : {}
|
|
89
|
+
};
|
|
90
|
+
setCachedSlackConversationInfo(cacheKey, {
|
|
91
|
+
type,
|
|
92
|
+
...user ? { user } : {}
|
|
93
|
+
});
|
|
94
|
+
return result;
|
|
95
|
+
} catch {
|
|
96
|
+
return { type: isNativeImChannel ? "dm" : "unknown" };
|
|
97
|
+
}
|
|
98
|
+
const result = configuredInfo;
|
|
99
|
+
if (!isNativeImChannel) setCachedSlackConversationInfo(cacheKey, result);
|
|
100
|
+
return result;
|
|
101
|
+
}
|
|
102
|
+
async function resolveSlackChannelType(params) {
|
|
103
|
+
return (await resolveSlackConversationInfo(params)).type;
|
|
104
|
+
}
|
|
105
|
+
function resetSlackChannelTypeCacheForTest() {
|
|
106
|
+
SLACK_CONVERSATION_INFO_CACHE.clear();
|
|
107
|
+
}
|
|
108
|
+
//#endregion
|
|
109
|
+
export { resolveSlackConversationInfo as i, resetSlackChannelTypeCacheForTest as n, resolveSlackChannelType as r, channel_type_exports as t };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { a as resolveSlackAccount, c as resolveSlackConfigAccessorAccount, i as resolveDefaultSlackAccountId, n as listSlackAccountIds } from "./accounts-BOJJiHSr.js";
|
|
2
2
|
import { a as describeSlackSetupAccount, i as SLACK_CHANNEL, n as createSlackSetupWizardProxy, o as isSlackSetupAccountConfigured, r as slackSetupAdapter } from "./setup-core-fGd6Gquy.js";
|
|
3
|
-
import { t as SlackChannelConfigSchema } from "./config-schema-
|
|
3
|
+
import { t as SlackChannelConfigSchema } from "./config-schema-DYI01PV2.js";
|
|
4
4
|
import { adaptScopedAccountAccessor, createScopedChannelConfigAdapter } from "openclaw/plugin-sdk/channel-config-helpers";
|
|
5
5
|
import { formatAllowFromLowercase } from "openclaw/plugin-sdk/allow-from";
|
|
6
6
|
//#region extensions/slack/src/channel.setup.ts
|
|
7
|
-
const slackSetupWizard = createSlackSetupWizardProxy(async () => ({ slackSetupWizard: (await import("./setup-surface-
|
|
7
|
+
const slackSetupWizard = createSlackSetupWizardProxy(async () => ({ slackSetupWizard: (await import("./setup-surface-BN2WeG5c.js")).slackSetupWizard }));
|
|
8
8
|
const slackSetupConfigAdapter = createScopedChannelConfigAdapter({
|
|
9
9
|
sectionKey: SLACK_CHANNEL,
|
|
10
10
|
listAccountIds: listSlackAccountIds,
|