import type { SuperagentChannelStatus } from '../../types'; export function isChannelResultForActiveAgent( requestedAgentId: string, activeAgentId: string | null, ): boolean { return requestedAgentId === activeAgentId; } // Local channel mutations are authoritative over any status request that began // before them. Activation codes are also client-held until the server connects. export function mergeLoadedChannelStatus( current: SuperagentChannelStatus, loaded: SuperagentChannelStatus, overlaps: { slack: boolean; telegram: boolean; whatsapp: boolean }, ): SuperagentChannelStatus { return { ...loaded, imessage: { ...loaded.imessage, activation: current.imessage?.activation ?? loaded.imessage?.activation, }, line: { ...loaded.line, activation: current.line?.activation ?? loaded.line?.activation, }, slack: overlaps.slack ? current.slack : (loaded.slack ?? current.slack), telegram: overlaps.telegram ? current.telegram : loaded.telegram, whatsapp: overlaps.whatsapp ? current.whatsapp : (loaded.whatsapp ?? current.whatsapp), }; }