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:
19
package-lock.json
generated
19
package-lock.json
generated
@@ -12,13 +12,11 @@
|
|||||||
"@whiskeysockets/baileys": "^7.0.0-rc.9",
|
"@whiskeysockets/baileys": "^7.0.0-rc.9",
|
||||||
"better-sqlite3": "^11.8.1",
|
"better-sqlite3": "^11.8.1",
|
||||||
"pino": "^9.6.0",
|
"pino": "^9.6.0",
|
||||||
"pino-pretty": "^13.0.0",
|
"pino-pretty": "^13.0.0"
|
||||||
"qrcode-terminal": "^0.12.0"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/better-sqlite3": "^7.6.12",
|
"@types/better-sqlite3": "^7.6.12",
|
||||||
"@types/node": "^22.10.0",
|
"@types/node": "^22.10.0",
|
||||||
"@types/qrcode-terminal": "^0.12.2",
|
|
||||||
"tsx": "^4.19.0",
|
"tsx": "^4.19.0",
|
||||||
"typescript": "^5.7.0"
|
"typescript": "^5.7.0"
|
||||||
},
|
},
|
||||||
@@ -1177,13 +1175,6 @@
|
|||||||
"undici-types": "~6.21.0"
|
"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": {
|
"node_modules/@whiskeysockets/baileys": {
|
||||||
"version": "7.0.0-rc.9",
|
"version": "7.0.0-rc.9",
|
||||||
"resolved": "https://registry.npmjs.org/@whiskeysockets/baileys/-/baileys-7.0.0-rc.9.tgz",
|
"resolved": "https://registry.npmjs.org/@whiskeysockets/baileys/-/baileys-7.0.0-rc.9.tgz",
|
||||||
@@ -1989,14 +1980,6 @@
|
|||||||
"node": ">=20"
|
"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": {
|
"node_modules/quick-format-unescaped": {
|
||||||
"version": "4.0.4",
|
"version": "4.0.4",
|
||||||
"resolved": "https://registry.npmjs.org/quick-format-unescaped/-/quick-format-unescaped-4.0.4.tgz",
|
"resolved": "https://registry.npmjs.org/quick-format-unescaped/-/quick-format-unescaped-4.0.4.tgz",
|
||||||
|
|||||||
@@ -16,13 +16,11 @@
|
|||||||
"@whiskeysockets/baileys": "^7.0.0-rc.9",
|
"@whiskeysockets/baileys": "^7.0.0-rc.9",
|
||||||
"better-sqlite3": "^11.8.1",
|
"better-sqlite3": "^11.8.1",
|
||||||
"pino": "^9.6.0",
|
"pino": "^9.6.0",
|
||||||
"pino-pretty": "^13.0.0",
|
"pino-pretty": "^13.0.0"
|
||||||
"qrcode-terminal": "^0.12.0"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/better-sqlite3": "^7.6.12",
|
"@types/better-sqlite3": "^7.6.12",
|
||||||
"@types/node": "^22.10.0",
|
"@types/node": "^22.10.0",
|
||||||
"@types/qrcode-terminal": "^0.12.2",
|
|
||||||
"tsx": "^4.19.0",
|
"tsx": "^4.19.0",
|
||||||
"typescript": "^5.7.0"
|
"typescript": "^5.7.0"
|
||||||
},
|
},
|
||||||
|
|||||||
22
src/index.ts
22
src/index.ts
@@ -17,8 +17,8 @@ import makeWASocket, {
|
|||||||
} from '@whiskeysockets/baileys';
|
} from '@whiskeysockets/baileys';
|
||||||
import { query } from '@anthropic-ai/claude-agent-sdk';
|
import { query } from '@anthropic-ai/claude-agent-sdk';
|
||||||
import pino from 'pino';
|
import pino from 'pino';
|
||||||
import qrcode from 'qrcode-terminal';
|
|
||||||
import Database from 'better-sqlite3';
|
import Database from 'better-sqlite3';
|
||||||
|
import { exec } from 'child_process';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
|
||||||
@@ -356,16 +356,16 @@ async function connectWhatsApp(): Promise<void> {
|
|||||||
const { connection, lastDisconnect, qr } = update;
|
const { connection, lastDisconnect, qr } = update;
|
||||||
|
|
||||||
if (qr) {
|
if (qr) {
|
||||||
// Only show QR if running interactively (not as a background daemon)
|
// Auth needed - notify user and exit
|
||||||
if (process.stdout.isTTY) {
|
// This shouldn't happen during normal operation; auth is done during setup
|
||||||
console.log('\nScan this QR code with WhatsApp:\n');
|
const msg = 'WhatsApp authentication required. Run /setup in Claude Code.';
|
||||||
qrcode.generate(qr, { small: true });
|
logger.error(msg);
|
||||||
console.log('\nWaiting for scan...\n');
|
|
||||||
} else {
|
// Send macOS notification so user sees it
|
||||||
logger.error('WhatsApp authentication required but running non-interactively.');
|
exec(`osascript -e 'display notification "${msg}" with title "NanoClaw" sound name "Basso"'`);
|
||||||
logger.error('Run "npm run dev" manually to scan the QR code, then restart the service.');
|
|
||||||
process.exit(1);
|
// Give notification time to display, then exit
|
||||||
}
|
setTimeout(() => process.exit(1), 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (connection === 'close') {
|
if (connection === 'close') {
|
||||||
|
|||||||
Reference in New Issue
Block a user