1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
//! AI agent run-loop, prompt builder, and multi-agent orchestration for Garudust.
//!
//! The centrepiece of this crate is [`Agent`], which drives the
//! **think → tool-call → observe** loop until the model signals it is done.
//!
//! # Quick start
//!
//! ```no_run
//! use std::sync::Arc;
//! use std::path::PathBuf;
//! use garudust_agent::{Agent, AutoApprover};
//! use garudust_core::config::AgentConfig;
//! use garudust_transport::build_transport;
//! use garudust_memory::FileMemoryStore;
//! use garudust_tools::ToolRegistry;
//!
//! #[tokio::main]
//! async fn main() -> anyhow::Result<()> {
//! let config = Arc::new(AgentConfig::default());
//! let transport = build_transport(&config);
//! let tools = Arc::new(ToolRegistry::default());
//! let memory = Arc::new(FileMemoryStore::new(&PathBuf::from("/tmp")));
//! let agent = Agent::new(transport, tools, memory, config);
//! let approver = Arc::new(AutoApprover);
//! let result = agent.run("List files here", approver, "cli").await?;
//! println!("{}", result.output);
//! Ok(())
//! }
//! ```
//!
//! # Architecture
//!
//! ```text
//! ┌──────────────────────────────────────────┐
//! │ Agent │
//! │ build_system_prompt() │
//! │ ┌────────────────────────────────────┐ │
//! │ │ iteration loop │ │
//! │ │ 1. call ProviderTransport (LLM) │ │
//! │ │ 2. dispatch tool calls │ │
//! │ │ 3. append results to history │ │
//! │ │ 4. repeat until stop_reason=end │ │
//! │ └────────────────────────────────────┘ │
//! │ persist_session() → SessionDb │
//! └──────────────────────────────────────────┘
//! ```
//!
//! # Skills and self-improvement
//!
//! When the agent finishes a task it may call `write_skill` to save a reusable
//! instruction set to `~/.garudust/skills/<name>/SKILL.md`. On subsequent
//! runs the skill index is injected into the system prompt so the model can
//! load and apply the skill via `skill_view`.
pub use Agent;
pub use ;