From beec04946295df3d26b1fefc6140008d8655850a Mon Sep 17 00:00:00 2001 From: root Date: Thu, 9 Oct 2025 07:34:12 +0200 Subject: [PATCH] Add automatic notifications for incoming messages MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - ReceiveMessagesTool now logs notifications when messages arrive - Console output shows: from, subject, and message preview - Automatic real-time alerts via NATS subscription - Enables passive message monitoring without polling šŸ¤– Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- src/tools/builtin/messaging.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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();