mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 02:18:25 +00:00
refactor(routing): centralize inbound last-route policy
This commit is contained in:
@@ -30,6 +30,7 @@ describe("discord route resolution helpers", () => {
|
||||
accountId: "default",
|
||||
sessionKey: "agent:main:discord:channel:c1",
|
||||
mainSessionKey: "agent:main:main",
|
||||
lastRoutePolicy: "session",
|
||||
matchedBy: "default",
|
||||
};
|
||||
|
||||
@@ -54,6 +55,7 @@ describe("discord route resolution helpers", () => {
|
||||
accountId: "default",
|
||||
sessionKey: "agent:main:discord:channel:c1",
|
||||
mainSessionKey: "agent:main:main",
|
||||
lastRoutePolicy: "session",
|
||||
matchedBy: "default",
|
||||
};
|
||||
const configuredRoute = {
|
||||
@@ -62,6 +64,7 @@ describe("discord route resolution helpers", () => {
|
||||
agentId: "worker",
|
||||
sessionKey: "agent:worker:discord:channel:c1",
|
||||
mainSessionKey: "agent:worker:main",
|
||||
lastRoutePolicy: "session" as const,
|
||||
matchedBy: "binding.peer" as const,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import type { OpenClawConfig } from "../../config/config.js";
|
||||
import {
|
||||
deriveLastRoutePolicy,
|
||||
resolveAgentRoute,
|
||||
type ResolvedAgentRoute,
|
||||
type RoutePeer,
|
||||
@@ -90,6 +91,10 @@ export function resolveDiscordEffectiveRoute(params: {
|
||||
...params.route,
|
||||
sessionKey: boundSessionKey,
|
||||
agentId: resolveAgentIdFromSessionKey(boundSessionKey),
|
||||
lastRoutePolicy: deriveLastRoutePolicy({
|
||||
sessionKey: boundSessionKey,
|
||||
mainSessionKey: params.route.mainSessionKey,
|
||||
}),
|
||||
...(params.matchedBy ? { matchedBy: params.matchedBy } : {}),
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user