Skip to main content

abk/
lib.rs

1//! Agent Builder Kit (ABK) - Modular utilities for building LLM agents
2//!
3//! ABK provides a set of feature-gated modules for building LLM-based agents:
4//!
5//! - **`config`** - Configuration and environment loading
6//! - **`observability`** - Structured logging, metrics, and tracing
7//! - **`cli`** - CLI display utilities and formatting helpers
8//! - **`checkpoint`** - Session persistence and checkpoint management
9//!
10//! # Features
11//!
12//! Enable the features you need in your `Cargo.toml`:
13//!
14//! ```toml
15//! [dependencies]
16//! abk = { version = "0.1", features = ["config"] }
17//! # Or enable multiple features:
18//! abk = { version = "0.1", features = ["config", "observability"] }
19//! # Or enable everything:
20//! abk = { version = "0.1", features = ["all"] }
21//! ```
22//!
23//! # Example: Using the config feature
24//!
25//! ```ignore
26//! use abk::config::{ConfigurationLoader, EnvironmentLoader};
27//! use std::path::Path;
28//!
29//! // Load environment variables
30//! let env = EnvironmentLoader::new(None);
31//!
32//! // Load configuration from TOML
33//! let config_loader = ConfigurationLoader::new(Some(Path::new("config/agent.toml"))).unwrap();
34//! let config = &config_loader.config;
35//!
36//! // Access configuration
37//! println!("Max iterations: {}", config.execution.max_iterations);
38//! println!("LLM provider: {:?}", env.llm_provider());
39//! ```
40//!
41//! # Example: Using the observability feature
42//!
43//! ```ignore
44//! use abk::observability::Logger;
45//! use std::collections::HashMap;
46//!
47//! // Create a logger
48//! let logger = Logger::new(None, Some("DEBUG")).unwrap();
49//!
50//! // Log a session start
51//! let config = HashMap::new();
52//! logger.log_session_start("auto", &config).unwrap();
53//!
54//! // Log an LLM interaction
55//! let messages = vec![];
56//! logger.log_llm_interaction(&messages, "Hello, world!", "gpt-4").unwrap();
57//! ```
58//!
59//! # Example: Using the checkpoint feature
60//!
61//! ```ignore
62//! use abk::checkpoint::{get_storage_manager, CheckpointResult};
63//! use std::path::Path;
64//!
65//! async fn example() -> CheckpointResult<()> {
66//!     let manager = get_storage_manager()?;
67//!     let project_path = Path::new(".");
68//!     let project_storage = manager.get_project_storage(project_path).await?;
69//!     Ok(())
70//! }
71//! ```
72
73#![warn(missing_docs)]
74
75/// Configuration management (enabled with the `config` feature)
76#[cfg(feature = "config")]
77pub mod config;
78
79/// Observability utilities (enabled with the `observability` feature)
80#[cfg(feature = "observability")]
81pub mod observability;
82
83/// CLI display utilities (enabled with the `cli` feature)
84#[cfg(feature = "cli")]
85pub mod cli;
86
87/// Checkpoint and session management (enabled with the `checkpoint` feature)
88#[cfg(feature = "checkpoint")]
89pub mod checkpoint;
90
91/// LLM Provider abstraction (enabled with the `provider` feature)
92#[cfg(feature = "provider")]
93pub mod provider;
94
95/// Extension system (enabled with the `extension` feature)
96#[cfg(feature = "extension")]
97pub mod extension;
98
99/// Agent orchestration (enabled with the `orchestration` feature)
100#[cfg(feature = "orchestration")]
101pub mod orchestration;
102
103/// Agent implementation (enabled with the `agent` feature)
104#[cfg(feature = "agent")]
105pub mod agent;
106
107/// Executor implementation (enabled with the `executor` feature)
108#[cfg(feature = "executor")]
109pub mod executor;
110
111/// Lifecycle implementation (enabled with the `agent` feature)
112#[cfg(feature = "agent")]
113pub mod lifecycle;
114
115/// Tool Registry for multi-source tool aggregation (enabled with the `registry` feature)
116#[cfg(feature = "registry")]
117pub mod registry;
118
119/// Prelude module for convenient imports
120pub mod prelude {
121    #[cfg(feature = "config")]
122    pub use crate::config::{Configuration, ConfigurationLoader, EnvironmentLoader};
123
124    #[cfg(feature = "observability")]
125    pub use crate::observability::Logger;
126
127    #[cfg(feature = "checkpoint")]
128    pub use crate::checkpoint::{
129        get_storage_manager, Checkpoint, CheckpointError, CheckpointResult,
130        CheckpointStorageManager, ProjectStorage, SessionStorage,
131    };
132
133    #[cfg(feature = "provider")]
134    pub use crate::provider::{
135        LlmProvider, GenerateResponse, ToolInvocation, ProviderFactory,
136        InternalMessage, GenerateConfig, InternalToolDefinition,
137    };
138
139    #[cfg(feature = "orchestration")]
140    pub use crate::orchestration::{
141        AgentRuntime, RuntimeConfig, WorkflowCoordinator, WorkflowStep, WorkflowStatus,
142        ToolCoordinator, ToolExecutionResult, ExecutionResult, ExecutionMode, AgentMode,
143    };
144
145    #[cfg(feature = "registry")]
146    pub use crate::registry::{
147        RegisteredTool, RegistryError, RegistryResult, ToolRegistry, ToolSource,
148    };
149}