adk-awp
Agentic Web Protocol (AWP) implementation for ADK-Rust.
adk-awp provides the full AWP protocol implementation — route registration,
middleware, rate limiting, consent, events, health monitoring, and business
context management. Plug awp_routes() into any Axum app to make it
AWP-compliant.
Overview
Use adk-awp when you need to:
- serve AWP discovery documents and capability manifests from a
business.toml - apply per-trust-level rate limiting (Anonymous: 30/min, Known: 120/min, Partner: 600/min)
- manage consent records with durable file-backed storage (GDPR/KPA compliance)
- subscribe agents to events with HMAC-SHA256 webhook signing
- monitor service health with a validated state machine (Healthy → Degrading → Degraded)
- detect whether requests come from humans or AI agents
- negotiate AWP protocol versions automatically
Quick Start
1. Create a business.toml
= "My Shop"
= "An online store powered by AWP"
= "myshop.example.com"
[]
= "friendly"
= "Welcome! How can I help?"
[[]]
= "browse_products"
= "Browse the product catalog"
= "/api/products"
= "GET"
= "anonymous"
[[]]
= "privacy"
= "Minimal data collection."
= "privacy"
2. Serve AWP routes
use ;
let loader = from_file?;
let state = builder.build;
let app = new
.merge
.merge;
let listener = bind.await?;
serve.await?;
This registers all 7 AWP endpoints with version negotiation middleware.
Endpoints
| Method | Path | Description |
|---|---|---|
| GET | /.well-known/awp.json |
Discovery document |
| GET | /awp/manifest |
JSON-LD capability manifest |
| GET | /awp/health |
Health state |
| POST | /awp/events/subscribe |
Create webhook subscription |
| GET | /awp/events/subscriptions |
List subscriptions |
| DELETE | /awp/events/subscriptions/{id} |
Delete subscription |
| POST | /awp/a2a |
A2A message handler |
Components
AwpStateBuilder
Build AwpState with sensible defaults — all services default to in-memory,
health state machine auto-wired to event service:
use ;
use Arc;
let state = builder
.consent_service
.build;
BusinessContextLoader
Parse and validate business.toml with hot-reload support:
use BusinessContextLoader;
let loader = from_file?;
loader.watch.await?; // hot-reload every 5s
let ctx = loader.load;
println!;
Rate Limiting
Per-trust-level sliding window with configurable limits:
| Trust Level | Default Limit |
|---|---|
| Anonymous | 30 req/min |
| Known | 120 req/min |
| Partner | 600 req/min |
| Internal | Unlimited |
use ;
use TrustLevel;
use HashMap;
use Duration;
let mut limits = new;
limits.insert;
let limiter = with_config;
Consent Service
Two implementations:
InMemoryConsentService— ephemeral, for developmentFileConsentService— JSON file-backed, for production (GDPR/KPA)
use FileConsentService;
let consent = new?;
consent.capture_consent.await?;
assert!;
consent.revoke_consent.await?;
Health State Machine
Validated transitions with event emission:
Healthy → Degrading → Degraded → Healthy
Invalid transitions (e.g., Healthy → Degraded) return an error.
Event Subscriptions
CRUD with HMAC-SHA256 webhook signing:
use ;
let sig = sign_payload;
assert!;
Requester Detection
Detect human vs agent from HTTP headers:
use detect_requester_type;
use HeaderMap;
let mut headers = new;
headers.insert;
let requester = detect_requester_type;
// RequesterType::Agent
Feature Flags
[]
= []
= ["dep:reqwest"] # Enable real HTTP webhook delivery
Testing
Example
The example loads business.toml, creates an LLM agent with business context
instructions, serves all AWP endpoints, and exercises each one.
Documentation
See AWP Documentation for the full guide.
Related Crates
awp-types— Pure protocol types (zeroadk-*deps)adk-server— HTTP server with A2A protocoladk-core— ADK foundational traits
License
Apache-2.0