New: scripts/notify.py — sends via SMTP (notify@marcus-law.co.il → paperclip+chaim@marcus-law.co.il) Updated: HEARTBEAT.md — agents must send email when waiting for human decision Triggers: outcome choice, direction approval, QA failures, review ready. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
54 lines
1.4 KiB
Python
Executable File
54 lines
1.4 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""Send email notification from agents via SMTP.
|
|
|
|
Usage:
|
|
python3 scripts/notify.py "subject" "body"
|
|
python3 scripts/notify.py "subject" --file /path/to/body.md
|
|
"""
|
|
|
|
import smtplib
|
|
import sys
|
|
from email.mime.text import MIMEText
|
|
from email.mime.multipart import MIMEMultipart
|
|
|
|
SMTP_HOST = "smtp.gmail.com"
|
|
SMTP_PORT = 587
|
|
FROM_EMAIL = "notify@marcus-law.co.il"
|
|
FROM_PASS = "vuva jwed lbuz xjds"
|
|
TO_EMAIL = "paperclip+chaim@marcus-law.co.il"
|
|
|
|
|
|
def send(subject: str, body: str) -> bool:
|
|
msg = MIMEMultipart("alternative")
|
|
msg["Subject"] = subject
|
|
msg["From"] = f"עוזר משפטי <{FROM_EMAIL}>"
|
|
msg["To"] = TO_EMAIL
|
|
msg.attach(MIMEText(body, "plain", "utf-8"))
|
|
|
|
try:
|
|
with smtplib.SMTP(SMTP_HOST, SMTP_PORT) as server:
|
|
server.starttls()
|
|
server.login(FROM_EMAIL, FROM_PASS)
|
|
server.sendmail(FROM_EMAIL, TO_EMAIL, msg.as_string())
|
|
return True
|
|
except Exception as e:
|
|
print(f"Email failed: {e}", file=sys.stderr)
|
|
return False
|
|
|
|
|
|
if __name__ == "__main__":
|
|
if len(sys.argv) < 3:
|
|
print("Usage: notify.py 'subject' 'body' OR notify.py 'subject' --file path")
|
|
sys.exit(1)
|
|
|
|
subject = sys.argv[1]
|
|
if sys.argv[2] == "--file":
|
|
body = open(sys.argv[3], encoding="utf-8").read()
|
|
else:
|
|
body = sys.argv[2]
|
|
|
|
if send(subject, body):
|
|
print(f"Sent to {TO_EMAIL}")
|
|
else:
|
|
sys.exit(1)
|