import os, ssl, smtplib, html as H, imaplib, email
from email.header import decode_header
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
from email.utils import formataddr, make_msgid
U, A = [x.strip() for x in open(os.path.expanduser("~/.aura_csi_smtp")).read().split("\n")[:2]]
TO = ["cwbronfman@icloud.com"]; CC = ["bob.carella@auravision.co", "paul.chou@auravision.co"]; BCC=["plchou@gmail.com"]
subj = "Re: Progress write up"
# fetch the original Message-ID for proper threading
irt=None
try:
    M=imaplib.IMAP4_SSL("imap.gmail.com"); M.login(U,A); M.select("INBOX")
    t,d=M.search(None,'(FROM "cwbronfman" SUBJECT "Progress write")')
    for num in d[0].split()[-1:]:
        t,dd=M.fetch(num,"(BODY.PEEK[HEADER.FIELDS (MESSAGE-ID)])")
        irt=email.message_from_bytes(dd[0][1]).get("Message-ID")
    M.logout()
except Exception: pass
body = """Dear Clare,

Here's a concise progress summary you can share with the Trustees — kept strictly to what we can stand behind.

Over the past quarter, AuraVision's thesis — private, on-device AI, where intelligence runs locally and nothing leaves the room — moved from idea to shipping product on three fronts:

  • TONi (UK health). Our clinical intelligence, running on the on-device platform, is in NHS incubation through EDMG — roughly an 18,000-patient footprint under an ~$1M contract. The clearest proof that privacy-first AI belongs exactly where data can't go to the cloud.

  • The Aura Puck. Our consumer device is revealed, with founding reservations live and converting — 146 of the 335 founding places now claimed.

  • ContinuumOS. The AI-first operating system that coordinates every Aura device, keeping context and processing local.

The through-line is simple: in regulated, sensitive settings — health, enterprise, the home — privacy-first AI is moving from "nice to have" to mandatory, and we are among the few shipping it on hardware people own.

If the Trustees would like a deeper briefing on any of these, Paul and Bob can take that directly.

Warmly,
Aura
Chief Super Intelligence (CSI), AuraVision"""
def wrap(t):
    return ("<style>@import url('https://fonts.googleapis.com/css2?family=Chakra+Petch:wght@300;400;500;600&family=Michroma&display=swap');</style>"
            "<div style=\"font-family:'Chakra Petch','Helvetica Neue',Arial,sans-serif;font-size:15px;line-height:1.6;color:#1a1a1a;max-width:640px\">"
            + H.escape(t).replace(chr(10), "<br>\n") + "</div>")
m = MIMEMultipart("alternative"); m["Subject"] = subj; m["From"] = formataddr(("Aura (CSI)", U))
m["To"] = ", ".join(TO); m["Cc"] = ", ".join(CC); m["Reply-To"] = U
if irt: m["In-Reply-To"]=irt; m["References"]=irt
m["Message-ID"] = make_msgid(domain="auravision.co")
m.attach(MIMEText(body, "plain")); m.attach(MIMEText(wrap(body), "html"))
ctx = ssl.create_default_context(); s = smtplib.SMTP("smtp.gmail.com", 587, timeout=60)
s.ehlo(); s.starttls(context=ctx); s.ehlo(); s.login(U, A)
s.sendmail(U, TO + CC + BCC, m.as_string()); s.quit()
print("TRUSTEES WRITE-UP SENT to", TO, "| cc", CC, "| threaded:", bool(irt))
