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

@@ -70,6 +70,7 @@ export function buildAgentSessionKey(params: {
peer?: RoutePeer | null;
/** DM session scope. */
dmScope?: "main" | "per-peer" | "per-channel-peer";
identityLinks?: Record<string, string[]>;
}): string {
const channel = normalizeToken(params.channel) || "unknown";
const peer = params.peer;
@@ -80,6 +81,7 @@ export function buildAgentSessionKey(params: {
peerKind: peer?.kind ?? "dm",
peerId: peer ? normalizeId(peer.id) || "unknown" : null,
dmScope: params.dmScope,
identityLinks: params.identityLinks,
});
}
@@ -153,6 +155,7 @@ export function resolveAgentRoute(input: ResolveAgentRouteInput): ResolvedAgentR
});
const dmScope = input.cfg.session?.dmScope ?? "main";
const identityLinks = input.cfg.session?.identityLinks;
const choose = (agentId: string, matchedBy: ResolvedAgentRoute["matchedBy"]) => {
const resolvedAgentId = pickFirstExistingAgentId(input.cfg, agentId);
@@ -165,6 +168,7 @@ export function resolveAgentRoute(input: ResolveAgentRouteInput): ResolvedAgentR
channel,
peer,
dmScope,
identityLinks,
}),
mainSessionKey: buildAgentMainSessionKey({
agentId: resolvedAgentId,