Skip to main content

lellm_graph/
lib.rs

1//! lellm-graph — Graph/Node/Edge 编排层 + 状态管理 + Checkpoint。
2//!
3//! 通用工作流引擎(类似 LangGraph / Temporal / Prefect)。
4
5pub mod barrier_node;
6pub mod branch_state;
7pub mod checkpoint;
8pub mod delta;
9pub mod error;
10pub mod event;
11pub mod executor;
12pub mod graph;
13pub mod hook;
14pub mod ids;
15pub mod node;
16pub mod node_context;
17pub mod parallel_node;
18pub mod runtime_event;
19pub mod state;
20pub mod statekey;
21pub mod store;
22pub mod stream_chunk;
23pub mod stream_emitter;
24pub mod workflow_state;
25
26// ─── IDs ─────────────────────────────────────────────────────
27pub use checkpoint::TraceId;
28pub use ids::SpanId;
29
30// ─── State ───────────────────────────────────────────────────
31pub use state::{
32    ExecutionEntry, GraphResult, State, StateEffect, StateError, StateExt, StateMerge,
33    StateReducer, array_reducer,
34};
35
36// ─── Delta + Reducer ─────────────────────────────────────────
37pub use delta::{DeltaOp, DeltaSource, Reducer, ReducerRegistry, StateDelta};
38
39// ─── StateKey ────────────────────────────────────────────────
40pub use statekey::{
41    SK_COUNT, SK_ITERATIONS, SK_MESSAGES, SK_OUTPUT_TOKENS, SK_PENDING_TOOL_CALLS,
42    SK_REASONING_TOKENS, SK_STEPS, SK_TOTAL_TOOL_CALLS, StateKey, StateKeyExt,
43};
44
45// ─── Checkpoint ──────────────────────────────────────────────
46pub use checkpoint::{
47    Checkpoint, CheckpointId, CheckpointPolicy, CheckpointStore, CheckpointStoreError, NodeId,
48};
49
50// ─── Store ───────────────────────────────────────────────────
51pub use store::InMemoryCheckpointStore;
52
53// ─── Error Types ─────────────────────────────────────────────
54pub use error::{
55    BuildError, BuildErrors, Diagnostic, DiagnosticCategory, DiagnosticSeverity, GraphDiagnostics,
56    GraphError, ObservedError, TerminalError,
57};
58
59// ─── Events ──────────────────────────────────────────────────
60pub use event::{
61    BarrierDecision, BarrierId, FlowEvent, GraphEvent, GraphExecution, GraphHandle, GraphStream,
62};
63
64// ─── Graph ───────────────────────────────────────────────────
65pub use graph::{CycleAnalysis, Edge, Graph, GraphBuilder};
66
67// ─── Nodes ───────────────────────────────────────────────────
68pub use node::{
69    BarrierDefaultAction, BarrierNode, BranchCondition, ConditionNode, ConditionNodeBuilder,
70    FlowNode, NextStep, NodeKind, NodeOutput, ParallelErrorStrategy, ParallelNode,
71    ParallelNodeBuilder, TaskFn, TaskNode,
72};
73
74// ─── Executor ────────────────────────────────────────────────
75pub use executor::GraphExecutor;
76
77// ─── Hooks ───────────────────────────────────────────────────
78pub use hook::{AgentHook, NoOpHook, TracingHook};
79
80// ─── v04: NodeContext + BranchState + Stream ──────────────────
81pub use branch_state::{BranchState, ChangeOperation, ChangeRecord};
82pub use node_context::{ExecutionControl, ExecutionSignal, NextAction, NodeContext, NodeMetadata};
83pub use runtime_event::RuntimeEvent;
84pub use stream_chunk::StreamChunk;
85pub use stream_emitter::StreamEmitter;
86pub use workflow_state::{Effect, LastWriteWins, MergeStrategy, WorkflowError, WorkflowState};
87
88// ─── Trace ───────────────────────────────────────────────────
89pub mod trace;
90pub use trace::{
91    ExecutionTrace, ExportedTrace, ExportedTraceStep, MemoryTraceSink, TraceSink, TraceStep,
92};