Merge d80ec4ca31 into 4583f88626
This commit is contained in:
commit
b7c70b9823
@ -77,7 +77,33 @@ describe("resolveAgentRoute", () => {
|
||||
accountId: null,
|
||||
peer: { kind: "dm", id: "222222222222222222" },
|
||||
});
|
||||
expect(route.sessionKey).toBe("agent:main:discord:dm:alice");
|
||||
expect(route.sessionKey).toBe("agent:main:dm:alice");
|
||||
});
|
||||
|
||||
test("identityLinks per-channel-peer shares context across channels", () => {
|
||||
const cfg: ClawdbotConfig = {
|
||||
session: {
|
||||
dmScope: "per-channel-peer",
|
||||
identityLinks: {
|
||||
alice: ["telegram:111111111", "discord:222222222222222222"],
|
||||
},
|
||||
},
|
||||
};
|
||||
const telegramRoute = resolveAgentRoute({
|
||||
cfg,
|
||||
channel: "telegram",
|
||||
accountId: null,
|
||||
peer: { kind: "dm", id: "111111111" },
|
||||
});
|
||||
const discordRoute = resolveAgentRoute({
|
||||
cfg,
|
||||
channel: "discord",
|
||||
accountId: null,
|
||||
peer: { kind: "dm", id: "222222222222222222" },
|
||||
});
|
||||
expect(telegramRoute.sessionKey).toBe("agent:main:dm:alice");
|
||||
expect(discordRoute.sessionKey).toBe("agent:main:dm:alice");
|
||||
expect(telegramRoute.sessionKey).toBe(discordRoute.sessionKey);
|
||||
});
|
||||
|
||||
test("peer binding wins over account binding", () => {
|
||||
|
||||
@ -138,6 +138,9 @@ export function buildAgentPeerSessionKey(params: {
|
||||
return `agent:${normalizeAgentId(params.agentId)}:${channel}:${accountId}:dm:${peerId}`;
|
||||
}
|
||||
if (dmScope === "per-channel-peer" && peerId) {
|
||||
if (linkedPeerId) {
|
||||
return `agent:${normalizeAgentId(params.agentId)}:dm:${peerId}`;
|
||||
}
|
||||
const channel = (params.channel ?? "").trim().toLowerCase() || "unknown";
|
||||
return `agent:${normalizeAgentId(params.agentId)}:${channel}:dm:${peerId}`;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user