
























@@ -138,6 +138,109 @@ describe("resolveAgentRoute", () => {
138138});
139139});
140140141+test("route binding session dmScope isolates selected direct peers without changing agent", () => {
142+const cfg: OpenClawConfig = {
143+session: { dmScope: "main" },
144+bindings: [
145+{
146+type: "route",
147+agentId: "main",
148+match: {
149+channel: "discord",
150+accountId: "default",
151+peer: { kind: "direct", id: "1497598990336790559" },
152+},
153+session: { dmScope: "per-account-channel-peer" },
154+},
155+{
156+type: "route",
157+agentId: "main",
158+match: {
159+channel: "discord",
160+accountId: "default",
161+peer: { kind: "direct", id: "389224669418618880" },
162+},
163+session: { dmScope: "per-account-channel-peer" },
164+},
165+],
166+};
167+168+expectResolvedRoute(
169+resolveAgentRoute({
170+ cfg,
171+channel: "discord",
172+accountId: "default",
173+peer: { kind: "direct", id: "358611388488351744" },
174+}),
175+{
176+agentId: "main",
177+sessionKey: "agent:main:main",
178+matchedBy: "default",
179+lastRoutePolicy: "main",
180+},
181+);
182+183+expectResolvedRoute(
184+resolveAgentRoute({
185+ cfg,
186+channel: "discord",
187+accountId: "default",
188+peer: { kind: "direct", id: "1497598990336790559" },
189+}),
190+{
191+agentId: "main",
192+sessionKey: "agent:main:discord:default:direct:1497598990336790559",
193+matchedBy: "binding.peer",
194+lastRoutePolicy: "session",
195+},
196+);
197+198+expectResolvedRoute(
199+resolveAgentRoute({
200+ cfg,
201+channel: "discord",
202+accountId: "default",
203+peer: { kind: "direct", id: "389224669418618880" },
204+}),
205+{
206+agentId: "main",
207+sessionKey: "agent:main:discord:default:direct:389224669418618880",
208+matchedBy: "binding.peer",
209+lastRoutePolicy: "session",
210+},
211+);
212+213+expectResolvedRoute(
214+resolveAgentRoute({
215+ cfg,
216+channel: "discord",
217+accountId: "default",
218+peer: { kind: "channel", id: "1494710434396110868" },
219+}),
220+{
221+agentId: "main",
222+sessionKey: "agent:main:discord:channel:1494710434396110868",
223+matchedBy: "default",
224+lastRoutePolicy: "session",
225+},
226+);
227+228+expectResolvedRoute(
229+resolveAgentRoute({
230+ cfg,
231+channel: "webchat",
232+accountId: null,
233+peer: null,
234+}),
235+{
236+agentId: "main",
237+sessionKey: "agent:main:main",
238+matchedBy: "default",
239+lastRoutePolicy: "main",
240+},
241+);
242+});
243+141244test.each([
142245{
143246name: "collapses inbound last-route session keys to main when policy is main",
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。