Skip to main content

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
39pub use actions::{register_builtin_actions, MoveNode, SensorCheckNode, TimerNode, WanderNode};
40pub use behavior::{boxed_children_mut, BehaviorNode, BehaviorNodeExt, BoxedBehavior};
41pub use composition::{ParallelNode, ParallelPolicy, SelectOrNode, SequenceNode};
42pub use config::{
43    detect_project_root, get_current_environment, list_available_behaviors, load_behavior_config,
44    resolve_behavior_config_path, validate_behavior_composition_json, 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
52pub mod hot_reload;
53
54pub use mecha10_core::Context;
55
56/// Prelude module for convenient imports
57pub mod prelude {
58    pub use crate::actions::{MoveNode, SensorCheckNode, TimerNode, WanderNode};
59    pub use crate::behavior::{BehaviorNode, BehaviorNodeExt, BoxedBehavior};
60    pub use crate::composition::{ParallelNode, ParallelPolicy, SelectOrNode, SequenceNode};
61    pub use crate::config::{BehaviorConfig, CompositionConfig, NodeConfig, NodeReference, ParallelPolicyConfig};
62    pub use crate::execution::{BehaviorExecutor, ExecutionContext, ExecutionStats};
63    pub use crate::loader::BehaviorLoader;
64    pub use crate::registry::NodeRegistry;
65    pub use crate::status::NodeStatus;
66    pub use async_trait::async_trait;
67    pub use mecha10_core::Context;
68}