























@@ -1,11 +1,23 @@
11import type { OpenClawConfig } from "openclaw/plugin-sdk/config-types";
2+import {
3+__testing as conversationBindingTesting,
4+registerSessionBindingAdapter,
5+type SessionBindingAdapter,
6+} from "openclaw/plugin-sdk/conversation-runtime";
27import { resolveThreadSessionKeys } from "openclaw/plugin-sdk/routing";
3-import { describe, expect, it } from "vitest";
4-import { resolveTelegramConversationBaseSessionKey } from "./conversation-route.js";
8+import { beforeEach, describe, expect, it, vi } from "vitest";
9+import {
10+resolveTelegramConversationBaseSessionKey,
11+resolveTelegramConversationRoute,
12+} from "./conversation-route.js";
513614describe("resolveTelegramConversationBaseSessionKey", () => {
715const cfg: OpenClawConfig = {};
81617+beforeEach(() => {
18+conversationBindingTesting.resetSessionBindingAdaptersForTests();
19+});
20+921it("keeps default-account DMs on the route session key", () => {
1022expect(
1123resolveTelegramConversationBaseSessionKey({
@@ -105,4 +117,47 @@ describe("resolveTelegramConversationBaseSessionKey", () => {
105117}).sessionKey,
106118).toBe("agent:main:telegram:personal:direct:12345:thread:12345:99");
107119});
120+121+it("keeps inbound DMs on the main route when a stale runtime binding points at a cron run", () => {
122+const touch = vi.fn<NonNullable<SessionBindingAdapter["touch"]>>();
123+registerSessionBindingAdapter({
124+channel: "telegram",
125+accountId: "default",
126+listBySession: () => [],
127+resolveByConversation: () => ({
128+bindingId: "binding-cron-run",
129+targetSessionKey: "agent:youtube:cron:monthly-report:run:closed-run-1",
130+targetKind: "session",
131+conversation: {
132+channel: "telegram",
133+accountId: "default",
134+conversationId: "12345",
135+},
136+status: "active",
137+boundAt: 1,
138+}),
139+ touch,
140+});
141+142+const result = resolveTelegramConversationRoute({
143+cfg: {
144+session: {
145+dmScope: "main",
146+},
147+},
148+accountId: "default",
149+chatId: 12345,
150+isGroup: false,
151+senderId: 12345,
152+});
153+154+expect(touch).not.toHaveBeenCalled();
155+expect(result.configuredBinding).toBeNull();
156+expect(result.configuredBindingSessionKey).toBe("");
157+expect(result.route).toMatchObject({
158+agentId: "main",
159+sessionKey: "agent:main:main",
160+matchedBy: "default",
161+});
162+});
108163});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。