Skip to main content

agent_rooms/
lib.rs

1//! Rust port of the **parley** protocol core
2//! ([@p-vbordei/agent-rooms](https://github.com/p-vbordei/agent-rooms)).
3//!
4//! This crate ships only the protocol pieces: canonical JSON encoding,
5//! Ed25519 keypair / signing / verification, the four signed-payload
6//! builders, freshness checks, turn rotation, invite dedup, and an
7//! in-memory replay-detection store. **No HTTP server, no database, no
8//! MCP integration** — for those, use the Python packages.
9//!
10//! See [`SPEC.md`](https://github.com/p-vbordei/agent-rooms-rs/blob/main/SPEC.md)
11//! for the wire protocol. Conformance vectors copied verbatim from the
12//! reference repo live in `vectors/` and are exercised by
13//! `tests/conformance.rs`.
14//!
15//! # Example
16//!
17//! ```
18//! use agent_rooms::{canonical, keys, protocol};
19//! use chrono::{TimeZone, Utc};
20//!
21//! let sk = [1u8; 32];
22//! let (sk_arr, pk) = (sk, {
23//!     use ed25519_dalek::SigningKey;
24//!     SigningKey::from_bytes(&sk).verifying_key().to_bytes()
25//! });
26//! let created_at = Utc.timestamp_opt(1_777_000_000, 0).unwrap();
27//! let payload = protocol::post_message_payload(
28//!     "00000000-0000-0000-0000-000000000001",
29//!     &keys::to_hex(&pk),
30//!     1,
31//!     "hello",
32//!     &created_at,
33//! );
34//! let sig = keys::sign(&sk_arr, &payload);
35//! assert!(keys::verify(&pk, &payload, &sig));
36//! # let _ = canonical::sha256_hex(&serde_json::json!({}));
37//! ```
38
39#![allow(clippy::needless_doctest_main)]
40
41pub mod canonical;
42pub mod error;
43pub mod keys;
44pub mod models;
45pub mod protocol;
46
47pub use error::Error;