Capability-based DHT discovery for the agent:// URI scheme.
This crate provides DHT (Distributed Hash Table) infrastructure for discovering agents by their capabilities. It includes:
- Key derivation: [
DhtKey] for Kademlia-style routing - Registration records: [
Registration] with endpoints and attestations - Trait interface: [
Dht] trait for abstracting DHT implementations - In-memory simulation: [
SimulatedDht] for evaluation and testing - Prefix matching: [
PathTrie] for efficient hierarchical discovery
Overview
The core idea is that agents register at DHT keys derived from their trust root and capability path:
key = SHA256(trust_root || "/" || capability_path)
This enables capability-based discovery: "find me an agent at
anthropic.com that can do assistant/chat".
Quick Start
use ;
use ;
// Create a simulated DHT
let dht = new;
// Register an agent
let uri = parse.unwrap;
let endpoint = https;
let registration = new;
dht.register.unwrap;
// Discover agents by capability
let results = dht.lookup_prefix.unwrap;
assert_eq!;
Key Derivation
DHT keys are derived deterministically from trust root and capability path using SHA-256. This enables:
- Exact lookup: Find agents at a specific capability path
- Prefix lookup: Find agents at a path and all child paths
- Cross-trust-root lookup: Find agents with a capability across all authorities
use ;
use DhtKey;
let trust_root = parse.unwrap;
let path = parse.unwrap;
// Derive a key for this capability
let key = derive;
// Keys are deterministic
let key2 = derive;
assert_eq!;
// Partial depth for hierarchical queries
let parent_key = derive_at_depth.unwrap;
Agent Migration
The identity stability of agent:// URIs means agents can migrate between network locations without changing their identity:
use AgentUri;
use ;
let dht = with_defaults;
let uri = parse.unwrap;
// Register at initial location
let registration = new;
dht.register.unwrap;
// Migrate to new location (same identity)
dht.update_endpoint.unwrap;