From fb712295fe9c720b616fa117ca948ed7b8b85bc9 Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 22 Nov 2024 12:05:12 -0800 Subject: [PATCH] add emit to agent --- packages/server/agents/src/lib/Agent.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) 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) + }) } }