A HiveMind transport over email: store-and-forward mesh links carried by ordinary SMTP/IMAP mailboxes. It ships two clearly separate surfaces in one package, mirroring hivemind-usenet's structure but swapping the carrier for email:
EmailWormhole-- the PROTOCOL surface. ANetworkProtocolthat carries encrypted HiveMind wire-protocol frames (HiveMessageobjects) between two specific nodes. Peer-to-peer, PGP-keyed, and it is NOT natural language: it never "answers" anyone, it just relays the actual HiveMind handshake and bus traffic over email, exactly likeUsenetWormholerouteskind="hive"frames intohm_protocol.handle_message.EmailBridge-- the NATURAL-LANGUAGE surface. Athreading.Threadthat turns a mailbox into an open, public-facing assistant: any email that lands in the inbox is treated as an utterance from its sender, forwarded to the hive, and the spoken reply is emailed back to that sender. By default there is no allowlist -- anyone who emails the bridge gets an answer, the same way anyone can post a question to the usenet bridge's code-word hSub. An optional--allowed-sendersflag turns it into a private assistant if you want that instead.
Do not confuse the two: the wormhole is a protocol transport bound to one peer's PGP key; the bridge is an open NL gateway that talks to everyone who writes in.
A satellite-side client (HiveMindEmailClient) mirrors the HTTP/WS client
API, so the same connect/emit/run/close usage works over the email carrier.
local node <---- EmailCarrier (PGP + hSub subject, SMTP/IMAP) ----> peer node
send an email to the peer's address
poll the mailbox, match hSub, decrypt, reassemble
EmailCarrieris the shared framing layer bothEmailWormholeandEmailBridge's encrypted mode build on. It chunks arbitrary payloads into roughly 8 KB base64 frames, PGP-encrypts each to the peer's key, emails it with the subject stamped bycreate_hsub(peer_secret), and reassembles complete messages by polling a mailbox withmail_monitorover IMAP.- Addressing for the wormhole is hSub (hashed subject) plus a real recipient email address: a shared passphrase per peer, exchanged out of band together with PGP public keys.
- The bridge does not use hSub or PGP for inbound mail -- it answers whatever lands in its inbox in plaintext, because it is meant to be usable by anyone with an email client, not just peers who did a PGP key exchange.
- Confidentiality on the wormhole is PGP: each frame is encrypted to the
peer's public key. Reassembly dedupes on
(message-id, chunk)and rebuilds the payload once all chunks arrive -- identical logic tohivemind-usenet's carrier.
- Python 3.10-3.12. The carrier's PGP crypto (
remailers-> PGPy) imports the standard-libraryimghdrmodule, removed in Python 3.13 (PEP 594). The package is capped>=3.10,<3.13. - A mailbox with IMAP and SMTP access. Any provider works. For Gmail, create an app password -- do not use your normal account password, and enable IMAP access in Gmail settings.
- For the wormhole only: a PGP identity per node (
remailers.Credentialsgenerates one automatically at the configuredkey_pathif missing), plus an out-of-band exchange of an hSub passphrase and the peer's PGP public key with the other node. - For the bridge: nothing beyond the mailbox itself -- it is meant to be reachable by anyone.
pip install hivemind-emailFrom source:
git clone https://github.com/JarbasHiveMind/hivemind-email
cd hivemind-email
pip install -e .Point it at a mailbox and a running hivemind-core hub. Anyone who emails
that mailbox gets an answer from the hive:
hivemind-email-bridge \
--imap-host imap.gmail.com --imap-user assistant@example.com --imap-password "app-password" \
--smtp-host smtp.gmail.com \
--hive-host 127.0.0.1 --hive-key "my-hivemind-api-key"Add --allowed-senders "a@example.com,b@example.com" if you want a private
assistant instead of a public one.
Two nodes that have exchanged passphrases and public keys out of band:
hivemind-email-wormhole \
--my-secret "my-passphrase" \
--peer-secret "their-passphrase" \
--peer-email "peer@example.com" \
--peer-pubkey /path/to/peer.asc \
--imap-host imap.gmail.com --imap-user node-a@example.com --imap-password "app-password" \
--smtp-host smtp.gmail.com--my-secret is the hSub passphrase you read with. --peer-secret is
the one you post with, and the peer reads it. They are the mirror image
on the other node.
from hivemind_email.client import HiveMindEmailClient
client = HiveMindEmailClient(
my_secret="hub-to-client",
hub_secret="client-to-hub",
hub_email="hub@example.com",
hub_pubkey=open("hub.asc").read(),
smtp_host="smtp.gmail.com", smtp_user="me@example.com", smtp_password="app-password",
)
client.connect()
client.start()hSub addressing is shared-secret symmetric: both peers must agree on a
passphrase and exchange PGP public keys out of band before any post. There
is no in-band key exchange. This only applies to EmailWormhole; the
EmailBridge needs no prior exchange since it deliberately talks to
strangers.
cp .env.example .env # fill in mailbox + hive credentials
docker compose up hivemind-email-bridge
# or, for the peer-to-peer transport:
docker compose --profile wormhole up hivemind-email-wormholeSee docker-compose.yml and Dockerfile.
All tests run offline. There is no live mailbox and no network. The carrier's SMTP/IMAP transport is the only thing faked -- chunking, PGP, hSub matching, and reassembly are all real:
uv venv --python 3.12
uv pip install --prerelease=allow -e .[test]
uv run pytest tests/- HiveMind-core: the hub this transport connects to.
- hivemind-usenet: the structural template this package follows, with Usenet instead of email as the carrier.
- mail_monitor: the IMAP polling helper reused for the inbound side.
- remailers: the PGP identity and hSub-subject layer reused for the encrypted transport framing.
Apache-2.0