diff --git a/package.json b/package.json index f87b5d62c..8af97b0eb 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ "dev:server": "nx serve @magickml/server", "bucket:init": "ts-node ./scripts/init-bucket.ts", "build-release": "nx run-many --target=build --parallel=20 --projects=tag:release", + "build-release:watch": "nx run-many --target=build --parallel=20 --projects=tag:release --watch", "build-client": "npx nx build @magickml/client", "build-cloud-agent-manager": "npm run generateClients && npx nx build @magickml/cloud-agent-manager-app", "build-cloud-agent-worker": "npm run generateClients && npx nx build @magickml/cloud-agent-worker-app", diff --git a/packages/server/agents/src/lib/Agent.ts b/packages/server/agents/src/lib/Agent.ts index 02695cd26..e9b9da0da 100644 --- a/packages/server/agents/src/lib/Agent.ts +++ b/packages/server/agents/src/lib/Agent.ts @@ -96,12 +96,14 @@ type ChannelEvents = { class Channel extends (EventEmitter as new () => TypedEmitter) { constructor(private channelId: string, private agent: Agent) { super() + console.log(`Channel ${channelId} constructed`) } emit( event: K, data: Parameters[0] ): boolean { + console.log(`Channel ${this.channelId} emitting ${event}:`, data) return super.emit(event, ...([data] as Parameters)) } @@ -109,11 +111,20 @@ class Channel extends (EventEmitter as new () => TypedEmitter) { event: K, data: Parameters[0] ): boolean { + console.log(`Channel ${this.channelId} emitting to agent ${event}:`, data) return this.agent.emit(event, { ...data, channel: this.channelId, }) } + + on( + event: K, + listener: ChannelEvents[K] + ): this { + console.log(`Channel ${this.channelId} adding listener for ${event}`) + return super.on(event, listener) + } } const plugins = [CorePlugin, KnowledgePlugin, DiscordPlugin, SlackPlugin] @@ -204,17 +215,21 @@ export class Agent this.logger.info('New agent created: %s | %s', this.name, this.id) - // Set up global event routing to channels + // Set up global event routing to channels with debug logging this.on('messageReceived', (data: ActionPayload) => { + console.log('Agent received messageReceived event:', data) const channelId = (data as any)?.channel if (channelId && this.channels.has(channelId)) { + console.log(`Forwarding messageReceived to channel ${channelId}`) this.channels.get(channelId)!.emit('messageReceived', data) } }) this.on('message', (data: EventPayload) => { + console.log('Agent received message event:', data) const channelId = (data as any)?.channel if (channelId && this.channels.has(channelId)) { + console.log(`Forwarding message to channel ${channelId}`) this.channels.get(channelId)!.emit('message', data) } }) @@ -527,7 +542,9 @@ export class Agent // Add channel method to get/create channel instance channel(channelId: string): Channel { + console.log(`Getting/creating channel for ${channelId}`) if (!this.channels.has(channelId)) { + console.log(`Creating new channel for ${channelId}`) const channel = new Channel(channelId, this) this.channels.set(channelId, channel) } diff --git a/portal/cloud b/portal/cloud index c739a7550..6697b5a06 160000 --- a/portal/cloud +++ b/portal/cloud @@ -1 +1 @@ -Subproject commit c739a755084d73462816cc0247058d77109ae57f +Subproject commit 6697b5a06edbea8d1ce459e21114b143d9005608