Skip to main content

Crate mail4agent_client

Crate mail4agent_client 

Source
Expand description

HTTP client for a running mail4agent daemon.

Covers the public mailbox surface the daemon exposes over loopback HTTP: GET /health (no auth) and the bearer-gated POST /mail/* plus operator POST /admin/* routes. Wire types for mail transport come from mail4agent_api; admin / whoami / status display shapes that live only in the daemon are mirrored here so a caller never needs to depend on the binary crate.

Sender is never a field. Every /mail/* call authenticates with the bearer this client was constructed with; the daemon derives from from that credential plus kernel session attestation on the TCP peer. See mail4agent README / CLAUDE.md (“The rule that defines this service”).

A host application consumes this crate as a dependency — the harness holds no mailbox of its own (extraction plan mailbox-service-extraction-and-signed-session-identity-2026-09-16.md).

Structs§

HealthReport
Rich liveness payload from GET /health (unauthenticated).
MailAckRequest
Re-export common wire types so hosts can use mail4agent_client::*. Requests an acknowledgement be recorded for message_id, on behalf of whoever the presented credential authenticated as (same discipline as SendRequest: no reader field to fill in).
MailClient
Async HTTP client bound to one mailbox base URL and one bearer credential.
MailClientBuilder
Builder for MailClient.
MailDirectory
Re-export common wire types so hosts can use mail4agent_client::*. Answers a directory request: every participant the mailbox has registered and every room it tracks, from the point of view of whoever asked (see RoomEntry::member). The whole mailbox’s population in one call, deliberately unpaginated – this is a small, local directory, not a social graph (mail4agent/CLAUDE.md).
MailInboxRequest
Re-export common wire types so hosts can use mail4agent_client::*. Requests a page of the caller’s inbox. limit defaults to INBOX_LIMIT_DEFAULT when a caller’s JSON omits it, and is bounded by INBOX_LIMIT_MAX.
MailMessageId
Re-export common wire types so hosts can use mail4agent_client::*. Opaque, prefixed, fixed-width hex id for a stored Message. Ported from HarnessMailMessageId (prefix hmail_ there, m4a_ here so a value can never be mistaken for a harness message id from the crate this was ported out of).
MailParticipantId
Re-export common wire types so hosts can use mail4agent_client::*. Addresses one participant directly. Distinct from RoomId on purpose: a room id must never be accepted where a participant id is meant, and a shared alias would let one slip into the other’s slot.
MailRoomId
Re-export common wire types so hosts can use mail4agent_client::*. Addresses a named group of participants the mailbox itself tracks. Distinct from ParticipantId on purpose (see there).
MailSendRequest
Re-export common wire types so hosts can use mail4agent_client::*. Requests a send. Has no from field and must never grow one. The sender is whoever the presented credential authenticated as; the mailbox derives from from the verified identity, never from a field the caller filled in.
MailSendResponse
Re-export common wire types so hosts can use mail4agent_client::*. Answers a SendRequest. Returns the caller its own address so a participant that just wrote immediately knows where it can be answered.
ParticipantIdRequest
Body for admin routes that take only a participant id.
RegisterParticipantRequest
Body for POST /admin/participant.
RoomIdRequest
Body for POST /admin/room.
RoomMemberRequest
Body for room membership add/remove.
SecretResponse
Answers POST /admin/participant / …/rotate — secret returned once.
StatusResponse
Answers POST /mail/status (daemon dto::StatusResponse).
WhoAmIResponse
Answers POST /mail/whoami (daemon dto::WhoAmIResponse).

Enums§

ClientError
Typed failures from the HTTP client itself (transport / decode / HTTP status that is not a named MailError JSON body).
MailAddress
Re-export common wire types so hosts can use mail4agent_client::*. Where a message goes, or who it is from: one account directly, one of that account’s live sessions, or a room the mailbox tracks membership for. Serde-tagged on kind ("direct" / "session" / "room").

Constants§

DEFAULT_BASE_URL
Default loopback bind the daemon uses when mail4agent.toml is absent.
INBOX_LIMIT_DEFAULT
Re-export common wire types so hosts can use mail4agent_client::*. Value InboxRequest::limit defaults to when a caller’s JSON omits it.