agents_sdk/lib.rs
1//! # Rust Deep Agents SDK
2//!
3//! High-performance Rust framework for composing reusable "deep" AI agents with custom tools,
4//! sub-agents, and prompts.
5//!
6//! ## Quick Start
7//!
8//! ```toml
9//! [dependencies]
10//! agents-sdk = "0.0.1" # Includes toolkit by default
11//! ```
12//!
13//! ```rust,no_run
14//! # #[cfg(feature = "toolkit")]
15//! # {
16//! use agents_sdk::{ConfigurableAgentBuilder, OpenAiConfig};
17//! use agents_core::persistence::InMemoryCheckpointer;
18//! use std::sync::Arc;
19//!
20//! # async fn example() -> anyhow::Result<()> {
21//! let config = OpenAiConfig::new(
22//! std::env::var("OPENAI_API_KEY")?,
23//! "gpt-4o-mini"
24//! );
25//!
26//! // Build an agent
27//! let agent = ConfigurableAgentBuilder::new("You are a helpful assistant.")
28//! .with_openai_chat(config)?
29//! .with_checkpointer(Arc::new(InMemoryCheckpointer::new()))
30//! .build()?;
31//!
32//! // Use the agent
33//! use agents_sdk::state::AgentStateSnapshot;
34//! use std::sync::Arc;
35//!
36//! let response = agent.handle_message(
37//! "Please greet Alice using the greet tool",
38//! Arc::new(AgentStateSnapshot::default())
39//! ).await?;
40//! println!("{:?}", response);
41//! # Ok(())
42//! # }
43//! # }
44//! ```
45//!
46//! ## Features
47//!
48//! - `toolkit` (default): Includes agents-toolkit with built-in tools
49//! - `aws`: Includes AWS integrations
50//! - `redis`: Redis-backed state persistence
51//! - `postgres`: PostgreSQL-backed state persistence
52//! - `dynamodb`: DynamoDB-backed state persistence (AWS)
53//! - `persistence`: Grouped feature for Redis + PostgreSQL
54//! - `aws-full`: Grouped feature for AWS + DynamoDB
55//! - `full`: Includes all features
56//!
57//! ## Installation Options
58//!
59//! ```toml
60//! # Default installation with toolkit
61//! agents-sdk = "0.0.1"
62//!
63//! # Core only (minimal installation)
64//! agents-sdk = { version = "0.0.1", default-features = false }
65//!
66//! # With specific persistence backend
67//! agents-sdk = { version = "0.0.1", features = ["redis"] }
68//! agents-sdk = { version = "0.0.1", features = ["postgres"] }
69//! agents-sdk = { version = "0.0.1", features = ["dynamodb"] }
70//!
71//! # With AWS integrations
72//! agents-sdk = { version = "0.0.1", features = ["aws-full"] }
73//!
74//! # Everything included
75//! agents-sdk = { version = "0.0.1", features = ["full"] }
76//! ```
77//!
78//! ## Persistence Examples
79//!
80//! ### Redis Checkpointer
81//!
82//! ```rust,no_run
83//! # #[cfg(feature = "redis")]
84//! # {
85//! use agents_sdk::{RedisCheckpointer, ConfigurableAgentBuilder};
86//! use std::sync::Arc;
87//!
88//! # async fn example() -> anyhow::Result<()> {
89//! let checkpointer = Arc::new(
90//! RedisCheckpointer::new("redis://127.0.0.1:6379").await?
91//! );
92//!
93//! let agent = ConfigurableAgentBuilder::new("You are a helpful assistant")
94//! .with_checkpointer(checkpointer)
95//! .build()?;
96//! # Ok(())
97//! # }
98//! # }
99//! ```
100//!
101//! ### PostgreSQL Checkpointer
102//!
103//! ```rust,no_run
104//! # #[cfg(feature = "postgres")]
105//! # {
106//! use agents_sdk::{PostgresCheckpointer, ConfigurableAgentBuilder};
107//! use std::sync::Arc;
108//!
109//! # async fn example() -> anyhow::Result<()> {
110//! let checkpointer = Arc::new(
111//! PostgresCheckpointer::new("postgresql://user:pass@localhost/agents").await?
112//! );
113//!
114//! let agent = ConfigurableAgentBuilder::new("You are a helpful assistant")
115//! .with_checkpointer(checkpointer)
116//! .build()?;
117//! # Ok(())
118//! # }
119//! # }
120//! ```
121//!
122//! ### DynamoDB Checkpointer
123//!
124//! ```rust,no_run
125//! # #[cfg(feature = "dynamodb")]
126//! # {
127//! use agents_sdk::{DynamoDbCheckpointer, ConfigurableAgentBuilder};
128//! use std::sync::Arc;
129//!
130//! # async fn example() -> anyhow::Result<()> {
131//! let checkpointer = Arc::new(
132//! DynamoDbCheckpointer::new("agent-checkpoints").await?
133//! );
134//!
135//! let agent = ConfigurableAgentBuilder::new("You are a helpful assistant")
136//! .with_checkpointer(checkpointer)
137//! .build()?;
138//! # Ok(())
139//! # }
140//! # }
141//! ```
142
143#![deny(missing_docs)]
144#![cfg_attr(docsrs, feature(doc_cfg))]
145
146// Re-export core functionality (always available)
147pub use agents_core::agent::{AgentHandle, AgentStream};
148pub use agents_core::llm::{ChunkStream, StreamChunk};
149pub use agents_core::tools::{
150 Tool, ToolBox, ToolContext, ToolParameterSchema, ToolRegistry, ToolResult, ToolSchema,
151};
152pub use agents_core::{agent, hitl, llm, messaging, persistence, state, tools};
153pub use agents_runtime::{
154 create_async_deep_agent,
155 create_deep_agent,
156 get_default_model,
157 // Provider configurations and models
158 AnthropicConfig,
159 AnthropicMessagesModel,
160 ConfigurableAgentBuilder,
161 DeepAgent,
162 GeminiChatModel,
163 GeminiConfig,
164 HitlPolicy,
165 OpenAiChatModel,
166 OpenAiConfig,
167 SubAgentConfig,
168 SummarizationConfig,
169};
170
171// Re-export toolkit functionality (when toolkit feature is enabled)
172#[cfg(feature = "toolkit")]
173#[cfg_attr(docsrs, doc(cfg(feature = "toolkit")))]
174pub use agents_toolkit::*;
175
176// Re-export procedural macros from toolkit
177#[cfg(feature = "toolkit")]
178pub use agents_macros::tool;
179
180// Re-export AWS functionality (when aws feature is enabled)
181#[cfg(feature = "aws")]
182#[cfg_attr(docsrs, doc(cfg(feature = "aws")))]
183pub use agents_aws::*;
184
185// Re-export persistence functionality (when persistence features are enabled)
186#[cfg(feature = "redis")]
187#[cfg_attr(docsrs, doc(cfg(feature = "redis")))]
188pub use agents_persistence::RedisCheckpointer;
189
190#[cfg(feature = "postgres")]
191#[cfg_attr(docsrs, doc(cfg(feature = "postgres")))]
192pub use agents_persistence::PostgresCheckpointer;
193
194/// Prelude module for common imports
195///
196/// ```rust
197/// use agents_sdk::prelude::*;
198/// ```
199pub mod prelude {
200
201 // Core types
202 pub use agents_core::agent::{AgentHandle, PlannerHandle};
203 pub use agents_core::messaging::{AgentMessage, MessageContent, MessageRole, ToolInvocation};
204 pub use agents_core::persistence::{Checkpointer, ThreadId};
205 pub use agents_core::state::AgentStateSnapshot;
206
207 // Runtime essentials
208 pub use agents_runtime::{get_default_model, ConfigurableAgentBuilder};
209
210 // Toolkit utilities (when available)
211 #[cfg(feature = "toolkit")]
212 pub use agents_toolkit::{tool, tool_sync, ToolBuilder};
213}
214
215// Convenience re-exports for the most commonly used items already handled above
216
217#[cfg(feature = "toolkit")]
218pub use agents_toolkit::{tool_sync, ToolBuilder};