Skip to main content

agent_core_runtime/agent/
mod.rs

1//! Agent Infrastructure
2//!
3//! Core infrastructure for building LLM-powered agents.
4//!
5//! This module provides:
6//! - AgentCore - Complete working agent infrastructure
7//! - Message types for Frontend-Controller communication
8//! - Input routing between Frontend and controller
9//! - Logging infrastructure
10//! - Configuration management with trait-based customization
11//!
12//! # Quick Start (Headless)
13//!
14//! ```ignore
15//! use agent_core_runtime::agent::{AgentConfig, AgentCore};
16//!
17//! struct MyConfig;
18//! impl AgentConfig for MyConfig {
19//!     fn config_path(&self) -> &str { ".myagent/config.yaml" }
20//!     fn default_system_prompt(&self) -> &str { "You are helpful." }
21//!     fn log_prefix(&self) -> &str { "myagent" }
22//!     fn name(&self) -> &str { "MyAgent" }
23//! }
24//!
25//! fn main() -> std::io::Result<()> {
26//!     let mut core = AgentCore::new(&MyConfig)?;
27//!     core.start_background_tasks();
28//!
29//!     // Get channels for custom frontend integration
30//!     let tx = core.to_controller_tx();
31//!     let rx = core.take_from_controller_rx();
32//!
33//!     // Create a session and interact programmatically
34//!     let (session_id, model, _) = core.create_initial_session()?;
35//!     // ... implement your own event loop
36//!
37//!     core.shutdown();
38//!     Ok(())
39//! }
40//! ```
41
42mod config;
43mod core;
44mod environment;
45mod error;
46pub mod interface;
47mod logger;
48mod messages;
49mod providers;
50mod router;
51
52pub use config::{load_config, AgentConfig, ConfigError, ConfigFile, LLMRegistry, ProviderConfig, SimpleConfig};
53
54// Re-export commonly used interface types at agent level for convenience
55pub use interface::{
56    // Sink types
57    ChannelEventSink, EventSink, SendError, SimpleEventSink,
58    // Source types
59    ChannelInputSource, InputSource,
60    // Policy types
61    AutoApprovePolicy, DenyAllPolicy, InteractivePolicy, PermissionPolicy, PolicyDecision,
62};
63pub use environment::EnvironmentContext;
64pub use providers::{get_provider_info, is_known_provider, list_providers, ProviderInfo};
65pub use error::AgentError;
66pub use core::{
67    convert_controller_event_to_ui_message, AgentCore, FromControllerRx, FromControllerTx,
68    ToControllerRx, ToControllerTx,
69};
70pub use logger::Logger;
71pub use messages::channels::{create_channels, DEFAULT_CHANNEL_SIZE};
72pub use messages::UiMessage;
73pub use router::InputRouter;
74
75// Re-export common types from llm-controller-rs that agents typically need
76pub use crate::controller::{
77    ControllerEvent, ControllerInputPayload, LLMController, LLMSessionConfig, PermissionRegistry,
78    ToolResultStatus, TurnId, UserInteractionRegistry,
79};