agent_diva_nano/lib.rs
1//! agent-diva-nano — minimal "create an agent" library.
2//!
3//! Add to your project:
4//! ```toml
5//! [dependencies]
6//! agent-diva-nano = "0.4.11"
7//! tokio = { version = "1", features = ["rt-multi-thread", "macros"] }
8//! ```
9//!
10//! # Quick start
11//!
12//! ```rust,no_run
13//! use agent_diva_nano::{chat, NanoConfig};
14//!
15//! # #[tokio::main]
16//! # async fn main() -> Result<(), Box<dyn std::error::Error>> {
17//! let config = NanoConfig {
18//! model: "deepseek-chat".to_string(),
19//! api_key: std::env::var("NANO_API_KEY")?,
20//! ..Default::default()
21//! };
22//!
23//! let reply = chat("What is Rust ownership?", &config).await?;
24//! println!("{}", reply);
25//! # Ok(())
26//! # }
27//! ```
28//!
29//! # Stateful agent
30//!
31//! For multi-turn conversations, use [`Agent`] directly:
32//!
33//! ```rust,no_run
34//! use agent_diva_nano::{Agent, NanoConfig};
35//!
36//! # #[tokio::main]
37//! # async fn main() -> Result<(), Box<dyn std::error::Error>> {
38//! let config = NanoConfig {
39//! model: "deepseek-chat".to_string(),
40//! api_key: std::env::var("NANO_API_KEY")?,
41//! ..Default::default()
42//! };
43//!
44//! let mut agent = Agent::new(config).build().await?;
45//! agent.start().await?;
46//!
47//! let r1 = agent.send("Hello").await?;
48//! let r2 = agent.send("Tell me more").await?;
49//!
50//! agent.stop().await;
51//! # Ok(())
52//! # }
53//! ```
54//!
55//! # Flexible tool assembly
56//!
57//! Use [`ToolAssembly`] for fine-grained control over which tools are available:
58//!
59//! ```rust,no_run
60//! use agent_diva_nano::{AgentBuilder, ToolAssembly, BuiltInToolsConfig};
61//!
62//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
63//! // Create agent with minimal tools (only filesystem)
64//! let assembly = ToolAssembly::new(std::path::PathBuf::from("./workspace"))
65//! .builtin(BuiltInToolsConfig::minimal())
66//! .build();
67//!
68//! // Or create agent with custom tools only
69//! let assembly = ToolAssembly::new(std::path::PathBuf::from("./workspace"))
70//! .builtin(BuiltInToolsConfig::none())
71//! .with_tool(my_custom_tool);
72//! # Ok(())
73//! # }
74//! ```
75
76pub mod config;
77pub mod agent;
78pub mod chat;
79pub mod error;
80pub mod tool_assembly;
81pub mod nano_loop;
82
83mod internal;
84
85pub use config::{
86 BuiltInToolsConfig, MCPServerConfig, NanoConfig, ShellToolConfig, SoulConfig, WebSearchConfig,
87 WebToolConfig,
88};
89pub use agent::{Agent, AgentBuilder, AgentLoopMode};
90pub use chat::{chat, chat_stream};
91pub use error::NanoError;
92pub use tool_assembly::{ToolAssembly, SubagentSpawner};
93pub use nano_loop::{NanoAgentLoop, NanoLoopConfig, NanoRuntimeControlCommand};
94
95/// Re-export tool types for custom tool creation.
96pub use agent_diva_tooling::{Tool, ToolError, ToolRegistry};
97
98/// Re-export core event types so consumers don't need to depend on `agent-diva-core`.
99pub use agent_diva_core::bus::AgentEvent;
100
101/// Re-export provider registry so consumers can resolve provider names from model identifiers.
102pub use agent_diva_providers::ProviderRegistry;
103
104/// Re-export FileManager when files feature is enabled.
105#[cfg(feature = "files")]
106pub use agent_diva_files::FileManager;