Skip to main content

Crate agent_diva_nano

Crate agent_diva_nano 

Source
Expand description

agent-diva-nano — minimal “create an agent” library.

Add to your project:

[dependencies]
agent-diva-nano = "0.4.11"
tokio = { version = "1", features = ["rt-multi-thread", "macros"] }

§Quick start

use agent_diva_nano::{chat, NanoConfig};

let config = NanoConfig {
    model: "deepseek-chat".to_string(),
    api_key: std::env::var("NANO_API_KEY")?,
    ..Default::default()
};

let reply = chat("What is Rust ownership?", &config).await?;
println!("{}", reply);

§Stateful agent

For multi-turn conversations, use Agent directly:

use agent_diva_nano::{Agent, NanoConfig};

let config = NanoConfig {
    model: "deepseek-chat".to_string(),
    api_key: std::env::var("NANO_API_KEY")?,
    ..Default::default()
};

let mut agent = Agent::new(config).build().await?;
agent.start().await?;

let r1 = agent.send("Hello").await?;
let r2 = agent.send("Tell me more").await?;

agent.stop().await;

§Flexible tool assembly

Use ToolAssembly for fine-grained control over which tools are available:

use agent_diva_nano::{AgentBuilder, ToolAssembly, BuiltInToolsConfig};

// Create agent with minimal tools (only filesystem)
let assembly = ToolAssembly::new(std::path::PathBuf::from("./workspace"))
    .builtin(BuiltInToolsConfig::minimal())
    .build();

// Or create agent with custom tools only
let assembly = ToolAssembly::new(std::path::PathBuf::from("./workspace"))
    .builtin(BuiltInToolsConfig::none())
    .with_tool(my_custom_tool);

Re-exports§

pub use config::NanoConfig;
pub use config::ShellToolConfig;
pub use config::SoulConfig;
pub use config::WebSearchConfig;
pub use config::WebToolConfig;
pub use agent::Agent;
pub use agent::AgentBuilder;
pub use agent::AgentLoopMode;
pub use chat::chat;
pub use chat::chat_stream;
pub use error::NanoError;
pub use tool_assembly::ToolAssembly;
pub use nano_loop::NanoAgentLoop;
pub use nano_loop::NanoLoopConfig;
pub use nano_loop::NanoRuntimeControlCommand;

Modules§

agent
Agent creation and management for agent-diva-nano.
chat
config
error
nano_loop
Lightweight agent loop implementation for agent-diva-nano.
tool_assembly
Thin wrapper around the shared agent-diva tool assembly.

Structs§

BuiltInToolsConfig
Re-export tool assembly types. Built-in tool toggles shared by the main agent and nano runtime.
FileManager
Re-export FileManager when files feature is enabled. File manager - main interface for file operations
MCPServerConfig
Re-export MCP server configuration from the core crate. MCP server connection configuration (stdio or HTTP)
ProviderRegistry
Re-export provider registry so consumers can resolve provider names from model identifiers. Registry of available LLM providers
ToolRegistry
Re-export tool types for custom tool creation. Registry of available tools.

Enums§

AgentEvent
Re-export core event types so consumers don’t need to depend on agent-diva-core. Streaming events emitted by the agent
ToolError
Re-export tool types for custom tool creation. Tool errors.

Traits§

SubagentSpawner
Tool
Re-export tool types for custom tool creation. Trait for tools.