1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
//! # langgraph4rust
//!
//! A Rust implementation of a workflow engine inspired by Python's LangGraph library.
//! This crate provides a flexible and powerful way to build, execute, and manage
//! stateful workflow graphs with support for parallel execution and conditional routing.
//!
//! ## Features
//!
//! - **Declarative Graph Building**: Define workflows using a builder pattern
//! - **Parallel Execution**: Multiple nodes can execute simultaneously when possible
//! - **Conditional Routing**: Dynamic path selection based on state conditions
//! - **State Management**: Built-in JSON-based state persistence with type safety
//! - **Extensible Architecture**: Custom node implementations via traits
//! - **Validation**: Comprehensive graph validation before execution
//!
//! ## Quick Start
//!
//! ```rust
//! use langgraph4rust::*;
//! use std::collections::HashSet;
//! use std::sync::Arc;
//! use async_trait::async_trait;
//!
//! // Define a custom node
//! #[derive(Clone)]
//! struct GreetingNode;
//!
//! #[async_trait]
//! impl AgentNode<DefaultMemoryState> for GreetingNode {
//! async fn apply(&self, state: Arc<DefaultMemoryState>) -> Result<(), LangGraphError> {
//! state.set("message", "Hello from langgraph4rust!").await?;
//! Ok(())
//! }
//! }
//!
//! #[tokio::main]
//! async fn main() -> Result<(), LangGraphError> {
//! let mut builder = StateGraphBuilder::new();
//!
//! builder.add_node("greet", Box::new(GreetingNode));
//! builder.add_edge(START_NODE, HashSet::from(["greet".to_string()]));
//! builder.add_edge("greet", HashSet::from([END_NODE.to_string()]));
//!
//! let graph = builder.compile()?;
//! let state = Arc::new(DefaultMemoryState::new());
//!
//! graph.invoke(state).await?;
//!
//! Ok(())
//! }
//! ```
//!
//! ## Core Concepts
//!
//! ### Nodes
//! Nodes are the basic building blocks of your workflow. Each node implements the
//! [`AgentNode`] trait and contains the logic to process and modify the state.
//!
//! ### Edges
//! Edges define the flow between nodes. There are two types:
//! - **Static edges**: Always connect to the same target nodes
//! - **Conditional edges**: Dynamically choose targets based on current state
//!
//! ### State
//! The state is shared across all nodes and persists throughout the workflow execution.
//! By default, [`DefaultMemoryState`] provides JSON-based storage.
//!
//! ## Examples
//!
//! See the `examples/` directory for complete working examples including:
//! - Simple linear workflows
//! - Parallel execution patterns
//! - Conditional routing
//! - Custom state implementations
//!
//! ## License
//!
//! Apache License 2.0
pub use async_trait;
pub use AgentNode;
pub use ;
pub use LangGraphError;
pub use StateGraph;
pub use ;