openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
2 lines • 766 B
JavaScript
//!src/plugin-sdk/inbound-event-delivery.ts
function resolveInboundEventDeliveryCorrelationKey(e,t){const n=e?.trim();if(!n)return;return t===`room_event`?`${n}:room_event`:n}function createInboundEventDeliveryCorrelation(e){const t=/* @__PURE__ */ new Map;return{begin(e,n,r){const i=resolveInboundEventDeliveryCorrelationKey(e,r?.inboundEventKind);if(!i)return()=>{};t.set(i,n);return()=>{if(t.get(i)===n)t.delete(i)}},notify(n){const r=resolveInboundEventDeliveryCorrelationKey(n.sessionKey,n.inboundEventKind);if(!r)return;const i=t.get(r);if(!i||!e.targetsMatch(i.outboundTo,n.to))return;if(i.outboundAccountId&&n.accountId&&n.accountId!==i.outboundAccountId)return;t.delete(r);i.markInboundEventDelivered()}}}export{createInboundEventDeliveryCorrelation as t};