()
| 25 | } |
| 26 | |
| 27 | async function main() { |
| 28 | console.log('Running identifyBotSuspects…') |
| 29 | const report = await identifyBotSuspects({ logger }) |
| 30 | |
| 31 | const { subject, message } = formatSweepReport(report) |
| 32 | console.log('\n--- SUBJECT ---') |
| 33 | console.log(subject) |
| 34 | console.log('\n--- RULE-BASED BODY ---') |
| 35 | console.log(message) |
| 36 | |
| 37 | console.log('\nRunning agent review (Claude Sonnet 4.6)…') |
| 38 | const agentReview = await reviewSuspects({ report, logger }) |
| 39 | if (agentReview) { |
| 40 | console.log('\n--- AGENT REVIEW ---') |
| 41 | console.log(agentReview) |
| 42 | } else { |
| 43 | console.log('(agent review returned null — falling back to rule-only)') |
| 44 | } |
| 45 | console.log('\n--- END ---') |
| 46 | |
| 47 | const fullMessage = agentReview |
| 48 | ? `=== AGENT REVIEW (Claude Sonnet 4.6) ===\n\n${agentReview}\n\n=== RAW RULE-BASED DATA ===\n\n${message}` |
| 49 | : message |
| 50 | |
| 51 | console.log(`\nSending email to ${RECIPIENT}…`) |
| 52 | const result = await sendBasicEmail({ |
| 53 | email: RECIPIENT, |
| 54 | data: { subject, message: fullMessage }, |
| 55 | logger, |
| 56 | }) |
| 57 | |
| 58 | if (result.success) { |
| 59 | console.log(`✅ Email sent (loopsId=${result.loopsId ?? 'n/a'})`) |
| 60 | } else { |
| 61 | console.error(`❌ Email failed: ${result.error}`) |
| 62 | process.exit(1) |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | main() |
| 67 | .then(() => process.exit(0)) |
no test coverage detected