Skip to main content

Crate regula_core

Crate regula_core 

Source
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 GraphState trait and channel system for managing graph state.
  • Nodes: The Node trait for defining graph nodes (agents, tools, etc.).
  • Edges: Normal and conditional edges for graph control flow.
  • Graph: The StateGraph builder and CompiledStateGraph for 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.

Attribute Macros§

async_trait