feagi_agent/sdk/base/controller.rs
1// Copyright 2025 Neuraville Inc.
2// SPDX-License-Identifier: Apache-2.0
3
4//! Controller trait and base implementations
5
6use crate::sdk::error::Result;
7use feagi_structures::genomic::cortical_area::CorticalID;
8
9/// Core controller trait
10///
11/// Implement this trait to create custom controllers that follow FEAGI conventions.
12///
13/// # Example
14/// ```ignore
15/// use feagi_agent::sdk::base::Controller;
16///
17/// struct MyController {
18/// // ... fields
19/// }
20///
21/// #[async_trait::async_trait]
22/// impl Controller for MyController {
23/// fn controller_type(&self) -> &str { "my-custom" }
24/// fn agent_id(&self) -> &str { &self.agent_id }
25/// async fn start(&mut self) -> Result<()> { /* ... */ }
26/// async fn stop(&mut self) -> Result<()> { /* ... */ }
27/// fn is_running(&self) -> bool { /* ... */ }
28/// fn cortical_ids(&self) -> &[CorticalID] { /* ... */ }
29/// }
30/// ```
31#[async_trait::async_trait]
32pub trait Controller: Send + Sync {
33 /// Controller type identifier (e.g., "video", "text", "audio")
34 fn controller_type(&self) -> &str;
35
36 /// Get the agent ID this controller manages
37 fn agent_id(&self) -> &str;
38
39 /// Start the controller (connect to FEAGI, begin operation)
40 async fn start(&mut self) -> Result<()>;
41
42 /// Stop the controller gracefully
43 async fn stop(&mut self) -> Result<()>;
44
45 /// Check if controller is currently running
46 fn is_running(&self) -> bool;
47
48 /// Get cortical IDs this controller produces/consumes
49 fn cortical_ids(&self) -> &[CorticalID];
50}