Skip to main content

agent_core/
lib.rs

1//! Agent Core
2//!
3//! A Rust Framework for building TUI Agents powered by large language models.
4//!
5//! This is a meta-crate that re-exports from:
6//! - `agent-core-runtime` - Core runtime (always included)
7//! - `agent-core-tui` - TUI frontend (optional, enabled by default)
8//!
9//! ## Features
10//!
11//! - `tui` (default) - Include the TUI frontend
12//!
13//! ## Quick Start (with TUI)
14//!
15//! ```ignore
16//! use agent_core::agent::{AgentConfig, AgentCore};
17//! use agent_core::tui::AgentCoreExt;
18//!
19//! struct MyConfig;
20//! impl AgentConfig for MyConfig {
21//!     fn config_path(&self) -> &str { ".myagent/config.yaml" }
22//!     fn default_system_prompt(&self) -> &str { "You are helpful." }
23//!     fn log_prefix(&self) -> &str { "myagent" }
24//!     fn name(&self) -> &str { "MyAgent" }
25//! }
26//!
27//! fn main() -> std::io::Result<()> {
28//!     let agent = AgentCore::new(&MyConfig)?;
29//!     agent.into_tui().run()
30//! }
31//! ```
32//!
33//! ## Headless Usage (without TUI)
34//!
35//! ```ignore
36//! use agent_core::agent::{AgentConfig, AgentCore};
37//!
38//! struct MyConfig;
39//! impl AgentConfig for MyConfig {
40//!     fn config_path(&self) -> &str { ".myagent/config.yaml" }
41//!     fn default_system_prompt(&self) -> &str { "You are helpful." }
42//!     fn log_prefix(&self) -> &str { "myagent" }
43//!     fn name(&self) -> &str { "MyAgent" }
44//! }
45//!
46//! fn main() -> std::io::Result<()> {
47//!     let mut core = AgentCore::new(&MyConfig)?;
48//!     core.start_background_tasks();
49//!
50//!     // Get channels for custom frontend integration
51//!     let tx = core.to_controller_tx();
52//!     let rx = core.take_from_controller_rx();
53//!
54//!     // Create a session and interact programmatically
55//!     let (session_id, model, _) = core.create_initial_session()?;
56//!     // ... implement your own event loop
57//!
58//!     core.shutdown();
59//!     Ok(())
60//! }
61//! ```
62
63// Re-export everything from the runtime crate
64pub use agent_core_runtime::*;
65
66// Re-export the TUI crate when the feature is enabled
67#[cfg(feature = "tui")]
68pub mod tui {
69    //! TUI frontend for agent-core.
70    //!
71    //! This module provides a ratatui-based terminal interface for agents.
72    //! Use `AgentCoreExt::into_tui()` to convert an `AgentCore` into a `TuiRunner`.
73
74    pub use agent_core_tui::*;
75}