"""EventEmitter — async queue adapter (mirrors the established agent-mesh pattern). Agent session handlers call ``self.ws.send_json(data)`` expecting a WebSocket-like interface. This adapter puts each message into an ``asyncio.Queue`` so the Redis Stream worker can consume them one by one and publish to the per-task response channel. """ import asyncio class EventEmitter: """WebSocket-compatible adapter backed by an asyncio.Queue.""" def __init__(self): self.queue: asyncio.Queue = asyncio.Queue() self._done = False async def accept(self): pass async def send_json(self, data: dict): """Called by session handlers via ``self.push()``.""" await self.queue.put(data) async def receive_json(self): raise StopIteration("EventEmitter does not support receive") def query_params(self): return {} def mark_done(self): """Signal that the session handler has finished.""" self._done = True self.queue.put_nowait(None)