agent_sdk/lib.rs
1//! Agent SDK - A Rust SDK for building LLM-powered agents.
2//!
3//! This crate provides the building blocks for creating AI agents with:
4//! - Tool execution and lifecycle hooks
5//! - Streaming event-based architecture
6//! - Provider-agnostic LLM interface
7//! - Built-in primitive tools for file operations
8//!
9//! # Example
10//!
11//! ```ignore
12//! use agent_sdk::{builder, ToolContext, ThreadId, providers::AnthropicProvider};
13//!
14//! // Build agent with defaults (in-memory stores, default hooks)
15//! let agent = builder()
16//! .provider(AnthropicProvider::sonnet(api_key))
17//! .build();
18//!
19//! // Run the agent
20//! let thread_id = ThreadId::new();
21//! let tool_ctx = ToolContext::new(());
22//! let mut events = agent.run(thread_id, "Hello!".to_string(), tool_ctx);
23//!
24//! while let Some(event) = events.recv().await {
25//! println!("{:?}", event);
26//! }
27//! ```
28//!
29//! # Custom Configuration
30//!
31//! ```ignore
32//! use agent_sdk::{builder, AgentConfig, ToolRegistry, providers::AnthropicProvider};
33//!
34//! let agent = builder()
35//! .provider(AnthropicProvider::sonnet(api_key))
36//! .tools(my_tools)
37//! .config(AgentConfig {
38//! max_turns: 20,
39//! system_prompt: "You are a helpful assistant.".to_string(),
40//! ..Default::default()
41//! })
42//! .build();
43//! ```
44//!
45//! # Custom Stores and Hooks
46//!
47//! ```ignore
48//! use agent_sdk::builder;
49//!
50//! let agent = builder()
51//! .provider(my_provider)
52//! .hooks(my_hooks)
53//! .message_store(my_message_store)
54//! .state_store(my_state_store)
55//! .build_with_stores();
56//! ```
57
58#![forbid(unsafe_code)]
59
60mod agent_loop;
61mod capabilities;
62pub mod context;
63mod environment;
64mod events;
65mod filesystem;
66mod hooks;
67pub mod llm;
68pub mod mcp;
69pub mod primitive_tools;
70pub mod providers;
71pub mod skills;
72mod stores;
73pub mod subagent;
74mod tools;
75mod types;
76pub mod web;
77
78pub use agent_loop::{AgentLoop, AgentLoopBuilder, builder};
79pub use capabilities::AgentCapabilities;
80pub use environment::{Environment, ExecResult, FileEntry, GrepMatch, NullEnvironment};
81pub use events::AgentEvent;
82pub use filesystem::{InMemoryFileSystem, LocalFileSystem};
83pub use hooks::{AgentHooks, AllowAllHooks, DefaultHooks, LoggingHooks, ToolDecision};
84pub use llm::LlmProvider;
85pub use stores::{InMemoryStore, MessageStore, StateStore};
86pub use tools::{Tool, ToolContext, ToolRegistry};
87pub use types::{
88 AgentConfig, AgentState, PendingAction, RetryConfig, ThreadId, TokenUsage, ToolResult, ToolTier,
89};