





























@@ -61,6 +61,7 @@ import {
6161slackConfigAdapter,
6262} from "./shared.js";
6363import { parseSlackTarget } from "./target-parsing.js";
64+import { normalizeSlackThreadTsCandidate, resolveSlackThreadTsValue } from "./thread-ts.js";
6465import { buildSlackThreadingToolContext } from "./threading-tool-context.js";
65666667// Lazy SDK loaders. The dynamic import is hidden behind a string-literal
@@ -218,7 +219,7 @@ async function resolveSlackSendContext(params: {
218219const token = getTokenForOperation(account, "write");
219220const botToken = account.botToken?.trim();
220221const tokenOverride = token && token !== botToken ? token : undefined;
221-const threadTsValue = params.replyToId ?? params.threadId;
222+const threadTsValue = resolveSlackThreadTsValue(params);
222223return { send, threadTsValue, tokenOverride };
223224}
224225@@ -608,14 +609,16 @@ export const slackPlugin: ChannelPlugin<ResolvedSlackAccount, SlackProbe> = crea
608609allowExplicitReplyTagsWhenOff: false,
609610buildToolContext: (params) => buildSlackThreadingToolContext(params),
610611resolveAutoThreadId: ({ to, toolContext, replyToId }) =>
611-replyToId
612+normalizeSlackThreadTsCandidate(replyToId)
612613 ? undefined
613- : resolveSlackAutoThreadId({
614- to,
615- toolContext,
616-}),
614+ : normalizeSlackThreadTsCandidate(
615+resolveSlackAutoThreadId({
616+ to,
617+ toolContext,
618+}),
619+),
617620resolveReplyTransport: ({ threadId, replyToId }) => ({
618-replyToId: replyToId ?? (threadId != null && threadId !== "" ? String(threadId) : undefined),
621+replyToId: resolveSlackThreadTsValue({ replyToId, threadId }),
619622threadId: null,
620623}),
621624},
@@ -632,7 +635,7 @@ export const slackPlugin: ChannelPlugin<ResolvedSlackAccount, SlackProbe> = crea
632635 payload,
633636}),
634637sendPayload: async (ctx) => {
635-const { send, tokenOverride } = await resolveSlackSendContext({
638+const { send, threadTsValue, tokenOverride } = await resolveSlackSendContext({
636639cfg: ctx.cfg,
637640accountId: ctx.accountId ?? undefined,
638641deps: ctx.deps,
@@ -642,6 +645,8 @@ export const slackPlugin: ChannelPlugin<ResolvedSlackAccount, SlackProbe> = crea
642645const { slackOutbound } = await loadSlackOutboundAdapterModule();
643646return await slackOutbound.sendPayload!({
644647 ...ctx,
648+replyToId: threadTsValue,
649+threadId: null,
645650deps: {
646651 ...ctx.deps,
647652slack: async (
@@ -669,7 +674,7 @@ export const slackPlugin: ChannelPlugin<ResolvedSlackAccount, SlackProbe> = crea
669674});
670675return await send(to, text, {
671676 cfg,
672-threadTs: threadTsValue != null ? String(threadTsValue) : undefined,
677+threadTs: threadTsValue,
673678accountId: accountId ?? undefined,
674679 ...(tokenOverride ? { token: tokenOverride } : {}),
675680});
@@ -696,7 +701,7 @@ export const slackPlugin: ChannelPlugin<ResolvedSlackAccount, SlackProbe> = crea
696701 cfg,
697702 mediaUrl,
698703 mediaLocalRoots,
699-threadTs: threadTsValue != null ? String(threadTsValue) : undefined,
704+threadTs: threadTsValue,
700705accountId: accountId ?? undefined,
701706 ...(tokenOverride ? { token: tokenOverride } : {}),
702707});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。