





















@@ -7,10 +7,12 @@ import type {
77} from "openclaw/plugin-sdk/config-types";
88import type { SessionScope } from "openclaw/plugin-sdk/config-types";
99import type { DmPolicy, GroupPolicy } from "openclaw/plugin-sdk/config-types";
10+import { resolveRuntimeConversationBindingRoute } from "openclaw/plugin-sdk/conversation-runtime";
1011import { createDedupeCache } from "openclaw/plugin-sdk/dedupe-runtime";
1112import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
1213import type { HistoryEntry } from "openclaw/plugin-sdk/reply-history";
1314import { resolveAgentRoute } from "openclaw/plugin-sdk/routing";
15+import { resolveThreadSessionKeys } from "openclaw/plugin-sdk/routing";
1416import { logVerbose } from "openclaw/plugin-sdk/runtime-env";
1517import { getChildLogger } from "openclaw/plugin-sdk/runtime-env";
1618import type { RuntimeEnv } from "openclaw/plugin-sdk/runtime-env";
@@ -78,6 +80,7 @@ export type SlackMonitorContext = {
7880channelId?: string | null;
7981channelType?: string | null;
8082senderId?: string | null;
83+threadTs?: string | null;
8184}) => string;
8285isChannelAllowed: (params: {
8386channelId?: string;
@@ -178,6 +181,7 @@ export function createSlackMonitorContext(params: {
178181channelId?: string | null;
179182channelType?: string | null;
180183senderId?: string | null;
184+threadTs?: string | null;
181185}) => {
182186const channelId = normalizeOptionalString(p.channelId) ?? "";
183187if (!channelId) {
@@ -207,18 +211,58 @@ export function createSlackMonitorContext(params: {
207211teamId: params.teamId,
208212peer: { kind: peerKind, id: peerId },
209213});
210-return route.sessionKey;
214+const threadTs = normalizeOptionalString(p.threadTs);
215+const baseConversationId = isDirectMessage ? `user:${senderId}` : channelId;
216+const threadBindingRoute = threadTs
217+ ? resolveRuntimeConversationBindingRoute({
218+ route,
219+conversation: {
220+channel: "slack",
221+accountId: params.accountId,
222+conversationId: threadTs,
223+parentConversationId: baseConversationId,
224+},
225+})
226+ : null;
227+const runtimeRoute =
228+threadBindingRoute?.boundSessionKey || threadBindingRoute?.bindingRecord
229+ ? threadBindingRoute
230+ : resolveRuntimeConversationBindingRoute({
231+ route,
232+conversation: {
233+channel: "slack",
234+accountId: params.accountId,
235+conversationId: baseConversationId,
236+},
237+});
238+if (runtimeRoute.boundSessionKey) {
239+return runtimeRoute.route.sessionKey;
240+}
241+return resolveThreadSessionKeys({
242+baseSessionKey: runtimeRoute.route.sessionKey,
243+threadId: threadTs,
244+parentSessionKey:
245+threadTs && params.threadInheritParent ? runtimeRoute.route.sessionKey : undefined,
246+}).sessionKey;
211247}
212248} catch {
213249// Fall through to legacy key derivation.
214250}
215251216-return resolveSessionKey(
252+const legacySessionKey = resolveSessionKey(
217253params.sessionScope,
218254{ From: from, ChatType: chatType, Provider: "slack" },
219255params.mainKey,
220256resolveDefaultAgentId(params.cfg),
221257);
258+return resolveThreadSessionKeys({
259+baseSessionKey: legacySessionKey,
260+threadId: normalizeOptionalString(p.threadTs),
261+parentSessionKey:
262+normalizeOptionalString(p.threadTs) && params.threadInheritParent
263+ ? legacySessionKey
264+ : undefined,
265+}).sessionKey;
222266};
223267224268const resolveChannelName = async (channelId: string) => {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。