openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
23 lines (22 loc) • 840 B
JavaScript
import { r as sha256HexPrefixCore } from "./node-crypto-B6yuTjmm.mjs";
//#region src/routing/conversation-ref.ts
/** Canonicalizes an adapter target into the peer id used by inbound routing. */
function normalizeConversationPeerId(e, t) {
let n = t.trim();
const r = `${e.trim().toLowerCase()}:`;
if (n.toLowerCase().startsWith(r)) n = n.slice(r.length).trim();
return n.replace(/^(user|channel|group|conversation|room|dm|thread):/i, "").trim();
}
/** Builds an opaque address from canonical transport identity, never from model-session state. */
function buildConversationRef(e) {
return `conv_${sha256HexPrefixCore(JSON.stringify([
e.channel,
e.accountId,
e.kind,
e.peerId,
e.parentConversationRef ?? "",
e.threadId ?? ""
]), 32)}`;
}
//#endregion
export { normalizeConversationPeerId as n, buildConversationRef as t };