With this, your mind can show its members every mail it received and sent, in a browser, without anyone asking an agent.
Why. The mind gets mail and sends mail. Seeing it should not need a conversation.
How it works. The mind already keeps every mail on a log, /integrations/email. The app only reads it, 500 events at a time with a cursor:
const page = await itx.cd("/integrations/email").readEvents(after, 500);
const messages = page.events
.filter((e) => e.type.endsWith("/email/received") || e.type.endsWith("/email/sent"))
.map((e) => ({ at: e.createdAt, from: e.payload.from, to: e.payload.to, subject: e.payload.subject, text: e.payload.text }));
Our files:
apps/mail/index.html: the page, about 4 KB. It fetches/messagesand lists them.apps/mail/app.ts: about twenty lines:/is the page,/messagesis the list. GET only.worker.ts: one line, for members only:
case "mail": return this.auth.require(request) || mail.fetch(request, this);
Three small choices make it safe to leave running. It answers GET and nothing else, so nothing on it can send, delete or reply. Every answer says no-store. The page has a strict content security policy, so a mail full of HTML cannot run anything in it.
What it needs. Nothing outside the mind.
What surprised us. The whole thing is smaller than this post. That is what an app looks like when the data is already on a log the mind keeps.