mecha10_behavior_runtime/
lib.rs

1//! Mecha10 Behavior Runtime
2//!
3//! This crate provides a unified behavior composition system for robotics and AI.
4//! All behaviors implement the `BehaviorNode` trait with a simple tick-based interface.
5//!
6//! # Philosophy
7//!
8//! - **Behavior Logic** = Rust code (complex logic, high performance)
9//! - **Behavior Composition** = JSON config (simple orchestration, hot-reloadable)
10//! - **Configuration** = JSON with validation (parameters only)
11//!
12//! # Example
13//!
14//! ```rust
15//! use mecha10_behavior_runtime::{BehaviorNode, NodeStatus, Context};
16//! use async_trait::async_trait;
17//!
18//! #[derive(Debug)]
19//! struct MyBehavior;
20//!
21//! #[async_trait]
22//! impl BehaviorNode for MyBehavior {
23//!     async fn tick(&mut self, ctx: &Context) -> anyhow::Result<NodeStatus> {
24//!         // Your behavior logic here
25//!         Ok(NodeStatus::Success)
26//!     }
27//! }
28//! ```
29
30pub mod actions;
31mod behavior;
32mod composition;
33pub mod config;
34mod execution;
35mod loader;
36mod registry;
37mod status;
38
39// Re-export core types
40pub use actions::{register_builtin_actions, MoveNode, SensorCheckNode, TimerNode, WanderNode};
41pub use behavior::{BehaviorNode, BehaviorNodeExt, BoxedBehavior};
42pub use composition::{ParallelNode, ParallelPolicy, SelectOrNode, SequenceNode};
43pub use config::{
44    detect_project_root, get_current_environment, load_behavior_config, validate_behavior_config, BehaviorConfig,
45    CompositionConfig, NodeConfig, NodeReference, ParallelPolicyConfig, ValidationResult,
46};
47pub use execution::{BehaviorExecutor, ExecutionContext, ExecutionStats};
48pub use loader::BehaviorLoader;
49pub use registry::NodeRegistry;
50pub use status::NodeStatus;
51
52// Re-export hot-reload module as public
53pub mod hot_reload;
54
55// Re-export mecha10-core Context
56pub use mecha10_core::Context;
57
58/// Prelude module for convenient imports
59pub mod prelude {
60    pub use crate::actions::{MoveNode, SensorCheckNode, TimerNode, WanderNode};
61    pub use crate::behavior::{BehaviorNode, BehaviorNodeExt, BoxedBehavior};
62    pub use crate::composition::{ParallelNode, ParallelPolicy, SelectOrNode, SequenceNode};
63    pub use crate::config::{BehaviorConfig, CompositionConfig, NodeConfig, NodeReference, ParallelPolicyConfig};
64    pub use crate::execution::{BehaviorExecutor, ExecutionContext, ExecutionStats};
65    pub use crate::loader::BehaviorLoader;
66    pub use crate::registry::NodeRegistry;
67    pub use crate::status::NodeStatus;
68    pub use async_trait::async_trait;
69    pub use mecha10_core::Context;
70}