qwen_2.5_model / src /core /plugins /handover-gate.ts
Muhammad Noman
Deploy OpenWA to Hugging Face Spaces
46252cd
Raw
History Blame Contribute Delete
696 Bytes
// The core deterministically silences OTHER bots once a plugin has taken a conversation over (human) or
// closed it, while exempting the owning plugin so it (e.g. the Chatwoot relay) keeps mirroring. Scoped by
// session+chat, NOT by pluginId: a handover set by one plugin governs every plugin on that chat.
export function shouldDispatchToPlugin(
handover: { pluginId: string; handoverState: 'bot' | 'human' | 'closed' } | null,
callerPluginId: string,
): boolean {
if (!handover) return true; // no handover row => bot default => dispatch
if (handover.handoverState === 'bot') return true;
return handover.pluginId === callerPluginId; // owner exempt; every other plugin silenced
}