Repository navigation
Proposal: imap.ts, an IMAP/SMTP mail tool with the same contract as gmail.ts #2931
basjes1977
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
The gap
LIFEOS/TOOLS/gmail.tsis the only mail route in LifeOS, so anyone whose mail lives on a standards server (self-hosted Dovecot, poste.io or Mailcow, Fastmail, a work IMAP account) cannot give their DA a mailbox. I searched issues, PRs and discussions for IMAP, SMTP and himalaya. The only related item is the closed AppleMail PR (#1283).What I built
LIFEOS/TOOLS/Imap/imap.tsgives an IMAP mailbox the gmail.ts verbs and output shapes, and sends through the gmail.ts send contract. Since today it runs against a self-hosted poste.io (Dovecot) mailbox for two agents.It has profile, folders, count, ids, list, fetch/fetchfull/fetchall, body, attach, thread, sent-meta, the flag verbs (read, unread, star, answered), the move verbs (archive, spam, trash, move), drafts (list, get, create, delete, send) and send. There is no permanent delete. Reads use EXAMINE and BODY.PEEK, so reading never marks a message as read.
Search takes a Gmail-like subset (
in:from:subject:since:newer_than:7dis:unreadlarger:2mheader:-term) and compiles it to IMAP SEARCH. An unknown operator is an error.Sending follows gmail.ts step by step:
LIFEOS_NO_OUTBOUNDrefuses the send;parseAddressList, andwithPrincipalCopyadds the principal copy;canonicalSendTextgoes throughSendGate.gatedTransmiton channelimap, so the Proof code tier runs on the exact bytes, and the message is built from the proofed copy only;requireTLSon 587) and then APPENDed to Sent;drafts sendproofs the stored snapshot throughrawSnapshotMetadataandcanonicalDraftText.Each account is a JSON file in
USER/CONFIG/CREDENTIALS/imap/(mode 0600) that names where the password comes from: an env var (falling back to the LifeOS.env), a 0600 file, or a lookup in an MCP password manager. A literal password in the file is refused.The 21 tests need no mail server. They include the send path through the real SendGate, with only the SMTP submit and the APPEND stubbed: a clean message passes, and a body carrying a private key is blocked with
safety-private-keybefore anything is submitted. The tool depends on imapflow, mailparser and nodemailer, pinned to exact versions.What an upstream version would still need
I can do all five.
\bimap\.ts\bnext to\bgmail\.ts\binhooks/lib/texting-guard-core.ts(MAIL_TOOL_RE),LIFEOS/RELAY/bridge/thread.ts(MAIL_READER_RE) and the built-in shapes inhooks/lib/outbound-shapes.ts. My install covers the send shape with a USER overlay row for now.package.jsonso that it survives updates; upstream it belongs inLIFEOS/TOOLS/package.json.MailArchive.tsand the STATVS mail stream, which know only Gmail today.recordSentMailis reused as is, so a sent row is written astool:gmail.Question
Do you want IMAP support in LifeOS? If so, should it be one tool next to gmail.ts, as I built it, or a mail interface that both gmail.ts and imap.ts implement? I will shape the PR to whichever you choose.
Context
LifeOS 8.761.0 · Alpine Linux v3.24 (x64) · claude-code
All reactions