diff --git a/packages/server/agents/src/lib/Agent.ts b/packages/server/agents/src/lib/Agent.ts index 399e4e771..02695cd26 100644 --- a/packages/server/agents/src/lib/Agent.ts +++ b/packages/server/agents/src/lib/Agent.ts @@ -96,18 +96,23 @@ type ChannelEvents = { class Channel extends (EventEmitter as new () => TypedEmitter) { constructor(private channelId: string, private agent: Agent) { super() - this.agent = agent } emit( event: K, data: Parameters[0] ): boolean { - const eventData = { + return super.emit(event, ...([data] as Parameters)) + } + + emitToAgent( + event: K, + data: Parameters[0] + ): boolean { + return this.agent.emit(event, { ...data, channel: this.channelId, - } - return this.agent.emit(event, eventData) + }) } }