Email/SMTP + iCalendar + OTP for the Cogno stack — stdlib-only delivery with an injectable OTP store (no Redis hard-dep) and host-owned credentials
Project description
cogno-herald
Email/SMTP + iCalendar + OTP for the Cogno stack — the messenger of the ecosystem.
A self-contained communication utility, decoupled from any proprietary infra:
- SMTP — send plain or iCalendar-attached email over stdlib
smtplib(async viaasyncio.to_thread); senders never raise, they return a result dict. - iCalendar — build RFC 5545
.icsinvites (REQUEST) and cancellations (CANCEL) that work with Google/Outlook/Apple Calendar. - OTP — a 6-digit one-time-password flow (generate/store/verify) with bounded
attempts and single-use codes, generated with a CSPRNG (
secrets).
Design
- Zero third-party runtime dependencies. Pure stdlib.
- Host owns infra. SMTP credentials come from the host (tenant override → env);
OTP state rides in an injectable
OTPStoreport (defaultInMemoryOTPStore, plug Redis in a multi-worker host), and delivery rides in an injectableEmailSender— mirroring thecogno-homeoin-memory-default pattern. - No surprises. Senders return
SendResult; nothing raises on a bad recipient or a dead SMTP host.
from cogno_herald import OtpService, InMemoryOTPStore, make_smtp_sender, \
resolve_smtp_config, send_plain_email
smtp = resolve_smtp_config(tenant_config) # or None
sender = make_smtp_sender(send_plain_email, smtp) if smtp else None
otp = OtpService(InMemoryOTPStore(), sender=sender)
await otp.send("user@example.com", tenant_name="Acme")
ok = await otp.verify("user@example.com", code)
resolve_smtp_config reads SMTP_HOST / SMTP_PORT / SMTP_USER / SMTP_PASSWORD /
SMTP_FROM_EMAIL / SMTP_FROM_NAME / SMTP_USE_TLS (tenant config wins over the
environment).
STARTTLS verifies the server certificate. If your relay presents a certificate no public
CA vouches for, point SMTP_TLS_CA_FILE at its CA rather than turning verification off — the
session stays authenticated. SMTP_TLS_VERIFY=false is the last resort (encrypted but
unauthenticated; it logs event=tls_verification_disabled every send). Do not reach for
SMTP_USE_TLS=false for this: that drops encryption entirely, on a session carrying your SMTP
password and every OTP.
See docs/HOST_INTEGRATION.md for the Redis adapter and SMTP wiring, and LOGGING.md for the logging convention.
The Cogno ecosystem
cogno-herald is one organ of Cogno — a family of
small, composable, Apache-2.0 libraries that together form a complete
conversational-agent platform. Each library owns a single concern and stays
infra-agnostic; a host assembles them into a running agent:
The open-source libraries are the organs; the host is the body that joins
them. Our reference host — cogno-host, with its cogno-ui dashboard — is the
private product layer, but it holds no special powers: everything it does rides
on the public seams documented in each library's docs/HOST_INTEGRATION.md, so
you can assemble a body of your own.
Develop
pip install -e ".[dev]"
pytest tests/unit -q
ruff check cogno_herald tests examples
mypy cogno_herald
Apache-2.0.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cogno_herald-0.1.0.tar.gz.
File metadata
- Download URL: cogno_herald-0.1.0.tar.gz
- Upload date:
- Size: 16.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5a1133b65504b255eb4431ee23a0340e1c0b444582a9077a4f00d488dbae2c15
|
|
| MD5 |
923de60e76f3fd63a6f2d0ea164bd1b9
|
|
| BLAKE2b-256 |
15224d17ef3397f1a9d8bf70ef7e6f7641686582511ec868a54a8f119bf03d26
|
File details
Details for the file cogno_herald-0.1.0-py3-none-any.whl.
File metadata
- Download URL: cogno_herald-0.1.0-py3-none-any.whl
- Upload date:
- Size: 17.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5dd1a1d1a8afa9529be23b53ef0f4dc005c391433fddecaa5482b7171cf4def9
|
|
| MD5 |
f93d8d2ebe825b47e6d36093d66a9c46
|
|
| BLAKE2b-256 |
c7c7f5428cea4c46c9202809a6e544a413c19faefb1c3ef403c22f992477b39f
|