@openclaw/slack 2026.12.1 → 2026.12.6-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/.setup/{action-runtime-zVonj7Ub.mjs → action-runtime-B2JYA0KK.mjs} +30 -39
- package/dist/.setup/action-runtime.runtime-DhTK_A6l.mjs +1 -0
- package/dist/.setup/{actions-0x2TsQH6.mjs → actions-cVgdS6sU.mjs} +147 -22
- package/dist/.setup/{approval-handler.runtime-BBYoz7El.mjs → approval-handler.runtime-DDn3L7Gd.mjs} +5 -5
- package/dist/.setup/{approval-message-updates-BrGg-eis.mjs → approval-message-updates-CnjKG4If.mjs} +1 -1
- package/dist/.setup/{channel-C6-Cp-Fz.mjs → channel-BWLl8hAf.mjs} +24 -28
- package/dist/.setup/{channel-type-BQCZqcgg.mjs → channel-type-CNYPuhN7.mjs} +1 -1
- package/dist/.setup/{channel.setup-Dzt1s8XR.mjs → channel.setup-C0NEy9hG.mjs} +1 -1
- package/dist/.setup/{directory-config-CWeEzb_Y.mjs → directory-config-CFrpmf6d.mjs} +2 -2
- package/dist/.setup/{fork-CiiHD26T.mjs → fork-CyGNd27b.mjs} +3 -3
- package/dist/.setup/{literal-text-DXy7nGRR.mjs → literal-text-D5exd3B9.mjs} +1 -1
- package/dist/.setup/{monitor-D5erEc0i.mjs → monitor-dVQQ8XII.mjs} +264 -150
- package/dist/.setup/{outbound-adapter-BmJCT3Qj.mjs → outbound-adapter-CIJgw3fk.mjs} +6 -6
- package/dist/.setup/{pipeline.runtime-C51V3mhq.mjs → pipeline.runtime-Bet_aK1D.mjs} +53 -37
- package/dist/.setup/{policy-l2IjJV43.mjs → policy-Bo-JJQ2c.mjs} +1 -1
- package/dist/.setup/{probe-DKu67cjh.mjs → probe-DhQ6LeKX.mjs} +70 -12
- package/dist/.setup/{question-delivery-BRQza6lN.mjs → question-delivery-D-WigwxO.mjs} +1 -1
- package/dist/.setup/{relay-source-D2WA09C-.mjs → relay-source-BWKpwdJT.mjs} +2 -2
- package/dist/.setup/{replies-kwdtXt3e.mjs → replies-BFqakO6L.mjs} +6 -6
- package/dist/.setup/{reply-blocks-Cf8e9Sau.mjs → reply-blocks-BsJPukUN.mjs} +28 -6
- package/dist/.setup/{resolve-channels-BoQiIEny.mjs → resolve-channels-Cl7l3BLf.mjs} +1 -1
- package/dist/.setup/{resolve-users-PpJHZiBC.mjs → resolve-users-mep8kUHy.mjs} +1 -1
- package/dist/.setup/{scopes-bvZxH5i3.mjs → scopes-CnMdp9Pj.mjs} +1 -1
- package/dist/.setup/{send-DJpeS70B.mjs → send-kbYZlK6B.mjs} +133 -145
- package/dist/.setup/send-results-DVKN1Zix.mjs +77 -0
- package/dist/.setup/setup-plugin-api-TYFn_irv.mjs +2 -0
- package/dist/.setup/{setup-surface-BqdskNYS.mjs → setup-surface-D8hoExQs.mjs} +3 -3
- package/dist/.setup/slash-dispatch.runtime--T5PbqoB.mjs +7 -0
- package/dist/.setup/{target-parsing-DwYAP3ts.mjs → target-parsing-DaLcdOoQ.mjs} +10 -1
- package/dist/.setup/{targets-eeOxA_b_.mjs → targets-DaKqo4kn.mjs} +1 -1
- package/dist/.source-module-urls/c5ffd0957b234c7c12090e7de4eca2482ef339b8561e078da55b734211b0ba58.json +1 -1
- package/dist/api.js +10 -10
- package/dist/channel-plugin-api.js +1 -1
- package/dist/directory-contract-api.js +1 -1
- package/dist/runtime-api.js +7 -7
- package/dist/setup-entry.js +1 -1
- package/dist/setup-plugin-api.js +1 -1
- package/package.json +4 -4
- package/dist/.setup/action-runtime.runtime-YBV3dNF-.mjs +0 -1
- package/dist/.setup/send-results-Bm6V1ekL.mjs +0 -21
- package/dist/.setup/setup-plugin-api-DPOqeRW0.mjs +0 -2
- package/dist/.setup/slash-dispatch.runtime-CMQgSmJc.mjs +0 -8
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { i as __exportAll } from "./doctor-contract-CcNdculn.mjs";
|
|
2
2
|
import { a as mergeSlackAccountConfig, c as resolveSlackAccountAllowFrom, g as resolveSlackBotToken, h as resolveSlackAppToken, l as resolveSlackAccountDmPolicy, m as formatSlackBotTokenIdentityWarning, o as resolveDefaultSlackAccountId, p as resolveSlackReplyToMode, s as resolveSlackAccount } from "./accounts-Dsl3wabY.mjs";
|
|
3
|
-
import { a as parseSlackTarget, n as formatSlackTarget } from "./target-parsing-
|
|
4
|
-
import {
|
|
3
|
+
import { a as parseSlackTarget, n as formatSlackTarget } from "./target-parsing-DaLcdOoQ.mjs";
|
|
4
|
+
import { C as normalizeSlackRouteBindingConfig, Ct as SLACK_TEXT_LIMIT, Dt as escapeSlackMrkdwn, G as resolveSlackQuestionAction, Gt as normalizeSlackSlug, Kt as resolveSlackAllowListMatch, Ot as isSlackAnyNativeApprovalClientEnabled, Qt as registerSlackInstallationState, R as isSlackApprovalActionId, S as resolveSlackAgentRoute, T as resolveSlackConversationBindingRouteAsync, U as decodeSlackQuestionAction, Ut as allowListMatches, V as isSlackQuestionActionId, Vt as isSlackPluginApprovalAuthorizedSender, Wt as normalizeSlackAllowOwnerEntry, b as qualifySlackConversationId, c as slackIngressIdentity, en as isSlackExecApprovalAuthorizedSender, g as setSlackChannelPolicyBindings, i as setSlackSessionStatus, k as truncateSlackText, l as buildSlackChannelIdCandidates, m as mergeSlackBoundChannelEntries, nt as buildSlackCompleteBlocksFallbackText, o as createSlackIngressSubject, q as decodeSlackApprovalAction, qt as resolveSlackUserAllowListForTeam, r as renameSlackSession, v as formatSlackError, x as qualifySlackRoutePeerId, z as isSlackCallbackActionId } from "./probe-DhQ6LeKX.mjs";
|
|
5
5
|
import { n as collectSlackCursorPages } from "./cursor-pages-DiOrzZtc.mjs";
|
|
6
6
|
import { _ as resolveSlackMonitorDispatchers, a as createSlackWebClient, d as readLruMapEntry, f as writeLruMapEntry, g as resolveSlackLookupClientOptions, l as getOrCreateWeakOwnerMap, r as createSlackStartupAuthClient, s as getSlackListenerWriteClient, u as pruneExpiredMapEntries, v as resolveSlackWebClientOptions } from "./client-DQqLIemQ.mjs";
|
|
7
7
|
import { t as DEFAULT_SLACK_SUGGESTED_PROMPTS } from "./channel-meta-C5vsCo3a.mjs";
|
|
8
|
-
import {
|
|
9
|
-
import { f as
|
|
8
|
+
import { _ as requireSlackPostMessageTimestamp, r as setSlackDefaultSendIdentity, y as buildSlackMessageIdentityPayload } from "./send-kbYZlK6B.mjs";
|
|
9
|
+
import { D as isSlackUnfurlAttachment, E as hasSlackTableBlock, O as resolveSlackBlocksText, S as saveRemoteMedia, T as hasSlackMessageTableBlock, _ as readCachedSlackUserProfile, f as readSlackMessages, k as resolveSlackMessageText$1, v as resetSlackUserProfileCache, w as formatSlackFileReferenceList, x as isGovSlackClient, y as resolveSlackUserProfile } from "./actions-cVgdS6sU.mjs";
|
|
10
10
|
import { n as getSlackRuntime, t as getOptionalSlackRuntime } from "./runtime-C6HKn7Av.mjs";
|
|
11
11
|
import { t as normalizeSlackWebhookPath } from "./paths-CQZI_5WY.mjs";
|
|
12
|
-
import { n as resolveSlackChannelConfig, r as resolveSlackChannelLabel, t as isSlackChannelAllowedByPolicy } from "./policy-
|
|
13
|
-
import { t as resolveSlackChannelAllowlist } from "./resolve-channels-
|
|
14
|
-
import { t as resolveSlackUserAllowlist } from "./resolve-users-
|
|
15
|
-
import { n as runSlackApprovalMessageUpdate, t as hasSlackApprovalControl } from "./approval-message-updates-
|
|
12
|
+
import { n as resolveSlackChannelConfig, r as resolveSlackChannelLabel, t as isSlackChannelAllowedByPolicy } from "./policy-Bo-JJQ2c.mjs";
|
|
13
|
+
import { t as resolveSlackChannelAllowlist } from "./resolve-channels-Cl7l3BLf.mjs";
|
|
14
|
+
import { t as resolveSlackUserAllowlist } from "./resolve-users-mep8kUHy.mjs";
|
|
15
|
+
import { n as runSlackApprovalMessageUpdate, t as hasSlackApprovalControl } from "./approval-message-updates-CnjKG4If.mjs";
|
|
16
16
|
import { normalizeAccountId } from "openclaw/plugin-sdk/account-resolution";
|
|
17
17
|
import { normalizeResolvedSecretInputString } from "openclaw/plugin-sdk/secret-input";
|
|
18
18
|
import { asNonArrayRecord, asOptionalObjectRecord, asOptionalRecord, isRecord, normalizeLowercaseStringOrEmpty, normalizeOptionalLowercaseString, normalizeOptionalString, normalizeStringEntries, normalizeUniqueTrimmedStringList, readNonBlankString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
@@ -35,9 +35,9 @@ import { classifyTransientNetworkErrorCode } from "openclaw/plugin-sdk/retry-run
|
|
|
35
35
|
import { resolveRuntimeConversationBindingRouteAsync } from "openclaw/plugin-sdk/conversation-binding-runtime";
|
|
36
36
|
import { readChannelIngressStoreAllowFromForDmPolicy } from "openclaw/plugin-sdk/channel-ingress-runtime";
|
|
37
37
|
import { collectErrorGraphCandidates, extractErrorCode, formatErrorMessage, isApprovalNotFoundError, readErrorName, toErrorObject } from "openclaw/plugin-sdk/error-runtime";
|
|
38
|
+
import { createDeferred } from "openclaw/plugin-sdk/extension-shared";
|
|
38
39
|
import { resolveTextChunkLimit } from "openclaw/plugin-sdk/reply-chunking";
|
|
39
40
|
import { buildChannelMetadata } from "openclaw/plugin-sdk/security-runtime";
|
|
40
|
-
import { createDeferred } from "openclaw/plugin-sdk/extension-shared";
|
|
41
41
|
import { createDedupeCache } from "openclaw/plugin-sdk/dedupe-runtime";
|
|
42
42
|
import { buildPluginBindingResolvedText, parsePluginBindingApprovalCustomId, resolvePluginConversationBindingApproval, upsertChannelPairingRequest } from "openclaw/plugin-sdk/conversation-runtime";
|
|
43
43
|
import { resolveNativeCommandsEnabled, resolveNativeSkillsEnabled } from "openclaw/plugin-sdk/native-command-config-runtime";
|
|
@@ -943,27 +943,20 @@ async function resolveWorkspacePolicy(ctx, resolveToken) {
|
|
|
943
943
|
token: resolveToken,
|
|
944
944
|
entries
|
|
945
945
|
});
|
|
946
|
-
const nextChannels = { ...channelsConfig };
|
|
947
946
|
const mapping = [];
|
|
948
947
|
const unresolved = [];
|
|
949
948
|
for (const entry of resolved) {
|
|
950
|
-
|
|
951
|
-
if (!source) continue;
|
|
949
|
+
if (!channelsConfig?.[entry.input]) continue;
|
|
952
950
|
if (!entry.resolved || !entry.id) {
|
|
953
951
|
unresolved.push(entry.input);
|
|
954
952
|
continue;
|
|
955
953
|
}
|
|
956
954
|
const resolvedLabel = formatSlackChannelResolved(entry);
|
|
957
955
|
if (resolvedLabel) mapping.push(resolvedLabel);
|
|
958
|
-
const existing = nextChannels[entry.id] ?? {};
|
|
959
|
-
nextChannels[entry.id] = {
|
|
960
|
-
...source,
|
|
961
|
-
...existing
|
|
962
|
-
};
|
|
963
956
|
channelBindings.set(entry.input, entry.id);
|
|
964
957
|
}
|
|
965
|
-
channelsConfig =
|
|
966
|
-
ctx.channelsConfig =
|
|
958
|
+
channelsConfig = mergeSlackBoundChannelEntries(channelsConfig, channelBindings);
|
|
959
|
+
ctx.channelsConfig = channelsConfig;
|
|
967
960
|
summarizeMapping("slack channels", mapping, unresolved, runtime);
|
|
968
961
|
}
|
|
969
962
|
} catch (err) {
|
|
@@ -1062,7 +1055,6 @@ function classifySlackChannelLookupFailure(error) {
|
|
|
1062
1055
|
return "other";
|
|
1063
1056
|
}
|
|
1064
1057
|
const SLACK_CHANNEL_CACHE_MAX_ENTRIES = 1024;
|
|
1065
|
-
const SLACK_USER_CACHE_MAX_ENTRIES = 2048;
|
|
1066
1058
|
const SLACK_AVATAR_CACHE_MAX_ENTRIES = 128;
|
|
1067
1059
|
const SLACK_AVATAR_MAX_BYTES = 262144;
|
|
1068
1060
|
const SLACK_AVATAR_SSRF_POLICY = {
|
|
@@ -1078,7 +1070,7 @@ function createSlackMonitorContextFields(params) {
|
|
|
1078
1070
|
};
|
|
1079
1071
|
const logger = getChildLogger({ module: "slack-auto-reply" });
|
|
1080
1072
|
const channelCache = /* @__PURE__ */ new Map();
|
|
1081
|
-
|
|
1073
|
+
resetSlackUserProfileCache(params.accountId);
|
|
1082
1074
|
const avatarCache = /* @__PURE__ */ new Map();
|
|
1083
1075
|
const pendingAvatars = /* @__PURE__ */ new Set();
|
|
1084
1076
|
const channelDenialWarnings = createDedupeCache({
|
|
@@ -1258,21 +1250,18 @@ function createSlackMonitorContextFields(params) {
|
|
|
1258
1250
|
}
|
|
1259
1251
|
};
|
|
1260
1252
|
const resolveUserName = async (userId, eventScope) => {
|
|
1261
|
-
const cacheKey = scopedKey(userId, eventScope);
|
|
1262
|
-
const cached = readLruMapEntry(userCache, cacheKey);
|
|
1263
|
-
if (cached) return cached;
|
|
1264
1253
|
try {
|
|
1265
|
-
const
|
|
1266
|
-
|
|
1267
|
-
|
|
1254
|
+
const profile = await resolveSlackUserProfile({
|
|
1255
|
+
accountId: params.accountId,
|
|
1256
|
+
teamId: eventScope?.teamId,
|
|
1257
|
+
userId,
|
|
1258
|
+
client: eventScope?.client ?? params.app.client,
|
|
1259
|
+
token: params.botToken
|
|
1268
1260
|
});
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
imageUrl: normalizeOptionalString(profile?.image_192) ?? normalizeOptionalString(profile?.image_512) ?? normalizeOptionalString(profile?.image_72)
|
|
1261
|
+
return {
|
|
1262
|
+
name: profile.displayName || profile.realName || profile.handle,
|
|
1263
|
+
imageUrl: profile.imageUrl
|
|
1273
1264
|
};
|
|
1274
|
-
writeLruMapEntry(userCache, cacheKey, entry, SLACK_USER_CACHE_MAX_ENTRIES);
|
|
1275
|
-
return entry;
|
|
1276
1265
|
} catch (error) {
|
|
1277
1266
|
return { error };
|
|
1278
1267
|
}
|
|
@@ -1280,7 +1269,11 @@ function createSlackMonitorContextFields(params) {
|
|
|
1280
1269
|
const resolveUserAvatar = (userId, eventScope) => {
|
|
1281
1270
|
const client = eventScope?.client ?? params.app.client;
|
|
1282
1271
|
if (isGovSlackClient(client)) return;
|
|
1283
|
-
const imageUrl =
|
|
1272
|
+
const imageUrl = readCachedSlackUserProfile({
|
|
1273
|
+
accountId: params.accountId,
|
|
1274
|
+
teamId: eventScope?.teamId,
|
|
1275
|
+
token: params.botToken
|
|
1276
|
+
}, userId)?.imageUrl;
|
|
1284
1277
|
if (!imageUrl) return;
|
|
1285
1278
|
const cacheKey = scopedKey(`${userId}\0${imageUrl}`, eventScope);
|
|
1286
1279
|
const cached = readLruMapEntry(avatarCache, cacheKey);
|
|
@@ -2678,6 +2671,60 @@ async function dispatchSlackPluginInteractiveHandler(params) {
|
|
|
2678
2671
|
}
|
|
2679
2672
|
});
|
|
2680
2673
|
}
|
|
2674
|
+
// extensions/slack/src/monitor/events/interactions.agent-button.ts
|
|
2675
|
+
/**
|
|
2676
|
+
* Delivers an agent-authored button tap that no plugin handled as the tapper's reply in
|
|
2677
|
+
* that conversation. Slack's message owner admits it as their typed text would be,
|
|
2678
|
+
* addressed to the bot. `onAdmitted` runs once the owner has admitted the tap, before
|
|
2679
|
+
* the turn starts.
|
|
2680
|
+
*
|
|
2681
|
+
* Resolves true when the message owner refused the tap without telling the tapper, and
|
|
2682
|
+
* undefined when the tap could not be delivered.
|
|
2683
|
+
*/
|
|
2684
|
+
async function deliverSlackAgentButtonTap(params) {
|
|
2685
|
+
const { ctx, eventScope, parsed } = params.action;
|
|
2686
|
+
if (!parsed.channelId) return;
|
|
2687
|
+
const repliesThread = ((params.auth.channelType === "channel" || params.auth.channelType === "group" ? resolveSlackChannelConfig({
|
|
2688
|
+
teamId: eventScope?.teamId ?? ctx.teamId,
|
|
2689
|
+
allowUnscoped: ctx.installationIdentity?.kind !== "enterprise",
|
|
2690
|
+
channelId: parsed.channelId,
|
|
2691
|
+
channelName: params.auth.channelName,
|
|
2692
|
+
channels: ctx.channelsConfig,
|
|
2693
|
+
channelKeys: ctx.channelsConfigKeys,
|
|
2694
|
+
defaultRequireMention: ctx.defaultRequireMention,
|
|
2695
|
+
allowNameMatching: ctx.allowNameMatching
|
|
2696
|
+
})?.replyToMode : void 0) ?? resolveSlackReplyToMode(resolveSlackAccount({
|
|
2697
|
+
cfg: ctx.cfg,
|
|
2698
|
+
accountId: ctx.accountId
|
|
2699
|
+
}), resolveSlackChatType(params.auth.channelType ?? "channel"))) !== "off" || params.auth.channelType === "im" && !eventScope && await ctx.isSlackAgentView();
|
|
2700
|
+
const threadTs = parsed.threadTs ?? (repliesThread ? parsed.messageTs : void 0);
|
|
2701
|
+
try {
|
|
2702
|
+
return await params.handleSlackMessage({
|
|
2703
|
+
type: "message",
|
|
2704
|
+
channel: parsed.channelId,
|
|
2705
|
+
user: parsed.userId,
|
|
2706
|
+
text: params.text,
|
|
2707
|
+
ts: normalizeOptionalString(parsed.typedActionWithText.action_ts),
|
|
2708
|
+
...threadTs ? { thread_ts: threadTs } : {}
|
|
2709
|
+
}, {
|
|
2710
|
+
source: "block_action",
|
|
2711
|
+
wasMentioned: true,
|
|
2712
|
+
senderAuthentication: params.senderAuthentication,
|
|
2713
|
+
eventScope,
|
|
2714
|
+
awaitDispatch: true,
|
|
2715
|
+
turnAdoptionLifecycle: {
|
|
2716
|
+
admission: "exclusive",
|
|
2717
|
+
onAdopted: () => {},
|
|
2718
|
+
onDeferred: () => {},
|
|
2719
|
+
onAbandoned: () => {},
|
|
2720
|
+
onSessionRouted: params.onAdmitted
|
|
2721
|
+
}
|
|
2722
|
+
});
|
|
2723
|
+
} catch (error) {
|
|
2724
|
+
ctx.runtime.error?.(`slack:interaction agent button failed: ${formatErrorMessage(error)}`);
|
|
2725
|
+
return;
|
|
2726
|
+
}
|
|
2727
|
+
}
|
|
2681
2728
|
// extensions/slack/src/monitor/events/interactions.approval-sender.ts
|
|
2682
2729
|
function resolveSlackPluginApprovalSender(params) {
|
|
2683
2730
|
const senderId = formatSlackTarget({
|
|
@@ -2884,10 +2931,8 @@ async function authorizeSlackBlockAction(params) {
|
|
|
2884
2931
|
expectedSenderId: params.parsed.userId,
|
|
2885
2932
|
interactiveEvent: true
|
|
2886
2933
|
});
|
|
2887
|
-
if (auth.allowed)
|
|
2888
|
-
|
|
2889
|
-
await respondEphemeral(params.respond, "You are not authorized to use this control.");
|
|
2890
|
-
return { allowed: false };
|
|
2934
|
+
if (!auth.allowed) params.ctx.runtime.log?.(`slack:interaction drop action=${params.parsed.actionId} user=${params.parsed.userId} channel=${params.parsed.channelId ?? "unknown"} reason=${auth.reason ?? "unauthorized"}`);
|
|
2935
|
+
return auth;
|
|
2891
2936
|
}
|
|
2892
2937
|
async function handleSlackPluginBindingApproval(params) {
|
|
2893
2938
|
const pluginBindingApproval = parsePluginBindingApprovalCustomId(params.pluginInteractionData);
|
|
@@ -2942,7 +2987,7 @@ async function handleSlackApprovalInteraction(params) {
|
|
|
2942
2987
|
channelId,
|
|
2943
2988
|
messageTs
|
|
2944
2989
|
}, async () => {
|
|
2945
|
-
const { readSlackMessages } = await import("./actions-
|
|
2990
|
+
const { readSlackMessages } = await import("./actions-cVgdS6sU.mjs").then((n) => n.t);
|
|
2946
2991
|
const { messages } = await readSlackMessages(channelId, {
|
|
2947
2992
|
client: params.eventScope?.client ?? params.ctx.app.client,
|
|
2948
2993
|
messageId: messageTs,
|
|
@@ -2971,7 +3016,7 @@ async function handleSlackApprovalInteraction(params) {
|
|
|
2971
3016
|
} catch (error) {
|
|
2972
3017
|
params.ctx.runtime.log?.(`slack:interaction approval resolve failed id=${params.approval.approvalId}: ${String(error)}`);
|
|
2973
3018
|
if (isApprovalNotFoundError(error)) {
|
|
2974
|
-
await respondEphemeral(params.respond, "
|
|
3019
|
+
await respondEphemeral(params.respond, "OpenClaw couldn't apply this decision. Open the Control UI to see pending approvals.");
|
|
2975
3020
|
return true;
|
|
2976
3021
|
}
|
|
2977
3022
|
await respondEphemeral(params.respond, "Could not reach the Gateway to resolve this approval. Try again.");
|
|
@@ -3141,7 +3186,10 @@ function registerSlackBlockActionHandler(params) {
|
|
|
3141
3186
|
await respondEphemeral(respond, "This question action is invalid or expired.");
|
|
3142
3187
|
return;
|
|
3143
3188
|
}
|
|
3144
|
-
if (!(await authorizeSlackBlockAction(actionContext)).allowed)
|
|
3189
|
+
if (!(await authorizeSlackBlockAction(actionContext)).allowed) {
|
|
3190
|
+
await respondEphemeral(respond, "You are not authorized to use this control.");
|
|
3191
|
+
return;
|
|
3192
|
+
}
|
|
3145
3193
|
await resolveSlackQuestionAction({
|
|
3146
3194
|
action: question,
|
|
3147
3195
|
cfg: runtimeContext.cfg,
|
|
@@ -3161,8 +3209,30 @@ function registerSlackBlockActionHandler(params) {
|
|
|
3161
3209
|
pluginInteractionData
|
|
3162
3210
|
})) return;
|
|
3163
3211
|
}
|
|
3212
|
+
const agentText = agentControlText(pluginInteractionData);
|
|
3213
|
+
const runAgentTap = async (auth, text) => {
|
|
3214
|
+
const refusedSilently = await deliverSlackAgentButtonTap({
|
|
3215
|
+
action: actionContext,
|
|
3216
|
+
auth,
|
|
3217
|
+
text,
|
|
3218
|
+
senderAuthentication: resolveSlackSenderAuthentication(args.context),
|
|
3219
|
+
handleSlackMessage: params.handleSlackMessage,
|
|
3220
|
+
onAdmitted: async () => {
|
|
3221
|
+
if (runtimeContext.isRuntimePolicyCurrent()) await updateSlackLegacyBlockAction(actionContext);
|
|
3222
|
+
}
|
|
3223
|
+
});
|
|
3224
|
+
if (refusedSilently === void 0) await respondEphemeral(respond, "This button didn't reach the agent. Try again.");
|
|
3225
|
+
else if (refusedSilently) await respondEphemeral(respond, "You are not authorized to use this control.");
|
|
3226
|
+
};
|
|
3164
3227
|
const auth = await authorizeSlackBlockAction(actionContext);
|
|
3165
|
-
if (!auth.allowed)
|
|
3228
|
+
if (!auth.allowed) {
|
|
3229
|
+
if (agentText !== void 0) {
|
|
3230
|
+
await runAgentTap(auth, agentText);
|
|
3231
|
+
return;
|
|
3232
|
+
}
|
|
3233
|
+
await respondEphemeral(respond, "You are not authorized to use this control.");
|
|
3234
|
+
return;
|
|
3235
|
+
}
|
|
3166
3236
|
const route = await captureSlackInteractionEventRoute(await runtimeContext.resolveSlackSystemEventRoute({
|
|
3167
3237
|
channelId: parsed.channelId,
|
|
3168
3238
|
channelType: auth.channelType,
|
|
@@ -3234,6 +3304,10 @@ function registerSlackBlockActionHandler(params) {
|
|
|
3234
3304
|
});
|
|
3235
3305
|
if (pluginResult.matched && pluginResult.handled) return;
|
|
3236
3306
|
}
|
|
3307
|
+
if (agentText !== void 0) {
|
|
3308
|
+
await runAgentTap(auth, agentText);
|
|
3309
|
+
return;
|
|
3310
|
+
}
|
|
3237
3311
|
if (!route || !runtimeContext.isRuntimePolicyCurrent()) return;
|
|
3238
3312
|
const teamId = args.context.teamId;
|
|
3239
3313
|
const targetKind = auth.channelType === "im" ? "user" : "channel";
|
|
@@ -3257,16 +3331,15 @@ function registerSlackBlockActionHandler(params) {
|
|
|
3257
3331
|
threadTs: parsed.threadTs
|
|
3258
3332
|
};
|
|
3259
3333
|
runtimeContext.runtime.log?.(`slack:interaction action=${parsed.actionId} type=${parsed.actionSummary.actionType ?? "unknown"} user=${parsed.userId} channel=${parsed.channelId}`);
|
|
3260
|
-
|
|
3261
|
-
|
|
3262
|
-
|
|
3263
|
-
|
|
3264
|
-
|
|
3265
|
-
|
|
3266
|
-
|
|
3267
|
-
|
|
3268
|
-
|
|
3269
|
-
contextKey: contextParts.join(":"),
|
|
3334
|
+
if (await enqueueSlackInteractionEvent(eventPayload, route, {
|
|
3335
|
+
contextKey: [
|
|
3336
|
+
"slack:interaction",
|
|
3337
|
+
teamId,
|
|
3338
|
+
parsed.channelId,
|
|
3339
|
+
parsed.messageTs,
|
|
3340
|
+
parsed.actionId,
|
|
3341
|
+
normalizeOptionalString(parsed.typedActionWithText.action_ts) ?? parsed.typedBody.trigger_id
|
|
3342
|
+
].filter(Boolean).join(":"),
|
|
3270
3343
|
deliveryContext: {
|
|
3271
3344
|
channel: "slack",
|
|
3272
3345
|
to: deferredTarget?.target,
|
|
@@ -3723,25 +3796,32 @@ function isLaterSlackMessage(candidate, current) {
|
|
|
3723
3796
|
}
|
|
3724
3797
|
/** Keeps a live preview attached to its actual place in the Slack conversation. */
|
|
3725
3798
|
function trackSlackDraftMessage(conversation) {
|
|
3726
|
-
const
|
|
3799
|
+
const keys = [conversationKey(conversation)];
|
|
3800
|
+
if (conversation.deliveryThreadTs && conversation.deliveryThreadTs !== conversation.threadTs) keys.push(conversationKey({
|
|
3801
|
+
...conversation,
|
|
3802
|
+
threadTs: conversation.deliveryThreadTs
|
|
3803
|
+
}));
|
|
3727
3804
|
const activeDraft = {
|
|
3728
3805
|
messageTs: conversation.messageTs,
|
|
3729
3806
|
onInterveningMessage: conversation.onInterveningMessage
|
|
3730
3807
|
};
|
|
3731
|
-
const
|
|
3732
|
-
|
|
3733
|
-
|
|
3734
|
-
|
|
3735
|
-
|
|
3736
|
-
currentDrafts?.delete(activeDraft);
|
|
3737
|
-
if (currentDrafts?.size === 0) activeDraftsByConversation.delete(key);
|
|
3738
|
-
};
|
|
3808
|
+
for (const key of keys) {
|
|
3809
|
+
const drafts = activeDraftsByConversation.get(key) ?? /* @__PURE__ */ new Set();
|
|
3810
|
+
drafts.add(activeDraft);
|
|
3811
|
+
activeDraftsByConversation.set(key, drafts);
|
|
3812
|
+
}
|
|
3739
3813
|
return {
|
|
3740
3814
|
setMessageTs: (messageTs) => {
|
|
3741
3815
|
activeDraft.messageTs = messageTs;
|
|
3742
3816
|
if (activeDraft.latestHumanMessageTs && isLaterSlackMessage(activeDraft.latestHumanMessageTs, messageTs)) activeDraft.onInterveningMessage();
|
|
3743
3817
|
},
|
|
3744
|
-
stop
|
|
3818
|
+
stop() {
|
|
3819
|
+
for (const key of keys) {
|
|
3820
|
+
const drafts = activeDraftsByConversation.get(key);
|
|
3821
|
+
drafts?.delete(activeDraft);
|
|
3822
|
+
if (drafts?.size === 0) activeDraftsByConversation.delete(key);
|
|
3823
|
+
}
|
|
3824
|
+
}
|
|
3745
3825
|
};
|
|
3746
3826
|
}
|
|
3747
3827
|
/** A later human message means subsequent assistant output belongs below it. */
|
|
@@ -4161,13 +4241,21 @@ function registerSlackMessageEvents(params) {
|
|
|
4161
4241
|
});
|
|
4162
4242
|
}
|
|
4163
4243
|
// extensions/slack/src/monitor/session-run-targets.ts
|
|
4164
|
-
async function captureSlackSessionTargetGuard(ctx,
|
|
4165
|
-
|
|
4244
|
+
async function captureSlackSessionTargetGuard(ctx, target) {
|
|
4245
|
+
const { route } = target;
|
|
4246
|
+
let stopped = false;
|
|
4247
|
+
const guard = await captureSessionEntryCurrentCheckAsync({
|
|
4166
4248
|
agentId: route.agentId,
|
|
4167
4249
|
sessionKey: route.sessionKey,
|
|
4168
4250
|
storePath: resolveStorePath(ctx.cfg.session?.store, { agentId: route.agentId }),
|
|
4169
|
-
isActive
|
|
4251
|
+
isActive: () => target.isActive() || stopped && target.isUnreplaced()
|
|
4170
4252
|
});
|
|
4253
|
+
return {
|
|
4254
|
+
...guard,
|
|
4255
|
+
isCurrent: Object.assign(guard.isCurrent, { onTargetStopped: () => {
|
|
4256
|
+
stopped = true;
|
|
4257
|
+
} })
|
|
4258
|
+
};
|
|
4171
4259
|
}
|
|
4172
4260
|
const runs = /* @__PURE__ */ new WeakMap();
|
|
4173
4261
|
function addressKey(address) {
|
|
@@ -4178,7 +4266,7 @@ function addressKey(address) {
|
|
|
4178
4266
|
]);
|
|
4179
4267
|
}
|
|
4180
4268
|
/** Registers the exact publisher before status/output; the dispatch owner must release it. */
|
|
4181
|
-
function registerSlackSessionRun(ctx, address, route) {
|
|
4269
|
+
function registerSlackSessionRun(ctx, address, route, explicitlyAddressed = false) {
|
|
4182
4270
|
if (!address.threadTs) return () => {};
|
|
4183
4271
|
const byAddress = runs.get(ctx.app) ?? /* @__PURE__ */ new Map();
|
|
4184
4272
|
runs.set(ctx.app, byAddress);
|
|
@@ -4187,6 +4275,7 @@ function registerSlackSessionRun(ctx, address, route) {
|
|
|
4187
4275
|
byAddress.set(key, targets);
|
|
4188
4276
|
const target = {
|
|
4189
4277
|
route,
|
|
4278
|
+
explicitlyAddressed,
|
|
4190
4279
|
isActive: () => targets.has(target)
|
|
4191
4280
|
};
|
|
4192
4281
|
targets.add(target);
|
|
@@ -4195,10 +4284,17 @@ function registerSlackSessionRun(ctx, address, route) {
|
|
|
4195
4284
|
if (targets.size === 0 && byAddress.get(key) === targets) byAddress.delete(key);
|
|
4196
4285
|
};
|
|
4197
4286
|
}
|
|
4287
|
+
function hasAddressedSlackSessionRun(ctx, address) {
|
|
4288
|
+
for (const target of runs.get(ctx.app)?.get(addressKey(address)) ?? []) if (target.explicitlyAddressed) return true;
|
|
4289
|
+
return false;
|
|
4290
|
+
}
|
|
4198
4291
|
function getSlackSessionRuns(ctx, address) {
|
|
4199
|
-
const
|
|
4292
|
+
const key = addressKey(address);
|
|
4293
|
+
const current = () => runs.get(ctx.app)?.get(key);
|
|
4294
|
+
const targets = [...current() ?? []];
|
|
4200
4295
|
return [...new Map(targets.map((target) => [target.route.sessionKey, target])).values()].map((target) => ({
|
|
4201
4296
|
route: target.route,
|
|
4297
|
+
isUnreplaced: () => [...current() ?? []].every((candidate) => targets.includes(candidate)),
|
|
4202
4298
|
isActive: () => targets.some((candidate) => candidate.route.sessionKey === target.route.sessionKey && candidate.isActive())
|
|
4203
4299
|
}));
|
|
4204
4300
|
}
|
|
@@ -4567,7 +4663,7 @@ const SLACK_COMMAND_ARG_BUTTON_VALUE_MAX = 2e3;
|
|
|
4567
4663
|
const SLACK_COMMAND_ARG_CONFIRM_TEXT_MAX = 300;
|
|
4568
4664
|
const SLACK_HEADER_TEXT_MAX = 150;
|
|
4569
4665
|
const SLACK_COMMAND_ARG_ACTION_BLOCKS_MAX = 47;
|
|
4570
|
-
const loadSlashDispatchRuntime = createLazyRuntimeModule(() => import("./slash-dispatch.runtime
|
|
4666
|
+
const loadSlashDispatchRuntime = createLazyRuntimeModule(() => import("./slash-dispatch.runtime--T5PbqoB.mjs"));
|
|
4571
4667
|
const loadPluginCommandRuntime = createLazyRuntimeModule(() => import("openclaw/plugin-sdk/plugin-command-runtime"));
|
|
4572
4668
|
const slackExternalArgMenuStore = createSlackExternalArgMenuStore();
|
|
4573
4669
|
function buildSlackArgMenuConfirm(params) {
|
|
@@ -4802,7 +4898,7 @@ function createSlackCommandHandler(params) {
|
|
|
4802
4898
|
allowNameMatching: ctx.allowNameMatching
|
|
4803
4899
|
});
|
|
4804
4900
|
const senderName = (await ctx.resolveUserName(command.user_id, eventScope))?.name ?? command.user_name ?? command.user_id;
|
|
4805
|
-
const
|
|
4901
|
+
const slashIngressParams = {
|
|
4806
4902
|
ctx,
|
|
4807
4903
|
teamId: eventScope?.teamId ?? ctx.teamId,
|
|
4808
4904
|
senderId: command.user_id,
|
|
@@ -4817,14 +4913,13 @@ function createSlackCommandHandler(params) {
|
|
|
4817
4913
|
hasControlCommand: false,
|
|
4818
4914
|
eventKind: "slash-command",
|
|
4819
4915
|
modeWhenAccessGroupsOff: "configured"
|
|
4820
|
-
}
|
|
4821
|
-
const
|
|
4822
|
-
if (isRoomish &&
|
|
4916
|
+
};
|
|
4917
|
+
const slashGate = await resolveSlackCommandIngress(slashIngressParams);
|
|
4918
|
+
if (isRoomish && slashGate.senderAccess.gate?.allowed === false) {
|
|
4823
4919
|
await respondEphemeral("You are not authorized to use this command here.");
|
|
4824
4920
|
return false;
|
|
4825
4921
|
}
|
|
4826
|
-
|
|
4827
|
-
if (isRoomish && ctx.useAccessGroups && !commandAuthorized) {
|
|
4922
|
+
if (isRoomish && ctx.useAccessGroups && !slashGate.commandAccess.authorized) {
|
|
4828
4923
|
await respondEphemeral("You are not authorized to use this command.");
|
|
4829
4924
|
return false;
|
|
4830
4925
|
}
|
|
@@ -4834,18 +4929,15 @@ function createSlackCommandHandler(params) {
|
|
|
4834
4929
|
id: isDirectMessage ? command.user_id : command.channel_id
|
|
4835
4930
|
});
|
|
4836
4931
|
const routingTeamId = (eventScope?.teamId ?? ctx.teamId) || void 0;
|
|
4837
|
-
|
|
4838
|
-
const sessionTarget = { isCurrent: p.isSessionTargetCurrent };
|
|
4932
|
+
const sessionTarget = {};
|
|
4839
4933
|
const resolveSlashRoute = async () => {
|
|
4840
|
-
if (resolvedSlashRoute) return resolvedSlashRoute;
|
|
4841
4934
|
if (p.threadTs) {
|
|
4842
4935
|
if (p.sessionTarget) {
|
|
4843
|
-
|
|
4844
|
-
const current = await captureSlackSessionTargetGuard(ctx, p.sessionTarget, p.isSessionTargetCurrent);
|
|
4936
|
+
const current = await captureSlackSessionTargetGuard(ctx, p.sessionTarget);
|
|
4845
4937
|
sessionTarget.isCurrent = current.isCurrent;
|
|
4846
4938
|
sessionTarget.source = current.source;
|
|
4847
4939
|
releaseSessionTarget = current.release;
|
|
4848
|
-
return
|
|
4940
|
+
return p.sessionTarget.route;
|
|
4849
4941
|
}
|
|
4850
4942
|
const routing = await resolveSlackSessionEventRoutingContext({
|
|
4851
4943
|
intent: "stop",
|
|
@@ -4862,14 +4954,13 @@ function createSlackCommandHandler(params) {
|
|
|
4862
4954
|
channelConfig,
|
|
4863
4955
|
eventScope
|
|
4864
4956
|
});
|
|
4865
|
-
resolvedSlashRoute = routing.route;
|
|
4866
4957
|
sessionTarget.isCurrent = routing.isCurrentSession;
|
|
4867
4958
|
sessionTarget.source = routing.sessionSource;
|
|
4868
4959
|
releaseSessionTarget = routing.release;
|
|
4869
|
-
return
|
|
4960
|
+
return routing.route;
|
|
4870
4961
|
}
|
|
4871
4962
|
const { resolveAgentRoute } = await loadSlashDispatchRuntime();
|
|
4872
|
-
|
|
4963
|
+
return resolveAgentRoute({
|
|
4873
4964
|
cfg,
|
|
4874
4965
|
channel: "slack",
|
|
4875
4966
|
accountId: account.accountId,
|
|
@@ -4879,11 +4970,38 @@ function createSlackCommandHandler(params) {
|
|
|
4879
4970
|
id: routeTarget.peerId
|
|
4880
4971
|
}
|
|
4881
4972
|
});
|
|
4882
|
-
return resolvedSlashRoute;
|
|
4883
4973
|
};
|
|
4974
|
+
const route = await resolveSlashRoute();
|
|
4975
|
+
const slashUserTarget = resolveSlackDeferredActionTarget({
|
|
4976
|
+
eventScope,
|
|
4977
|
+
kind: "user",
|
|
4978
|
+
id: command.user_id
|
|
4979
|
+
});
|
|
4980
|
+
const { sessionKey, commandTargetSessionKey } = resolveNativeCommandSessionTargets({
|
|
4981
|
+
agentId: route.agentId,
|
|
4982
|
+
sessionPrefix: slashCommand.sessionPrefix,
|
|
4983
|
+
userId: slashUserTarget.peerId,
|
|
4984
|
+
targetSessionKey: route.sessionKey,
|
|
4985
|
+
sessionKeyCase: "lowercase"
|
|
4986
|
+
});
|
|
4987
|
+
const messageId = p.eventTs ?? command.trigger_id;
|
|
4988
|
+
const slashIngress = await resolveSlackCommandIngress({
|
|
4989
|
+
...slashIngressParams,
|
|
4990
|
+
contextBinding: {
|
|
4991
|
+
agentId: route.agentId,
|
|
4992
|
+
sessionKey,
|
|
4993
|
+
messageId,
|
|
4994
|
+
inboundEventKind: "user_request"
|
|
4995
|
+
}
|
|
4996
|
+
});
|
|
4997
|
+
const commandAuthorized = slashIngress.commandAccess.authorized;
|
|
4998
|
+
if (slashIngress.ingress.admission !== "dispatch") {
|
|
4999
|
+
await respondEphemeral("You are not authorized to use this command.");
|
|
5000
|
+
return false;
|
|
5001
|
+
}
|
|
4884
5002
|
if (commandDefinition) {
|
|
4885
5003
|
const menuNeedsModelContext = !(commandArgs?.raw && !commandArgs.values) && commandDefinition.args?.some((arg) => typeof arg.choices === "function" && commandArgs?.values?.[arg.name] == null);
|
|
4886
|
-
const menuRoute = menuNeedsModelContext || commandDefinition.key === "verbose" ?
|
|
5004
|
+
const menuRoute = menuNeedsModelContext || commandDefinition.key === "verbose" ? route : void 0;
|
|
4887
5005
|
const menuModelContext = menuNeedsModelContext && menuRoute ? await resolveSlackCommandMenuModelContext({
|
|
4888
5006
|
cfg,
|
|
4889
5007
|
agentId: menuRoute.agentId,
|
|
@@ -4902,7 +5020,6 @@ function createSlackCommandHandler(params) {
|
|
|
4902
5020
|
catalog: menuModelCatalog
|
|
4903
5021
|
});
|
|
4904
5022
|
if (menu) {
|
|
4905
|
-
const route = menuRoute ?? await resolveSlashRoute();
|
|
4906
5023
|
const commandLabel = commandDefinition.nativeName ?? commandDefinition.key;
|
|
4907
5024
|
const title = formatCommandArgMenuTitle({
|
|
4908
5025
|
command: commandDefinition,
|
|
@@ -4947,69 +5064,65 @@ function createSlackCommandHandler(params) {
|
|
|
4947
5064
|
}
|
|
4948
5065
|
const channelName = channelInfo?.name;
|
|
4949
5066
|
const roomLabel = channelName ? `#${channelName}` : `#${command.channel_id}`;
|
|
4950
|
-
const { deliverSlackSlashReplies, dispatchChannelInboundTurn,
|
|
4951
|
-
const route = await resolveSlashRoute();
|
|
5067
|
+
const { buildChannelInboundEventContext, deliverSlackSlashReplies, dispatchChannelInboundTurn, isChannelPartialDeliveryError, resolveChunkMode, resolveMarkdownTableMode, sanitizeSlackMonitorReplyPayload } = await loadSlashDispatchRuntime();
|
|
4952
5068
|
const { channelMetadata, groupSystemPrompt } = resolveSlackRoomContextHints({
|
|
4953
5069
|
isRoomish,
|
|
4954
5070
|
channelInfo,
|
|
4955
5071
|
channelConfig
|
|
4956
5072
|
});
|
|
4957
|
-
const slashUserTarget = resolveSlackDeferredActionTarget({
|
|
4958
|
-
eventScope,
|
|
4959
|
-
kind: "user",
|
|
4960
|
-
id: command.user_id
|
|
4961
|
-
});
|
|
4962
|
-
const { sessionKey, commandTargetSessionKey } = resolveNativeCommandSessionTargets({
|
|
4963
|
-
agentId: route.agentId,
|
|
4964
|
-
sessionPrefix: slashCommand.sessionPrefix,
|
|
4965
|
-
userId: slashUserTarget.peerId,
|
|
4966
|
-
targetSessionKey: route.sessionKey,
|
|
4967
|
-
sessionKeyCase: "lowercase"
|
|
4968
|
-
});
|
|
4969
5073
|
const slashReplyTarget = resolveSlackDeferredActionTarget({
|
|
4970
5074
|
eventScope,
|
|
4971
5075
|
kind: !slashCommand.ephemeral && isRoomish ? "channel" : "user",
|
|
4972
5076
|
id: !slashCommand.ephemeral && isRoomish ? command.channel_id : command.user_id
|
|
4973
5077
|
}).target;
|
|
4974
5078
|
const from = isDirectMessage ? `slack:${routeTarget.peerId}` : isRoom ? `slack:channel:${routeTarget.peerId}` : `slack:group:${routeTarget.peerId}`;
|
|
4975
|
-
const ctxPayload =
|
|
4976
|
-
|
|
4977
|
-
|
|
4978
|
-
|
|
4979
|
-
|
|
4980
|
-
|
|
4981
|
-
|
|
4982
|
-
|
|
4983
|
-
|
|
4984
|
-
|
|
4985
|
-
|
|
4986
|
-
|
|
5079
|
+
const ctxPayload = (ctx.buildContext ?? buildChannelInboundEventContext)({
|
|
5080
|
+
channelIngress: slashIngress,
|
|
5081
|
+
channel: "slack",
|
|
5082
|
+
accountId: route.accountId,
|
|
5083
|
+
messageId,
|
|
5084
|
+
timestamp: Date.now(),
|
|
5085
|
+
from,
|
|
5086
|
+
sender: {
|
|
5087
|
+
id: command.user_id,
|
|
5088
|
+
name: senderName
|
|
5089
|
+
},
|
|
5090
|
+
conversation: {
|
|
5091
|
+
kind: chatType,
|
|
5092
|
+
id: command.channel_id,
|
|
5093
|
+
spaceId: routingTeamId,
|
|
5094
|
+
threadId: p.threadTs
|
|
5095
|
+
},
|
|
5096
|
+
route: {
|
|
5097
|
+
agentId: route.agentId,
|
|
5098
|
+
accountId: route.accountId,
|
|
5099
|
+
routeSessionKey: commandTargetSessionKey,
|
|
5100
|
+
dispatchSessionKey: sessionKey
|
|
5101
|
+
},
|
|
5102
|
+
reply: {
|
|
5103
|
+
to: `slash:${slashUserTarget.peerId}`,
|
|
5104
|
+
originatingTo: p.threadTs ? resolveSlackDeferredActionTarget({
|
|
5105
|
+
eventScope,
|
|
5106
|
+
kind: "channel",
|
|
5107
|
+
id: command.channel_id
|
|
5108
|
+
}).target : slashReplyTarget
|
|
5109
|
+
},
|
|
5110
|
+
message: {
|
|
5111
|
+
body: prompt,
|
|
5112
|
+
bodyForAgent: prompt,
|
|
5113
|
+
rawBody: prompt,
|
|
5114
|
+
commandBody: prompt
|
|
5115
|
+
},
|
|
5116
|
+
access: { commands: { authorized: commandAuthorized } },
|
|
5117
|
+
extra: {
|
|
5118
|
+
CommandArgs: commandArgs,
|
|
4987
5119
|
GroupSubject: isRoomish ? roomLabel : void 0,
|
|
4988
|
-
|
|
4989
|
-
|
|
4990
|
-
|
|
4991
|
-
|
|
4992
|
-
|
|
4993
|
-
|
|
4994
|
-
SenderName: senderName,
|
|
4995
|
-
SenderId: command.user_id,
|
|
4996
|
-
Provider: "slack",
|
|
4997
|
-
Surface: "slack",
|
|
4998
|
-
WasMentioned: true,
|
|
4999
|
-
MessageSid: p.eventTs ?? command.trigger_id,
|
|
5000
|
-
MessageThreadId: p.threadTs,
|
|
5001
|
-
Timestamp: Date.now(),
|
|
5002
|
-
SessionKey: sessionKey,
|
|
5003
|
-
CommandTargetSessionKey: commandTargetSessionKey,
|
|
5004
|
-
AccountId: route.accountId,
|
|
5005
|
-
CommandSource: "native",
|
|
5006
|
-
CommandAuthorized: commandAuthorized,
|
|
5007
|
-
OriginatingChannel: "slack",
|
|
5008
|
-
OriginatingTo: p.threadTs ? resolveSlackDeferredActionTarget({
|
|
5009
|
-
eventScope,
|
|
5010
|
-
kind: "channel",
|
|
5011
|
-
id: command.channel_id
|
|
5012
|
-
}).target : slashReplyTarget
|
|
5120
|
+
GroupSystemPrompt: groupSystemPrompt,
|
|
5121
|
+
ChannelPromptContext: channelMetadata ? [channelMetadata] : void 0,
|
|
5122
|
+
WasMentioned: true,
|
|
5123
|
+
CommandTargetSessionKey: commandTargetSessionKey,
|
|
5124
|
+
CommandSource: "native"
|
|
5125
|
+
}
|
|
5013
5126
|
});
|
|
5014
5127
|
const messageSentHookTarget = ctxPayload.OriginatingTo ?? ctxPayload.To ?? slashReplyTarget;
|
|
5015
5128
|
const deliverSlashPayloads = async (replies, onReplySettled) => {
|
|
@@ -5486,6 +5599,7 @@ function registerSlackCommonEvents(params) {
|
|
|
5486
5599
|
});
|
|
5487
5600
|
registerSlackInteractionEvents({
|
|
5488
5601
|
ctx,
|
|
5602
|
+
handleSlackMessage: params.handleSlackMessage,
|
|
5489
5603
|
trackEvent
|
|
5490
5604
|
});
|
|
5491
5605
|
}
|
|
@@ -5567,8 +5681,7 @@ function registerSlackWorkspaceEvents(params) {
|
|
|
5567
5681
|
senderAuthentication: resolveSlackSenderAuthentication(context),
|
|
5568
5682
|
prompt: "/stop",
|
|
5569
5683
|
builtInCommand: "stop",
|
|
5570
|
-
sessionTarget: target
|
|
5571
|
-
isSessionTargetCurrent: target?.isActive,
|
|
5684
|
+
sessionTarget: target,
|
|
5572
5685
|
onAdmitted: () => {
|
|
5573
5686
|
if (target && !target.isActive()) return false;
|
|
5574
5687
|
markSlackStreamsStopped(slackClient, event.channel, event.streaming_message_ts);
|
|
@@ -5823,7 +5936,7 @@ function createSlackThreadTsResolver(params) {
|
|
|
5823
5936
|
} };
|
|
5824
5937
|
}
|
|
5825
5938
|
// extensions/slack/src/monitor/message-handler.ts
|
|
5826
|
-
const loadSlackMessagePipeline = createLazyRuntimeModule(() => import("./pipeline.runtime-
|
|
5939
|
+
const loadSlackMessagePipeline = createLazyRuntimeModule(() => import("./pipeline.runtime-Bet_aK1D.mjs"));
|
|
5827
5940
|
const RETRYABLE_FLUSH_MAX_ATTEMPTS = 3;
|
|
5828
5941
|
function shouldDebounceSlackMessage(message, cfg) {
|
|
5829
5942
|
const textForCommandDetection = stripSlackMentionsForCommandDetection(message.text ?? "");
|
|
@@ -5843,7 +5956,7 @@ function createSlackMessageHandler(params) {
|
|
|
5843
5956
|
serializeImmediate: true,
|
|
5844
5957
|
resolveDebounceMs: (entry) => entry.debounceMs,
|
|
5845
5958
|
buildKey: (entry) => buildSlackDebounceKey(entry.message, ctx.accountId, entry.opts.eventScope?.teamId),
|
|
5846
|
-
shouldDebounce: (entry) => !entry.retry && !entry.opts.eventScope && shouldDebounceSlackMessage(entry.message, ctx.cfg),
|
|
5959
|
+
shouldDebounce: (entry) => !entry.retry && !entry.opts.eventScope && entry.opts.source !== "block_action" && shouldDebounceSlackMessage(entry.message, ctx.cfg),
|
|
5847
5960
|
onFlush: (entries, createFlush) => createFlush({
|
|
5848
5961
|
lifecycle: { abortSignal: AbortSignal.any([params.abortSignal, ...entries.map((entry) => entry.opts.turnAdoptionLifecycle?.abortSignal)].filter((signal) => signal !== void 0)) },
|
|
5849
5962
|
dispatch: async (admissionLifecycle) => {
|
|
@@ -5853,7 +5966,7 @@ function createSlackMessageHandler(params) {
|
|
|
5853
5966
|
try {
|
|
5854
5967
|
const runtimeContext = admittedContext ??= await ctx.readRuntimeContext();
|
|
5855
5968
|
admissionLifecycle.abortSignal.throwIfAborted();
|
|
5856
|
-
await (async () => {
|
|
5969
|
+
const refusedSilently = await (async () => {
|
|
5857
5970
|
const flushedEntry = entries.at(-1);
|
|
5858
5971
|
if (flushedEntry) {
|
|
5859
5972
|
const teamId = flushedEntry.opts.eventScope?.teamId;
|
|
@@ -5925,7 +6038,7 @@ function createSlackMessageHandler(params) {
|
|
|
5925
6038
|
const last = latestSurviving;
|
|
5926
6039
|
if (!last) {
|
|
5927
6040
|
releaseClaims();
|
|
5928
|
-
return;
|
|
6041
|
+
return false;
|
|
5929
6042
|
}
|
|
5930
6043
|
const combinedText = surviving.length === 1 ? last.message.text ?? "" : surviving.map((entry) => entry.message.text ?? "").filter(Boolean).join("\n");
|
|
5931
6044
|
const combinedMentioned = surviving.some((entry) => Boolean(entry.opts.wasMentioned));
|
|
@@ -5963,10 +6076,10 @@ function createSlackMessageHandler(params) {
|
|
|
5963
6076
|
if (!prepared) {
|
|
5964
6077
|
if (visibleDrop) {
|
|
5965
6078
|
await commitClaims();
|
|
5966
|
-
return;
|
|
6079
|
+
return false;
|
|
5967
6080
|
}
|
|
5968
6081
|
releaseClaims();
|
|
5969
|
-
return;
|
|
6082
|
+
return true;
|
|
5970
6083
|
}
|
|
5971
6084
|
await turnAdoptionLifecycle?.onSessionRouted?.(prepared.route.sessionKey);
|
|
5972
6085
|
const deferredHeartbeatIntervals = [turnAdoptionLifecycle?.deferredHeartbeatIntervalMs, admissionLifecycle.deferredHeartbeatIntervalMs].filter((interval) => interval !== void 0 && Number.isFinite(interval) && interval > 0);
|
|
@@ -6015,12 +6128,13 @@ function createSlackMessageHandler(params) {
|
|
|
6015
6128
|
await dispatchPreparedSlackMessage(prepared);
|
|
6016
6129
|
if (!turnAdoptionLifecycle && !settlementHandedOff) await commitClaims();
|
|
6017
6130
|
else if (!settlementHandedOff) releaseClaims();
|
|
6131
|
+
return false;
|
|
6018
6132
|
} catch (error) {
|
|
6019
6133
|
releaseClaims(error);
|
|
6020
6134
|
throw error;
|
|
6021
6135
|
}
|
|
6022
6136
|
})();
|
|
6023
|
-
for (const completion of completions) completion.resolve();
|
|
6137
|
+
for (const completion of completions) completion.resolve(refusedSilently);
|
|
6024
6138
|
} catch (error) {
|
|
6025
6139
|
const runtimeContext = admittedContext;
|
|
6026
6140
|
if (runtimeContext && (retry?.attempt ?? 0) < RETRYABLE_FLUSH_MAX_ATTEMPTS && error instanceof SlackMessageDispatchRetryError && !entries.some((entry) => entry.opts.eventScope || entry.opts.dispatchCompletion)) {
|
|
@@ -6067,7 +6181,7 @@ function createSlackMessageHandler(params) {
|
|
|
6067
6181
|
cfg: readConfig(),
|
|
6068
6182
|
channel: "slack"
|
|
6069
6183
|
});
|
|
6070
|
-
const canDebounce = !opts.eventScope && debounceMs > 0 && shouldDebounceSlackMessage(resolvedMessage, ctx.cfg);
|
|
6184
|
+
const canDebounce = !opts.eventScope && opts.source !== "block_action" && debounceMs > 0 && shouldDebounceSlackMessage(resolvedMessage, ctx.cfg);
|
|
6071
6185
|
if (!canDebounce && conversationKey) {
|
|
6072
6186
|
const pendingKeys = pendingTopLevelDebounceKeys.get(conversationKey);
|
|
6073
6187
|
if (pendingKeys && pendingKeys.size > 0) {
|
|
@@ -6095,7 +6209,7 @@ function createSlackMessageHandler(params) {
|
|
|
6095
6209
|
return dispatchCompletion;
|
|
6096
6210
|
}
|
|
6097
6211
|
return async (message, opts) => {
|
|
6098
|
-
await (await enqueueSlackMessage(message, opts))?.promise;
|
|
6212
|
+
return await (await enqueueSlackMessage(message, opts))?.promise ?? false;
|
|
6099
6213
|
};
|
|
6100
6214
|
}
|
|
6101
6215
|
// extensions/slack/src/monitor/presence-monitor.ts
|
|
@@ -6366,7 +6480,7 @@ function createSlackWorkspaceClientResolver(params) {
|
|
|
6366
6480
|
}
|
|
6367
6481
|
// extensions/slack/src/monitor/provider.ts
|
|
6368
6482
|
const getSlackBoltInterop = createLazyRuntimeSurface(() => import("@slack/bolt"), resolveSlackBoltInterop);
|
|
6369
|
-
const loadSlackRelaySource = createLazyRuntimeModule(() => import("./relay-source-
|
|
6483
|
+
const loadSlackRelaySource = createLazyRuntimeModule(() => import("./relay-source-BWKpwdJT.mjs"));
|
|
6370
6484
|
function resolveSlackRuntimeIdentity(params) {
|
|
6371
6485
|
const botUserId = normalizeOptionalString(params.botUserId);
|
|
6372
6486
|
const botId = normalizeOptionalString(params.botId);
|
|
@@ -6846,4 +6960,4 @@ var monitor_exports = /* @__PURE__ */ __exportAll({
|
|
|
6846
6960
|
isSlackChannelAllowedByPolicy: () => isSlackChannelAllowedByPolicy,
|
|
6847
6961
|
monitorSlackProvider: () => monitorSlackProvider
|
|
6848
6962
|
});
|
|
6849
|
-
export {
|
|
6963
|
+
export { resolveSlackChatType as A, appendSlackStream as C, stopSlackStream as D, startSlackStream as E, readSlackAssistantThreadContext as M, stripSlackMentionsForCommandDetection as N, SLACK_SOCKET_RECONNECT_POLICY as O, SlackStreamNotDeliveredError as S, markSlackStreamFallbackDelivered as T, requireSlackMessageEvent as _, createSlackResponseUrlBudget as a, resolveSlackEffectiveAllowFrom as b, hasAddressedSlackSessionRun as c, resolveSlackChannelHistory as d, resolveSlackThreadHistory as f, parseSlackMessageEvent as g, trackSlackDraftMessage as h, SlackResponseAlreadyReportedError as i, buildSlackAssistantThreadMetadata as j, normalizeSlackChannelType as k, registerSlackSessionRun as l, resolveSlackTimestampMs as m, monitorSlackProvider as n, authorizeSlackDirectMessage as o, resolveSlackThreadStarter as p, resolveSlackRoomContextHints as r, resolveSlackRoutingContext as s, monitor_exports as t, resolveSlackThreadContext as u, authorizeSlackBotRoomMessage as v, discardSlackStreamPendingText as w, SlackStreamMessageTooLongError as x, resolveSlackCommandIngress as y };
|