Skip to main content

aither_agent/
lib.rs

1//! Aither Agent Framework
2//!
3//! An ergonomic, minimal-core agent framework for building autonomous AI agents.
4//! The agent handles the tool-use loop internally with a simple API.
5//!
6//! # Quick Start
7//!
8//! ```rust,ignore
9//! use aither_agent::Agent;
10//!
11//! // Simple one-shot query
12//! let agent = Agent::new(llm);
13//! let response = agent.query("What is 2+2?").await?;
14//!
15//! // With tools and hooks
16//! let agent = Agent::builder(llm)
17//!     .tool(FileSystemTool::read_only("."))
18//!     .hook(LoggingHook)
19//!     .build();
20//!
21//! let response = agent.query("List all Rust files").await?;
22//! ```
23//!
24//! # Features
25//!
26//! - **Ergonomic API**: Simple `query()` for one-shot tasks, `run()` for streaming
27//! - **Internal Loop**: Tool execution handled automatically
28//! - **Trait-based Hooks**: Intercept operations at compile time
29//! - **Smart Compression**: Intelligent context management preserving critical info
30//! - **Generic over LLM**: Works with any `LanguageModel` implementation
31
32// Core modules
33mod agent;
34pub mod ask_user;
35mod browser_backend;
36mod builder;
37mod cache_stats;
38mod checkpoint;
39mod compression;
40mod config;
41mod context;
42mod context_window;
43mod error;
44mod event;
45mod fs_util;
46mod handoff;
47mod hook;
48mod model_group;
49mod stream;
50mod subagent_file;
51mod terminal_agent;
52pub mod tool_request;
53mod tools;
54pub mod transcript;
55pub mod working_docs;
56pub mod workspace_request;
57
58// Specialized agents
59pub mod specialized;
60
61// File-based subagent definitions
62pub use subagent_file::{SubagentDefinition, builtin_subagents};
63
64// Re-export tool crates
65#[cfg(feature = "command")]
66pub use aither_command as command;
67#[cfg(feature = "filesystem")]
68pub use aither_fs as filesystem;
69#[cfg(feature = "webfetch")]
70pub use aither_webfetch as webfetch;
71#[cfg(feature = "websearch")]
72pub use aither_websearch as websearch;
73
74// Sandbox is always available (terminal-first design)
75pub use aither_sandbox as sandbox;
76
77// Public API
78pub use agent::{Agent, CompactResult};
79pub use browser_backend::{BrowserBackend, BrowserBackendError, StaticCdpBrowser};
80pub use builder::AgentBuilder;
81pub use cache_stats::CacheStats;
82pub use checkpoint::AgentCheckpoint;
83pub use compression::{
84    CompressionLevel, ContextStrategy, PreserveConfig, PreservedContent, SmartCompressionConfig,
85};
86pub use config::{AgentConfig, AgentKind, ContextAssemblerConfig};
87pub use context::{Context, ContextCheckpoint, ReassemblyReport};
88pub use context_window::{ContextWindowMetrics, ContextWindowPhase, ContextWindowSnapshot};
89pub use error::AgentError;
90pub use event::AgentEvent;
91pub use handoff::HandoffDocument;
92pub use hook::{
93    CheckpointContext, CheckpointReason, HCons, Hook, PostToolAction, PreToolAction, StopContext,
94    StopReason, ToolResultContext, ToolUseContext, TurnBoundaryAction, TurnBoundaryContext,
95};
96pub use stream::AgentStream;
97pub use terminal_agent::{Prepared, TerminalAgentBuilder, Unprepared};
98pub use tools::AgentTools;
99
100// Model groups for budget tracking and fallback
101pub use model_group::{
102    Budget, BudgetedModel, ModelGroup, ModelGroupError, ModelTier, TieredModels,
103};
104
105// Re-export core tool trait for convenience
106pub use aither_attachments::{CacheEntry, FileCache};
107pub use aither_core::llm::Tool;
108
109/// Default system prompt for terminal-first agents.
110///
111/// This prompt teaches the LLM to use `terminal` as the primary tool interface,
112/// with all capabilities exposed as CLI commands that can be piped and composed.
113///
114/// # Example
115///
116/// ```rust,ignore
117/// use aither_agent::{Agent, TERMINAL_SYSTEM_PROMPT};
118///
119/// let agent = Agent::builder(llm)
120///     .system_prompt(TERMINAL_SYSTEM_PROMPT)
121///     .terminal(permission_handler, config, output_store)
122///     .build();
123/// ```
124pub const TERMINAL_SYSTEM_PROMPT: &str = include_str!("prompts/system.md");