

























@@ -13,14 +13,9 @@ import {
1313import type { AcpRuntimeSessionMode } from "../acp/runtime/types.js";
1414import { DEFAULT_HEARTBEAT_EVERY } from "../auto-reply/heartbeat.js";
1515import {
16-getChannelPlugin,
17-getLoadedChannelPlugin,
18-normalizeChannelId,
19-} from "../channels/plugins/index.js";
20-import {
21-resolveBundledChannelThreadBindingDefaultPlacement,
22-resolveBundledChannelThreadBindingInboundConversation,
23-} from "../channels/plugins/thread-binding-api.js";
16+resolveChannelDefaultBindingPlacement,
17+resolveInboundConversationResolution,
18+} from "../channels/conversation-resolution.js";
2419import {
2520resolveThreadBindingIntroText,
2621resolveThreadBindingThreadName,
@@ -45,8 +40,6 @@ import type { SessionEntry } from "../config/sessions/types.js";
4540import type { OpenClawConfig } from "../config/types.openclaw.js";
4641import { callGateway } from "../gateway/call.js";
4742import { areHeartbeatsEnabled } from "../infra/heartbeat-wake.js";
48-import { resolveConversationIdFromTargets } from "../infra/outbound/conversation-id.js";
49-import { normalizeConversationTargetRef } from "../infra/outbound/session-binding-normalization.js";
5043import {
5144getSessionBindingService,
5245isSessionBindingError,
@@ -291,46 +284,6 @@ function resolvePlacementWithoutChannelPlugin(params: {
291284return params.capabilities.placements.includes("child") ? "child" : "current";
292285}
293286294-function resolvePluginConversationRefForThreadBinding(params: {
295-channelId: string;
296-to?: string;
297-threadId?: string | number;
298-groupId?: string;
299-}): { conversationId: string; parentConversationId?: string } | null {
300-const resolverParams = {
301-// Keep the live delivery target authoritative; conversationId is only a fallback hint.
302-to: params.to,
303-conversationId: params.groupId ?? params.to,
304-threadId: params.threadId,
305-isGroup: true,
306-};
307-const loadedPluginConversation = getLoadedChannelPlugin(
308-params.channelId,
309-)?.messaging?.resolveInboundConversation?.(resolverParams);
310-const bundledApiConversation =
311-loadedPluginConversation === undefined
312- ? resolveBundledChannelThreadBindingInboundConversation({
313-channelId: params.channelId,
314- ...resolverParams,
315-})
316- : undefined;
317-const resolvedConversation =
318-loadedPluginConversation ??
319-(bundledApiConversation !== undefined
320- ? bundledApiConversation
321- : getChannelPlugin(params.channelId)?.messaging?.resolveInboundConversation?.(
322-resolverParams,
323-));
324-const conversationId = normalizeOptionalString(resolvedConversation?.conversationId);
325-if (!conversationId) {
326-return null;
327-}
328-return normalizeConversationTargetRef({
329- conversationId,
330-parentConversationId: resolvedConversation?.parentConversationId,
331-});
332-}
333-334287function resolveSpawnMode(params: {
335288requestedMode?: SpawnAcpMode;
336289threadRequested: boolean;
@@ -559,38 +512,23 @@ async function persistAcpSpawnSessionFileBestEffort(params: {
559512}
560513561514function resolveConversationRefForThreadBinding(params: {
515+cfg: OpenClawConfig;
562516channel?: string;
517+accountId?: string;
563518to?: string;
564519threadId?: string | number;
565520groupId?: string;
566521}): { conversationId: string; parentConversationId?: string } | null {
567-const channel = normalizeOptionalLowercaseString(params.channel);
568-const normalizedChannelId = channel ? normalizeChannelId(channel) : null;
569-const pluginResolvedConversation = normalizedChannelId
570- ? resolvePluginConversationRefForThreadBinding({
571-channelId: normalizedChannelId,
572-to: params.to,
573-threadId: params.threadId,
574-groupId: params.groupId,
575-})
576- : null;
577-if (pluginResolvedConversation) {
578-return pluginResolvedConversation;
579-}
580-const parentConversationId = resolveConversationIdFromTargets({
581-targets: [params.to],
582-});
583-const genericConversationId = resolveConversationIdFromTargets({
522+const resolution = resolveInboundConversationResolution({
523+cfg: params.cfg,
524+channel: params.channel,
525+accountId: params.accountId,
526+to: params.to,
584527threadId: params.threadId,
585-targets: [params.to],
528+groupId: params.groupId,
529+isGroup: true,
586530});
587-if (genericConversationId) {
588-return normalizeConversationTargetRef({
589-conversationId: genericConversationId,
590-parentConversationId: params.threadId != null ? parentConversationId : undefined,
591-});
592-}
593-return null;
531+return resolution?.canonical ?? null;
594532}
595533596534function resolveAcpSpawnChannelAccountId(params: {
@@ -669,13 +607,7 @@ function prepareAcpThreadBinding(params: {
669607error: `Thread bindings are unavailable for ${policy.channel}.`,
670608};
671609}
672-const loadedPluginPlacement = getLoadedChannelPlugin(policy.channel)?.conversationBindings
673-?.defaultTopLevelPlacement;
674-const bundledApiPlacement =
675-loadedPluginPlacement ?? resolveBundledChannelThreadBindingDefaultPlacement(policy.channel);
676-const pluginPlacement =
677-bundledApiPlacement ??
678-getChannelPlugin(policy.channel)?.conversationBindings?.defaultTopLevelPlacement;
610+const pluginPlacement = resolveChannelDefaultBindingPlacement(policy.channel);
679611const placementToUse =
680612pluginPlacement ??
681613resolvePlacementWithoutChannelPlugin({
@@ -688,7 +620,9 @@ function prepareAcpThreadBinding(params: {
688620};
689621}
690622const conversationRef = resolveConversationRefForThreadBinding({
623+cfg: params.cfg,
691624channel: policy.channel,
625+accountId: policy.accountId,
692626to: params.to,
693627threadId: params.threadId,
694628groupId: params.groupId,
@@ -1031,7 +965,9 @@ function resolveAcpSpawnBootstrapDeliveryPlan(params: {
1031965fallbackThreadIdRaw != null ? normalizeOptionalString(String(fallbackThreadIdRaw)) : undefined;
1032966const deliveryThreadId = boundThreadId ?? fallbackThreadId;
1033967const requesterConversationRef = resolveConversationRefForThreadBinding({
968+cfg: params.cfg,
1034969channel: params.requester.origin?.channel,
970+accountId: params.requester.origin?.accountId,
1035971threadId: fallbackThreadId,
1036972to: params.requester.origin?.to,
1037973});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。