diff --git a/package-lock.json b/package-lock.json index c46f756..7517f7b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,13 +12,11 @@ "@whiskeysockets/baileys": "^7.0.0-rc.9", "better-sqlite3": "^11.8.1", "pino": "^9.6.0", - "pino-pretty": "^13.0.0", - "qrcode-terminal": "^0.12.0" + "pino-pretty": "^13.0.0" }, "devDependencies": { "@types/better-sqlite3": "^7.6.12", "@types/node": "^22.10.0", - "@types/qrcode-terminal": "^0.12.2", "tsx": "^4.19.0", "typescript": "^5.7.0" }, @@ -1177,13 +1175,6 @@ "undici-types": "~6.21.0" } }, - "node_modules/@types/qrcode-terminal": { - "version": "0.12.2", - "resolved": "https://registry.npmjs.org/@types/qrcode-terminal/-/qrcode-terminal-0.12.2.tgz", - "integrity": "sha512-v+RcIEJ+Uhd6ygSQ0u5YYY7ZM+la7GgPbs0V/7l/kFs2uO4S8BcIUEMoP7za4DNIqNnUD5npf0A/7kBhrCKG5Q==", - "dev": true, - "license": "MIT" - }, "node_modules/@whiskeysockets/baileys": { "version": "7.0.0-rc.9", "resolved": "https://registry.npmjs.org/@whiskeysockets/baileys/-/baileys-7.0.0-rc.9.tgz", @@ -1989,14 +1980,6 @@ "node": ">=20" } }, - "node_modules/qrcode-terminal": { - "version": "0.12.0", - "resolved": "https://registry.npmjs.org/qrcode-terminal/-/qrcode-terminal-0.12.0.tgz", - "integrity": "sha512-EXtzRZmC+YGmGlDFbXKxQiMZNwCLEO6BANKXG4iCtSIM0yqc/pappSx3RIKr4r0uh5JsBckOXeKrB3Iz7mdQpQ==", - "bin": { - "qrcode-terminal": "bin/qrcode-terminal.js" - } - }, "node_modules/quick-format-unescaped": { "version": "4.0.4", "resolved": "https://registry.npmjs.org/quick-format-unescaped/-/quick-format-unescaped-4.0.4.tgz", diff --git a/package.json b/package.json index bcaec1b..c9309a9 100644 --- a/package.json +++ b/package.json @@ -16,13 +16,11 @@ "@whiskeysockets/baileys": "^7.0.0-rc.9", "better-sqlite3": "^11.8.1", "pino": "^9.6.0", - "pino-pretty": "^13.0.0", - "qrcode-terminal": "^0.12.0" + "pino-pretty": "^13.0.0" }, "devDependencies": { "@types/better-sqlite3": "^7.6.12", "@types/node": "^22.10.0", - "@types/qrcode-terminal": "^0.12.2", "tsx": "^4.19.0", "typescript": "^5.7.0" }, diff --git a/src/index.ts b/src/index.ts index 4b01093..c367839 100644 --- a/src/index.ts +++ b/src/index.ts @@ -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 { 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') {