Replace QR code display with macOS notification

The daemon should never show interactive QR codes. If auth is needed,
send a macOS notification alerting the user to run /setup, then exit.

Also removes unused qrcode-terminal dependency.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
gavrielc
2026-01-31 19:01:41 +02:00
parent 295c3e620d
commit e1867f8d27
3 changed files with 13 additions and 32 deletions

View File

@@ -17,8 +17,8 @@ import makeWASocket, {
} from '@whiskeysockets/baileys';
import { query } from '@anthropic-ai/claude-agent-sdk';
import pino from 'pino';
import qrcode from 'qrcode-terminal';
import Database from 'better-sqlite3';
import { exec } from 'child_process';
import fs from 'fs';
import path from 'path';
@@ -356,16 +356,16 @@ async function connectWhatsApp(): Promise<void> {
const { connection, lastDisconnect, qr } = update;
if (qr) {
// Only show QR if running interactively (not as a background daemon)
if (process.stdout.isTTY) {
console.log('\nScan this QR code with WhatsApp:\n');
qrcode.generate(qr, { small: true });
console.log('\nWaiting for scan...\n');
} else {
logger.error('WhatsApp authentication required but running non-interactively.');
logger.error('Run "npm run dev" manually to scan the QR code, then restart the service.');
process.exit(1);
}
// Auth needed - notify user and exit
// This shouldn't happen during normal operation; auth is done during setup
const msg = 'WhatsApp authentication required. Run /setup in Claude Code.';
logger.error(msg);
// Send macOS notification so user sees it
exec(`osascript -e 'display notification "${msg}" with title "NanoClaw" sound name "Basso"'`);
// Give notification time to display, then exit
setTimeout(() => process.exit(1), 1000);
}
if (connection === 'close') {