UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

34 lines (33 loc) 1.74 kB
import { r as normalizeOptionalAccountId } from "./account-id-CETVCrTz.js"; import { a as resolveMessageChannel } from "./message-channel-normalize-B81s0XMO.js"; import "./message-channel-BQrhwUEA.js"; import { f as stringifyRouteThreadId } from "./channel-route--2in3Ckg.js"; //#region src/agents/command/run-context.ts /** * Resolves channel/account/thread run context for agent command execution. */ /** Merges explicit run context with command routing options. */ function resolveAgentRunContext(opts) { const merged = opts.runContext ? { ...opts.runContext } : {}; const normalizedChannel = resolveMessageChannel(merged.messageChannel ?? opts.messageChannel, opts.replyChannel ?? opts.channel); if (normalizedChannel) merged.messageChannel = normalizedChannel; const normalizedAccountId = normalizeOptionalAccountId(merged.accountId ?? opts.accountId); if (normalizedAccountId) merged.accountId = normalizedAccountId; const groupId = (merged.groupId ?? opts.groupId)?.toString().trim(); if (groupId) merged.groupId = groupId; const groupChannel = (merged.groupChannel ?? opts.groupChannel)?.toString().trim(); if (groupChannel) merged.groupChannel = groupChannel; const groupSpace = (merged.groupSpace ?? opts.groupSpace)?.toString().trim(); if (groupSpace) merged.groupSpace = groupSpace; if (merged.currentThreadTs == null && opts.threadId != null && opts.threadId !== "" && opts.threadId !== null) { const threadId = stringifyRouteThreadId(opts.threadId); if (threadId) merged.currentThreadTs = threadId; } if (!merged.currentChannelId && opts.to) { const trimmedTo = opts.to.trim(); if (trimmedTo) merged.currentChannelId = trimmedTo; } return merged; } //#endregion export { resolveAgentRunContext as t };