UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

37 lines (36 loc) 2.16 kB
import { c as normalizeOptionalString } from "./string-coerce-mnp54Vah.js"; import { v as resolveSessionAgentId } from "./agent-scope-MrLta7Pq.js"; import { t as normalizeChatType } from "./chat-type-CxEvM45e.js"; //#region src/infra/outbound/session-context.ts /** Builds the outbound delivery session context, omitting empty policy fields. */ function buildOutboundSessionContext(params) { const key = normalizeOptionalString(params.sessionKey); const policyKey = normalizeOptionalString(params.policySessionKey); const normalizedChatType = normalizeChatType(params.conversationType ?? void 0); const conversationType = normalizedChatType === "group" || normalizedChatType === "channel" ? "group" : normalizedChatType === "direct" ? "direct" : params.isGroup === true ? "group" : params.isGroup === false ? "direct" : void 0; const explicitAgentId = normalizeOptionalString(params.agentId); const requesterAccountId = normalizeOptionalString(params.requesterAccountId); const requesterSenderId = normalizeOptionalString(params.requesterSenderId); const requesterSenderName = normalizeOptionalString(params.requesterSenderName); const requesterSenderUsername = normalizeOptionalString(params.requesterSenderUsername); const requesterSenderE164 = normalizeOptionalString(params.requesterSenderE164); const derivedAgentId = key ? resolveSessionAgentId({ sessionKey: key, config: params.cfg }) : void 0; const agentId = explicitAgentId ?? derivedAgentId; if (!key && !policyKey && !conversationType && !agentId && !requesterAccountId && !requesterSenderId && !requesterSenderName && !requesterSenderUsername && !requesterSenderE164) return; return { ...key ? { key } : {}, ...policyKey ? { policyKey } : {}, ...conversationType ? { conversationType } : {}, ...agentId ? { agentId } : {}, ...requesterAccountId ? { requesterAccountId } : {}, ...requesterSenderId ? { requesterSenderId } : {}, ...requesterSenderName ? { requesterSenderName } : {}, ...requesterSenderUsername ? { requesterSenderUsername } : {}, ...requesterSenderE164 ? { requesterSenderE164 } : {} }; } //#endregion export { buildOutboundSessionContext as t };