#!/usr/bin/env node
// Wipe the WhatsApp Baileys session so the bridge offers a fresh pairing QR.
// Resolves the session dir from lib/paths.js so it honours $MADARX_HOME /
// MADARX_DATA_DIR (global installs live under ~/.madarx, not the repo cwd).
import fs from 'node:fs';
import { WHATSAPP_SESSION_DIR } from '../lib/paths.js';

try {
  fs.rmSync(WHATSAPP_SESSION_DIR, { recursive: true, force: true });
  console.log('[whatsapp:reset] wiped', WHATSAPP_SESSION_DIR);
  console.log('[whatsapp:reset] restart madarx (or the WhatsApp bridge) to generate a fresh pairing QR.');
} catch (err) {
  console.error('[whatsapp:reset] failed to wipe', WHATSAPP_SESSION_DIR, '—', err.message);
  process.exit(1);
}
