haiai -- Rust SDK
Rust SDK for the HAI.AI platform. Thin wrapper around JACS for cryptographic agent identity, signed email, and conflict-resolution benchmarking.
Install
[]
= "0.1.2"
Quickstart
use ;
async
What This Crate Owns
This crate delegates all cryptographic operations to JACS via JacsProvider and owns HAI-specific concerns:
- HAI API endpoint contracts and authentication
- JACS auth header construction (
JACS {jacsId}:{timestamp}:{signature_base64}) - URL/path escaping for agent IDs
- Email, benchmark, and verification API workflows
- Verify-link generation
- A2A facade composition (
client.get_a2a(...))
Trait Architecture (Layers 0-7)
JACS 0.9.4 capabilities are exposed through 8 layered extension traits:
| Layer | Trait | Purpose | Feature |
|---|---|---|---|
| 0 | JacsProvider |
Core signing, identity, canonical JSON, A2A verification | -- |
| 1 | JacsAgentLifecycle |
Key rotation, migration, diagnostics, quickstart | -- |
| 2 | JacsDocumentProvider |
Document CRUD, versioning, search, storage | -- |
| 3 | JacsBatchProvider |
Batch sign/verify | -- |
| 4 | JacsVerificationProvider |
Document verification, DNS trust, auth headers | -- |
| 5 | JacsEmailProvider |
Email signing/verification, attachments | -- |
| 6 | JacsAgreementProvider |
Multi-party agreements | agreements |
| 7 | JacsAttestationProvider |
Verifiable attestation claims | attestation |
use ;
let provider = from_config_path?;
// Layer 1: Agent lifecycle
let diag = provider.diagnostics?;
// Layer 2: Document operations
let doc = provider.sign_and_store?;
let found = provider.search_documents?;
A2A Integration
use ;
use json;
let client = new?;
let a2a = client.get_a2a;
let wrapped = a2a.sign_artifact?;
let verified = a2a.verify_artifact?;
Storage Backend Selection
| Priority | Method | Example |
|---|---|---|
| 1 (highest) | --storage CLI flag |
haiai store-document --storage sqlite doc.json |
| 2 | JACS_STORAGE env var |
JACS_STORAGE=rusqlite haiai list-documents |
| 3 | default_storage in config |
"defaultStorage": "sqlite" |
| 4 (lowest) | Default | fs (filesystem) |
Available backends: fs (filesystem), rusqlite/sqlite (SQLite with fulltext search).
Features
= { = "0.1.2", = ["agreements", "attestation"] }
| Feature | Description |
|---|---|
rustls-tls (default) |
TLS via rustls |
native-tls |
TLS via system native |
jacs-crate (default) |
Include JACS dependency |
agreements |
Multi-party agreement support |
attestation |
Verifiable attestation support |
Links
- HAI.AI Developer Docs
- JACS
- haiai-cli -- CLI binary
- hai-mcp -- MCP server library
License
Apache-2.0 OR MIT