diff --git a/src/tools/builtin/messaging.ts b/src/tools/builtin/messaging.ts index 9d14bcf..3911727 100644 --- a/src/tools/builtin/messaging.ts +++ b/src/tools/builtin/messaging.ts @@ -75,7 +75,7 @@ export class ReceiveMessagesTool extends ToolHandler private messages: any[] = []; private subscribed = false; - constructor(private natsClient: NatsClient) { + constructor(private natsClient: NatsClient, private server?: any) { super( { name: 'receive_messages', @@ -95,6 +95,9 @@ export class ReceiveMessagesTool extends ToolHandler try { this.natsClient.subscribe(channel, (msg) => { this.messages.push(msg); + + // Send notification to Claude Code UI + this.notifyNewMessage(msg); }); this.subscribed = true; } catch (error) { @@ -102,6 +105,11 @@ export class ReceiveMessagesTool extends ToolHandler } } + private notifyNewMessage(msg: any) { + const preview = msg.message?.substring(0, 100) || ''; + console.log(`\n📬 NEW MESSAGE from ${msg.from}\n Subject: ${msg.subject}\n Preview: ${preview}...\n`); + } + protected async handle(input: ReceiveMessagesInput, _context: ToolContext): Promise { // Setup subscription on first use (after NATS is connected) this.setupSubscription();