Expand description
REGULA Core - Core abstractions for the REGULA agentic orchestration framework.
This crate provides the fundamental building blocks for constructing LangGraph-style agent graphs in Rust:
- State: The
GraphStatetrait and channel system for managing graph state. - Nodes: The
Nodetrait for defining graph nodes (agents, tools, etc.). - Edges: Normal and conditional edges for graph control flow.
- Graph: The
StateGraphbuilder andCompiledStateGraphfor execution.
§Example
ⓘ
use regula_core::prelude::*;
#[derive(Clone, Serialize, Deserialize)]
struct MyState {
messages: Vec<String>,
done: bool,
}
impl GraphState for MyState {
fn channels() -> HashMap<String, ChannelSpec> {
let mut channels = HashMap::new();
channels.insert("messages".to_string(), ChannelSpec::LastValue);
channels.insert("done".to_string(), ChannelSpec::LastValue);
channels
}
}
let graph = StateGraph::<MyState>::new()
.add_node("agent", node_fn(|state, config| async {
Ok(NodeOutput::update(json!({"messages": ["Hello!"]})))
}))
.add_edge(start(), "agent")
.add_edge("agent", end())
.compile(Default::default())?;Re-exports§
pub use channel::Channel;pub use channel::ChannelSpec;pub use config::ConfigSnapshot;pub use config::RunnableConfig;pub use constants::end;pub use constants::start;pub use constants::NodeId;pub use constants::END_NODE;pub use constants::START_NODE;pub use edge::async_router_fn;pub use edge::router_fn;pub use edge::Edge;pub use edge::EdgeRouter;pub use edge::RouteOutput;pub use error::RegulaError;pub use error::Result;pub use graph::CompileConfig;pub use graph::CompiledStateGraph;pub use graph::StateGraph;pub use node::node_fn;pub use node::node_fn_named;pub use node::BoxedNode;pub use node::Command;pub use node::CommandGoto;pub use node::Node;pub use node::NodeOutput;pub use node::RetryPolicy;pub use state::DynState;pub use state::GraphState;pub use serde;pub use serde_json;
Modules§
- channel
- Channel system for state management.
- config
- Runtime configuration for graph execution.
- constants
- Constants and fundamental types for REGULA framework.
- edge
- Edge types and routing logic.
- error
- Error types for REGULA framework.
- graph
- StateGraph builder and compilation.
- node
- Node trait and related types.
- prelude
- Prelude module for convenient imports.
- state
- GraphState trait and related types.
Macros§
- partial_
state - Macro to create a partial state update.