Skip to main content

adk_drivers/
lib.rs

1//! # adk-drivers
2//!
3//! Service drivers for ADK-Rust agents (spec 3.5 §7.13): DNS and registrar, email,
4//! analytics and search console, social and advertising.
5//!
6//! A driver is a kernel driver — a supervised MCP server under a manifest the owner
7//! approved (spec 3.2 §7.7) — or an in-process adapter with the same tools. For each
8//! class this crate gives:
9//!
10//! | Part | What it is |
11//! |---|---|
12//! | Contract | A trait for in-process adapters ([`dns::DnsDriver`], [`email::EmailDriver`], ...) and the class's tool list with effect classes, sides and default autonomy caps ([`DriverClass`]) |
13//! | Manifest | [`DriverClass::manifest`] and [`DriverClass::manifest_toml`] make the kernel `DriverManifest` of one side; [`DriverClass::check_manifest`] and [`DriverClass::check_listing`] tell whether any MCP server and its manifest satisfy the class, so the owner connects whichever server they choose (D-13) |
14//! | Rules | [`DriverCapPolicy`] holds DNS changes and campaign launches in every mode (A-I21) and within-budget calls beyond the owner's [`DriverBudget`]; the email and social outboxes keep the [`Disclosure`] line, unsubscribes, consent and `reply_in_thread`'s limits (§7.10, A-I8, A-I17) |
15//! | Conformance | A suite per contract (`conformance`, feature `conformance`) |
16//! | Adapters | In-memory adapters for hermetic tests, and a reference adapter per class over an open protocol or a common API |
17//!
18//! | Class | Tools | Reference adapter |
19//! |---|---|---|
20//! | DNS | `dns_list_records`, `dns_change_records` | [`dns::Rfc2136Dns`]: RFC 2136 with TSIG, AXFR |
21//! | Registrar | `registrar_domain_status`, `registrar_renew_domain` | [`dns::RdapRegistrar`]: RDAP expiry |
22//! | Email | `email_list_inbox`, `email_reply_in_thread`, `email_send_sequence_step`, `email_send_newsletter`, `email_delivery_stats`, `email_check_domain` | [`email::ImapSmtpEmail`]: IMAP and SMTP |
23//! | Analytics | `analytics_metric` | [`analytics::PlausibleAnalytics`]: Plausible Stats API v2 |
24//! | Search console | `search_console_performance` | [`analytics::SearchAnalyticsApi`]: Search Analytics API |
25//! | Social | `social_list_mentions`, `social_list_messages`, `social_reply_in_thread`, `social_post` | [`social::MastodonSocial`]: Mastodon client API |
26//! | Advertising | `ads_performance`, `ads_launch_campaign`, `ads_set_bid`, `ads_pause_campaign` | [`ads::RecordedAds`]: recorded responses, no live spend |
27//!
28//! `reply_in_thread` ([`ReplyInThread`]) is the public partition's one `SendExternal` tool
29//! (§7.10, A-I2): it answers an email or social thread through its outbox.
30//!
31//! Delivery statistics, analytics, search performance and ad spend are [`KpiSource`]s
32//! the KPI tracker reads (§7.11, §7.12).
33//!
34//! ## Features
35//!
36//! | Feature | Default | Adds |
37//! |---|---|---|
38//! | `rfc2136` | yes | [`dns::Rfc2136Dns`] and [`dns::tsig`] |
39//! | `rdap` | yes | [`dns::RdapRegistrar`] |
40//! | `imap-smtp` | yes | [`email::ImapSmtpEmail`] |
41//! | `system-dns` | yes | [`email::SystemTxtLookup`] for SPF, DKIM and DMARC checks |
42//! | `plausible` | yes | [`analytics::PlausibleAnalytics`] |
43//! | `search-console` | yes | [`analytics::SearchAnalyticsApi`] |
44//! | `mastodon` | yes | [`social::MastodonSocial`] |
45//! | `conformance` | no | The conformance suites |
46//!
47//! ## Example
48//!
49//! ```rust
50//! use std::sync::Arc;
51//! use adk_core::{PolicyDecision, ToolPolicy, ToolPolicyRequest};
52//! use adk_drivers::{DriverBudget, DriverCapPolicy, DriverKind, Side};
53//! use adk_drivers::dns::{InMemoryDns, dns_tools};
54//! use serde_json::json;
55//!
56//! # futures::executor::block_on(async {
57//! // The DNS class's tools over an in-process adapter...
58//! let tools = dns_tools(Arc::new(InMemoryDns::new().with_zone("bakery.example", [])));
59//! assert_eq!(tools[1].name(), "dns_change_records");
60//!
61//! // ...or a manifest for any MCP server that serves them.
62//! let manifest = DriverKind::Dns.class().manifest_toml("dns", "mcp-dns", &[], Side::BackOffice);
63//! assert!(manifest.contains("dns_change_records = \"publish_public\""));
64//!
65//! // Either way, a change is held for the owner in every mode (A-I21).
66//! let policy = DriverCapPolicy::new(DriverBudget::new());
67//! let change = ToolPolicyRequest::new("dns_change_records", json!({"zone": "bakery.example"}));
68//! assert!(matches!(policy.evaluate(&change).await, PolicyDecision::RequireApproval { .. }));
69//! # });
70//! ```
71//!
72//! ## Stability
73//!
74//! Experimental — new in 3.0.0 (spec 3.5), and its API may change while the spec lands. See
75//! [STABILITY.md](https://github.com/zavora-ai/adk-rust/blob/main/STABILITY.md).
76
77#![warn(missing_docs)]
78
79pub mod ads;
80pub mod analytics;
81mod class;
82#[cfg(feature = "conformance")]
83pub mod conformance;
84pub mod dns;
85pub mod email;
86mod error;
87#[cfg(any(
88    feature = "rdap",
89    feature = "plausible",
90    feature = "search-console",
91    feature = "mastodon"
92))]
93mod http;
94mod metrics;
95mod outbound;
96mod policy;
97pub mod social;
98mod tools;
99
100pub use class::{
101    AutonomyCap, BACK_OFFICE_PARTITION, DriverClass, DriverKind, Gap, ManifestCheck,
102    PUBLIC_PARTITION, Side, ToolSpec, all_tools, tool_spec,
103};
104pub use error::{DriverError, Result};
105pub use metrics::KpiSource;
106pub use outbound::{
107    ConsentCheck, Disclosure, IN_PROCESS_ORIGIN_PREFIX, InMemoryConsent, InMemorySuppressions,
108    RateLimit, ReplyInThread, ReplyTemplates, Suppression, SuppressionList, SuppressionScope,
109    ThreadReplier, recipient_key,
110};
111pub use policy::{BudgetCap, DRIVER_CAP_POLICY_REF, DriverBudget, DriverCapPolicy};