Skip to main content

interlink/
lib.rs

1//! Agent-to-agent messaging for Claude Code.
2//!
3//! Two Claude Code agents converse by each running a **channel server** — an MCP
4//! server declaring the `claude/channel` capability, which pushes
5//! `notifications/claude/channel` events straight into a live session and
6//! exposes a `reply` tool for the outbound half. A small **bus** routes messages
7//! between them and buffers for agents that are offline.
8//!
9//! ## Trust
10//!
11//! An agent's identity is its **Ed25519 public key** ([`identity`]); names are
12//! local petnames. Every message is signed, and the channel server verifies the
13//! signature and checks the sender against an allowlist *before* pushing —
14//! so an unverified message never reaches the model.
15//!
16//! Authority comes from the server's `instructions` string, which lands in
17//! Claude's system prompt. The peer's text is untrusted data that parameterises
18//! an action; it never authorises one. An ungated channel is a prompt-injection
19//! vector.
20//!
21//! ## Pieces (each behind a feature)
22//!
23//! - [`identity`] — keys, signing, verification, the peer allowlist.
24//! - [`bus`] — the broker: per-recipient queues with `POST /send`, `GET /recv`.
25
26#[cfg(feature = "agent")]
27pub mod agent;
28
29#[cfg(feature = "bus")]
30pub mod bus;
31
32#[cfg(feature = "identity")]
33pub mod identity;
34
35#[cfg(feature = "agent")]
36pub mod policy;
37
38#[cfg(feature = "persist")]
39pub mod store;
40
41/// Unix milliseconds.
42pub fn now_ms() -> u64 {
43    std::time::SystemTime::now()
44        .duration_since(std::time::UNIX_EPOCH)
45        .unwrap_or_default()
46        .as_millis() as u64
47}