Skip to main content

Crate haiai

Crate haiai 

Source
Expand description

Rust HAIAI.

This crate is intentionally a thin HAI-platform wrapper around JACS. Runtime signing/canonicalization should be delegated via JacsProvider.

§Feature flags

  • jacs-crate (default) – Use the published jacs crate from crates.io.

§Agent API

The recommended entry point is agent::Agent, which provides an ergonomic agent.email.* namespace. All email operations sign with the agent’s JACS key – there is no unsigned send path.

use haiai::agent::Agent;
use haiai::types::SendEmailOptions;

let agent = Agent::from_config(None).await?;
agent.email.send(SendEmailOptions {
    to: "other@hai.ai".into(),
    subject: "Hello".into(),
    body: "World".into(),
    cc: vec![],
    bcc: vec![],
    in_reply_to: None,
    attachments: vec![],
    labels: vec![],
    append_footer: None,
}).await?;

Re-exports§

pub use a2a::A2AAgentCapabilities;
pub use a2a::A2AAgentCard;
pub use a2a::A2AAgentExtension;
pub use a2a::A2AAgentInterface;
pub use a2a::A2AAgentSkill;
pub use a2a::A2AArtifactSignature;
pub use a2a::A2AArtifactVerificationResult;
pub use a2a::A2AChainEntry;
pub use a2a::A2AChainOfCustody;
pub use a2a::A2AIntegration;
pub use a2a::A2AMediatedJobOptions;
pub use a2a::A2ATrustAssessment;
pub use a2a::A2ATrustPolicy;
pub use a2a::A2AWrappedArtifact;
pub use a2a::A2A_JACS_EXTENSION_URI;
pub use a2a::A2A_PROTOCOL_VERSION_04;
pub use a2a::A2A_PROTOCOL_VERSION_10;
pub use agent::Agent;
pub use agent::EmailNamespace;
pub use client::HaiClient;
pub use client::HaiClientOptions;
pub use client::SseConnection;
pub use client::WsConnection;
pub use client::DEFAULT_BASE_URL;
pub use client::DEFAULT_DNS_RESOLVER;
pub use client::DEFAULT_MAX_RETRIES;
pub use client::DEFAULT_TIMEOUT_SECS;
pub use config::load_config;
pub use config::redacted_display;
pub use config::resolve_private_key_candidates;
pub use config::resolve_storage_backend;
pub use config::resolve_storage_backend_label;
pub use config::AgentConfig;
pub use config::StorageConfigSummary;
pub use email::verify_email;
pub use error::HaiError;
pub use error::Result;
pub use jacs::JacsAgentLifecycle;
pub use jacs::JacsBatchProvider;
pub use jacs::JacsDocumentProvider;
pub use jacs::JacsEmailProvider;
pub use jacs::JacsProvider;
pub use jacs::JacsVerificationProvider;
pub use jacs::NoopJacsProvider;
pub use jacs::StaticJacsProvider;
pub use jacs::media_verify_result_to_json;
pub use jacs::media_verify_status_to_str;
pub use jacs::text_signature_status_to_str;
pub use jacs::verify_text_result_to_json;
pub use jacs::JacsMediaProvider;
pub use jacs_local::LocalJacsProvider;
pub use jacs_remote::RemoteJacsProvider;
pub use jacs_remote::RemoteJacsProviderOptions;
pub use verify::MAX_VERIFY_DOCUMENT_BYTES;
pub use verify::MAX_VERIFY_URL_LEN;
pub use types::*;

Modules§

a2a
agent
High-level Agent API for HAI email operations.
client
config
email
HAI email verification wrapper.
error
jacs
jacs_local
jacs_remote
RemoteJacsProvider — JacsDocumentProvider impl backed by /api/v1/records on hai-api.
key_format
mime
RFC 5322 MIME email construction.
self_knowledge
Embedded documentation search powered by BM25.
types
validation
Input validation for email operations.
verify

Structs§

AttachmentEntry
An attachment entry with content hash, MIME header hash, and filename.
BodyPartEntry
A body part entry with content and MIME header hashes.
ContentVerificationResult
Result of content verification comparing trusted JACS hashes against email.
EmailSignatureHeaders
The set of signed email headers in the JACS signature payload.
EmailSignaturePayload
The payload section of the JACS email signature document.
JacsEmailMetadata
Metadata for the JACS email signature document.
JacsEmailSignature
Cryptographic signature of the JACS email signature document.
JacsEmailSignatureDocument
The complete JACS email signature document.
MediaVerificationResult
Result of super::advanced::verify_image.
ParsedAttachment
A parsed attachment with content and metadata.
ParsedBodyPart
A parsed body part with content and MIME metadata.
ParsedEmailParts
Parsed email parts extracted from raw RFC 5322 bytes. Used as intermediate representation for signing and verification.
SignImageOptions
Options for super::advanced::sign_image.
SignTextOptions
Options for super::advanced::sign_text_file.
SignTextOutcome
Outcome of super::advanced::sign_text_file.
SignedHeaderEntry
A signed header entry containing the raw value and its SHA-256 hash.
SignedMedia
Outcome of super::advanced::sign_image.
TextSignatureEntry
One result entry per signature block.
VerifyImageOptions
Options for super::advanced::verify_image.
VerifyTextOptions
Options for verify_inline. C1 resolution: callers pick strict vs permissive. PRD §4.1.5 adds key_dir for library callers that want programmatic equivalent of the CLI --key-dir flag.

Enums§

MediaVerifyStatus
Per-image verification status. Maps roughly to crate::inline::SignatureStatus but with image-specific additions (UnsupportedFormat).
TextSignatureStatus
Per-block verification status. Malformed here is per-block (well-terminated block with a bad body); file-level malformation goes on VerifyTextResult.
VerifyTextResult
Overall verify result. MissingSignature and Malformed are file-level discriminators.

Functions§

sign_email
Sign a raw RFC 5322 email and attach a JACS signature document.