Add email notifications: agents send mail when human action needed
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>
This commit is contained in:
@@ -59,7 +59,29 @@ curl -s -X PATCH -H "Authorization: Bearer $PAPERCLIP_API_KEY" \
|
||||
-d '{"status": "done"}'
|
||||
```
|
||||
|
||||
## 5. Release
|
||||
## 5. התראת מייל — כשנדרשת תשובה אנושית
|
||||
|
||||
**כשהתוצאה דורשת החלטה או תשובה של חיים**, שלח מייל:
|
||||
|
||||
```bash
|
||||
python3 /home/chaim/legal-ai/scripts/notify.py \
|
||||
"נדרשת תשובתך — [תיאור קצר]" \
|
||||
"תוכן ההודעה עם סיכום מה נדרש"
|
||||
```
|
||||
|
||||
**מתי לשלוח:**
|
||||
- בקשה לקביעת תוצאה (דחייה/קבלה/חלקית)
|
||||
- בקשה לאישור כיוון נימוק
|
||||
- דוח QA שנכשל (צריך החלטה על תיקונים)
|
||||
- החלטה מוכנה לביקורת דפנה
|
||||
- כל מצב שדורש פעולה אנושית ולא יכול להתקדם לבד
|
||||
|
||||
**מתי לא לשלוח:**
|
||||
- עדכוני סטטוס רגילים
|
||||
- סיום משימה שלא דורשת תגובה
|
||||
- שגיאות טכניות שאפשר לפתור לבד
|
||||
|
||||
## 6. Release
|
||||
|
||||
```bash
|
||||
curl -s -X POST -H "Authorization: Bearer $PAPERCLIP_API_KEY" \
|
||||
|
||||
53
scripts/notify.py
Executable file
53
scripts/notify.py
Executable file
@@ -0,0 +1,53 @@
|
||||
#!/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)
|
||||
Reference in New Issue
Block a user