refactor(channels): share native command session targets

This commit is contained in:
Peter Steinberger
2026-03-08 01:26:11 +00:00
parent 6016e22cc0
commit e381ab630e
7 changed files with 92 additions and 68 deletions

View File

@@ -14,6 +14,7 @@ import { finalizeInboundContext } from "../auto-reply/reply/inbound-context.js";
import { dispatchReplyWithBufferedBlockDispatcher } from "../auto-reply/reply/provider-dispatcher.js";
import { listSkillCommandsForAgents } from "../auto-reply/skill-commands.js";
import { resolveCommandAuthorizedFromAuthorizers } from "../channels/command-gating.js";
import { resolveNativeCommandSessionTargets } from "../channels/native-command-session-targets.js";
import { createReplyPrefixOptions } from "../channels/reply-prefix.js";
import { recordInboundSessionMetaSafe } from "../channels/session-meta.js";
import type { OpenClawConfig } from "../config/config.js";
@@ -638,6 +639,13 @@ export const registerTelegramNativeCommands = ({
groupConfig,
topicConfig,
});
const { sessionKey: commandSessionKey, commandTargetSessionKey } =
resolveNativeCommandSessionTargets({
agentId: route.agentId,
sessionPrefix: "telegram:slash",
userId: String(senderId || chatId),
targetSessionKey: sessionKey,
});
const conversationLabel = isGroup
? msg.chat.title
? `${msg.chat.title} id:${chatId}`
@@ -665,9 +673,9 @@ export const registerTelegramNativeCommands = ({
WasMentioned: true,
CommandAuthorized: commandAuthorized,
CommandSource: "native" as const,
SessionKey: `agent:${route.agentId}:telegram:slash:${senderId || chatId}`,
SessionKey: commandSessionKey,
AccountId: route.accountId,
CommandTargetSessionKey: sessionKey,
CommandTargetSessionKey: commandTargetSessionKey,
MessageThreadId: threadSpec.id,
IsForum: isForum,
// Originating context for sub-agent announce routing