Skip to main content

agent_air_runtime/agent/
mod.rs

1//! Agent Infrastructure
2//!
3//! Core infrastructure for building LLM-powered agents.
4//!
5//! This module provides:
6//! - AgentAir - 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_air_runtime::agent::{AgentConfig, AgentAir};
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 = AgentAir::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::{
53    AgentConfig, ConfigError, ConfigFile, LLMRegistry, ProviderConfig, SimpleConfig, load_config,
54};
55
56// Re-export commonly used interface types at agent level for convenience
57pub use core::{
58    AgentAir, FromControllerRx, FromControllerTx, ToControllerRx, ToControllerTx,
59    convert_controller_event_to_ui_message,
60};
61pub use environment::EnvironmentContext;
62pub use error::AgentError;
63pub use interface::{
64    // Policy types
65    AutoApprovePolicy,
66    // Sink types
67    ChannelEventSink,
68    // Source types
69    ChannelInputSource,
70    DenyAllPolicy,
71    EventSink,
72    InputSource,
73    InteractivePolicy,
74    PermissionPolicy,
75    PolicyDecision,
76    SendError,
77    SimpleEventSink,
78};
79pub use logger::Logger;
80pub use messages::UiMessage;
81pub use messages::channels::{DEFAULT_CHANNEL_SIZE, create_channels};
82pub use providers::{ProviderInfo, get_provider_info, is_known_provider, list_providers};
83pub use router::InputRouter;
84
85// Re-export common types from llm-controller-rs that agents typically need
86pub use crate::controller::{
87    ControllerEvent, ControllerInputPayload, LLMController, LLMSessionConfig, PermissionRegistry,
88    ToolResultStatus, TurnId, UserInteractionRegistry,
89};