feagi_agent/lib.rs
1// Copyright 2025 Neuraville Inc.
2// SPDX-License-Identifier: Apache-2.0
3
4//! # FEAGI Agent Library
5//!
6//! Complete toolkit for building FEAGI agents, from low-level protocol to high-level controllers.
7//!
8//! ## Core Module
9//!
10//! Low-level agent protocol implementation (always available):
11//! - [`core::AgentClient`] - Connect to FEAGI, manage lifecycle
12//! - [`core::AgentConfig`] - Configuration builder
13//! - [`core::AgentType`] - Agent type (Sensory, Motor, Both)
14//!
15//! ## SDK Module (Optional)
16//!
17//! High-level tools for building controllers (enabled with `sdk` feature):
18//! - [`sdk::base::Controller`] - Controller trait
19//! - [`sdk::base::TopologyCache`] - Topology fetching and caching
20//! - [`sdk::sensory::SensoryEncoder`] - Trait for encoding sensory data
21//! - [`sdk::motor::MotorDecoder`] - Trait for decoding motor data
22//!
23//! ## Examples
24//!
25//! ### Using Core Only (Minimal Agent)
26//!
27//! ```ignore
28//! use feagi_agent::core::{AgentClient, AgentConfig, AgentType};
29//!
30//! let config = AgentConfig::new("my-agent", AgentType::Sensory)
31//! .with_registration_endpoint("tcp://localhost:30001")
32//! .with_sensory_endpoint("tcp://localhost:5555");
33//!
34//! let mut client = AgentClient::new(config)?;
35//! client.connect()?;
36//! client.send_sensory_bytes(data)?;
37//! ```
38//!
39//! ### Building a Controller with SDK
40//!
41//! ```ignore
42//! use feagi_agent::sdk::sensory::video::{VideoEncoder, VideoEncoderConfig};
43//! use feagi_agent::sdk::base::TopologyCache;
44//! use feagi_agent::core::{AgentClient, AgentConfig};
45//!
46//! // Create topology cache (shared across encoders)
47//! let topology_cache = TopologyCache::new("localhost", 8080, 5.0)?;
48//!
49//! // Create video encoder
50//! let encoder = VideoEncoder::new(config, &topology_cache).await?;
51//!
52//! // Create agent client
53//! let mut client = AgentClient::new(agent_config)?;
54//! client.connect()?;
55//!
56//! // Encode and send frames
57//! let encoded = encoder.encode(&frame)?;
58//! client.send_sensory_bytes(encoded)?;
59//! ```
60
61pub mod core;
62
63// Re-export core types at top level for convenience
64pub use core::{AgentClient, AgentConfig, AgentType, Result, SdkError};
65
66// SDK module (behind feature flag)
67#[cfg(feature = "sdk")]
68pub mod sdk;
69
70#[cfg(test)]
71mod tests {
72 use super::*;
73
74 #[test]
75 fn test_core_imports() {
76 // Verify all main types are accessible
77 let _config = AgentConfig::new("test", AgentType::Sensory);
78 }
79}