























@@ -4,6 +4,7 @@ import { beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
44import type { TelegramNativeCommandDeps } from "./bot-native-command-deps.runtime.js";
55import {
66createDeferred,
7+createTelegramGroupCommandContext,
78createNativeCommandTestParams,
89createTelegramPrivateCommandContext,
910createTelegramTopicCommandContext,
@@ -873,6 +874,40 @@ describe("registerTelegramNativeCommands — session metadata", () => {
873874);
874875});
875876877+it("routes Telegram native commands through bound top-level group sessions", async () => {
878+sessionBindingMocks.resolveByConversation.mockReturnValue({
879+bindingId: "default:-1001234567890",
880+targetSessionKey: "agent:codex-acp:session-group",
881+});
882+883+const { handler } = registerAndResolveStatusHandler({
884+cfg: {},
885+allowFrom: ["200"],
886+groupAllowFrom: ["200"],
887+});
888+await handler(createTelegramGroupCommandContext());
889+890+expect(sessionBindingMocks.resolveByConversation).toHaveBeenCalledWith({
891+channel: "telegram",
892+accountId: "default",
893+conversationId: "-1001234567890",
894+});
895+const dispatchCall = (
896+replyMocks.dispatchReplyWithBufferedBlockDispatcher.mock.calls as unknown as Array<
897+[{ ctx?: { CommandTargetSessionKey?: string; OriginatingTo?: string } }]
898+>
899+)[0]?.[0];
900+expect(dispatchCall?.ctx?.CommandTargetSessionKey).toBe("agent:codex-acp:session-group");
901+expect(dispatchCall?.ctx?.OriginatingTo).toBe("telegram:-1001234567890");
902+const sessionMetaCall = (
903+sessionMocks.recordSessionMetaFromInbound.mock.calls as unknown as Array<
904+[{ sessionKey?: string }]
905+>
906+)[0]?.[0];
907+expect(sessionMetaCall?.sessionKey).toBe("agent:codex-acp:session-group");
908+expect(sessionBindingMocks.touch).toHaveBeenCalledWith("default:-1001234567890", undefined);
909+});
910+876911it.each(["new", "reset"] as const)(
877912"preserves the topic-qualified origin target for native /%s in forum topics",
878913async (commandName) => {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。