feat: add session.identityLinks for cross-platform DM session linking (#1033)

Co-authored-by: Shadow <shadow@clawd.bot>
This commit is contained in:
Ruby
2026-01-16 14:23:22 -06:00
committed by GitHub
parent 8ffb8cc363
commit 0cd24137e8
10 changed files with 100 additions and 2 deletions

View File

@@ -44,6 +44,42 @@ describe("resolveAgentRoute", () => {
expect(route.sessionKey).toBe("agent:main:whatsapp:dm:+15551234567");
});
test("identityLinks collapses per-peer DM sessions across providers", () => {
const cfg: ClawdbotConfig = {
session: {
dmScope: "per-peer",
identityLinks: {
alice: ["telegram:111111111", "discord:222222222222222222"],
},
},
};
const route = resolveAgentRoute({
cfg,
channel: "telegram",
accountId: null,
peer: { kind: "dm", id: "111111111" },
});
expect(route.sessionKey).toBe("agent:main:dm:alice");
});
test("identityLinks applies to per-channel-peer DM sessions", () => {
const cfg: ClawdbotConfig = {
session: {
dmScope: "per-channel-peer",
identityLinks: {
alice: ["telegram:111111111", "discord:222222222222222222"],
},
},
};
const route = resolveAgentRoute({
cfg,
channel: "discord",
accountId: null,
peer: { kind: "dm", id: "222222222222222222" },
});
expect(route.sessionKey).toBe("agent:main:discord:dm:alice");
});
test("peer binding wins over account binding", () => {
const cfg: ClawdbotConfig = {
bindings: [