# Phase 81.19.b — out-of-tree standalone repo.
#
# Built as a binary subprocess plugin loaded by the nexo-rs daemon
# via discovery + auto-subprocess fallback (Phase 81.17 + 81.17.b).
# The daemon spawns this binary, JSON-RPC handshakes over stdio,
# and routes inbound mail / outbound commands through the
# `plugin.inbound.email.<account_alias>` and
# `plugin.outbound.email.<account_alias>` broker topics.
#
# Path-deps to `../proyecto/crates/...` are interim — they ship
# this repo today before nexo-microapp-sdk + nexo-config + the
# rest publish to crates.io. Operators outside the monorepo build
# the binary against published crates.io versions; the
# `Cargo.lock` (committed; binary repo convention) pins the
# resolved versions for reproducibility.
#
# Unlike telegram / whatsapp, this plugin runs ONE subprocess that
# manages N internal accounts via `EmailPluginConfig.accounts`.
# Multi-instance spawning is NOT used — the inbound/outbound topics
# carry the per-account alias directly.

[package]
name        = "nexo-plugin-email"
version     = "0.5.0"
description = "Email (IMAP/SMTP) channel plugin for Nexo agents (out-of-tree subprocess)."
edition     = "2021"
license     = "MIT OR Apache-2.0"
repository  = "https://github.com/lordmacu/nexo-plugin-email"
authors     = ["Cristian García <informacion@cristiangarcia.co>"]
readme      = "README.md"
keywords    = ["nexo", "plugin", "email", "imap", "smtp"]
categories  = ["api-bindings", "email"]
rust-version = "1.80"

[lib]
name = "nexo_plugin_email"
path = "src/lib.rs"

[[bin]]
name = "nexo-plugin-email"
path = "src/main.rs"

[features]
default = []
# Phase 90 — mobile embedded consumer drops the subprocess loop and
# re-uses `EmailPlugin` directly through the lib surface.
embedded = []

[dependencies]
# Async / runtime
tokio        = { version = "1", features = ["rt-multi-thread", "macros", "sync", "io-util", "time", "process", "net"] }
tokio-util   = { version = "0.7", features = ["compat", "io"] }
async-trait  = "0.1"
futures      = "0.3"

# Serde / encoding
serde        = { version = "1", features = ["derive"] }
serde_json   = "1"
serde_yaml   = "0.9"
serde_bytes  = "0.11"
toml         = "0.8"
base64       = "0.22"
hex          = "0.4"

# Tracing / errors / id
anyhow       = "1"
thiserror    = "1"
tracing      = "0.1"
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
uuid         = { version = "1", features = ["v4", "v5", "serde"] }
once_cell    = "1"
chrono       = { version = "0.4", default-features = false, features = ["clock", "serde"] }
dashmap      = "6"

# Storage
sqlx         = { version = "0.8", default-features = false, features = ["runtime-tokio-rustls", "sqlite", "macros", "chrono", "uuid"] }
rand         = "0.8"

# Mail protocols
async-imap   = "0.10"
lettre       = { version = "0.11", default-features = false, features = ["tokio1-rustls-tls", "smtp-transport", "builder"] }
mail-parser  = "0.9"
mail-builder = "0.4"
html2text    = "0.13"
chardetng    = "0.1"
mime_guess   = "2"
encoding_rs  = "0.8"
hickory-resolver = "0.24"
sha2         = "0.10"

# TLS — pin the rustls CryptoProvider to `ring`. Without
# `default-features = false`, rustls 0.23's defaults pull in
# `aws_lc_rs` (and `prefer-post-quantum` which forwards to
# `aws_lc_rs`). aws-lc-rs ships its own bundled BoringSSL +
# jitterentropy C source — fine on glibc/musl/macOS/MSVC where
# Zig CC's bundled libc has the headers, but on Android NDK
# (`aarch64-linux-android`) the jitterentropy library hits
# `fatal error: 'sys/types.h' file not found` because the
# Bionic libc layout differs from POSIX in subtle ways the
# bundled C source assumes.
#
# Pinning `ring` (pure-Rust + asm crypto, no C build chain)
# eliminates the issue entirely. See Phase 27.2-follow-up.b
# (Termux / Android cross-compile) in the proyecto FOLLOWUPS.md.
rustls              = { version = "0.23", default-features = false, features = ["ring", "std", "tls12", "logging"] }
tokio-rustls        = { version = "0.26", default-features = false, features = ["ring", "tls12", "logging"] }
rustls-native-certs = "0.7"

# Misc
secrecy      = "0.8"
socket2      = "0.5"

# Path-deps interim until the rest of the proyecto crates publish to
# crates.io. Mirrors the layout used by the standalone telegram /
# whatsapp plugins.
nexo-microapp-sdk    = { version = "0.1.17", path = "../proyecto/crates/microapp-sdk", features = ["plugin"] }
nexo-broker          = { version = "0.1.4",  path = "../proyecto/crates/broker" }
nexo-core            = { version = "0.1.2",  path = "../proyecto/crates/core" }
nexo-config          = { version = "0.1.8",  path = "../proyecto/crates/config" }
nexo-llm             = { version = "0.1.3",  path = "../proyecto/crates/llm" }
nexo-auth            = { version = "0.1.5",  path = "../proyecto/crates/auth" }
nexo-resilience      = { version = "0.1.1",  path = "../proyecto/crates/resilience" }
nexo-plugin-manifest = { version = "0.1.5",  path = "../proyecto/crates/plugin-manifest" }

[dev-dependencies]
serde_yaml  = "0.9"
tempfile    = "3"
serial_test = "3"
tokio       = { version = "1", features = ["test-util", "macros", "rt-multi-thread"] }

[profile.release]
lto             = "thin"
codegen-units   = 1
strip           = "symbols"

# Mirror the proyecto workspace `[workspace.lints.clippy]` allow-list.
[lints.clippy]
doc_overindented_list_items = "allow"
doc_lazy_continuation       = "allow"
incompatible_msrv           = "allow"
