Skip to main content

simple_agents_workflow/
lib.rs

1//! Workflow IR and validation primitives for SimpleAgents.
2//!
3//! This crate currently provides:
4//! - A minimal canonical workflow IR (`start`, `llm`, `tool`, `condition`, `loop`, `end`)
5//! - Deterministic normalization helpers
6//! - Structural validation with actionable diagnostics
7//! - Runtime execution for the minimal node set
8//! - In-process worker protocol and bounded worker pool primitives
9//! - Worker pool adapter hook for external (for example gRPC) worker clients
10//!
11//! # Example
12//!
13//! ```rust
14//! use simple_agents_workflow::{Node, NodeKind, WorkflowDefinition, validate_and_normalize};
15//!
16//! let workflow = WorkflowDefinition {
17//!     version: "v0".into(),
18//!     name: "hello".into(),
19//!     nodes: vec![
20//!         Node { id: "start".into(), kind: NodeKind::Start { next: "end".into() } },
21//!         Node { id: "end".into(), kind: NodeKind::End },
22//!     ],
23//! };
24//!
25//! let normalized = validate_and_normalize(&workflow).unwrap();
26//! assert_eq!(normalized.name, "hello");
27//! ```
28
29pub mod checkpoint;
30pub mod debug;
31pub mod expressions;
32pub mod ir;
33pub mod observability;
34pub mod recorder;
35pub mod replay;
36pub mod runtime;
37pub mod scheduler;
38pub mod state;
39pub mod trace;
40pub mod validation;
41pub mod visualize;
42pub mod worker;
43pub mod worker_adapter;
44pub mod yaml_runner;
45
46pub use checkpoint::{
47    CheckpointError, CheckpointStore, FilesystemCheckpointStore, WorkflowCheckpoint,
48};
49pub use debug::{
50    inspect_replay_trace, node_timeline, retry_reason_summary, NodeTimelineEntry,
51    ReplayTraceInspection, RetryReasonSummary,
52};
53pub use expressions::{
54    default_expression_engine, evaluate_bool, ExpressionBackend, ExpressionEngine, ExpressionError,
55    ExpressionLimits,
56};
57pub use ir::{MergePolicy, Node, NodeKind, ReduceOperation, RouterRoute, WorkflowDefinition};
58pub use recorder::{TraceRecordError, TraceRecorder};
59pub use replay::{
60    replay_trace, replay_trace_with_options, ReplayCachePolicy, ReplayError, ReplayOptions,
61    ReplayReport, ReplayViolation, ReplayViolationCode,
62};
63pub use runtime::{
64    CancellationSignal, LlmExecutionError, LlmExecutionInput, LlmExecutionOutput, LlmExecutor,
65    NodeExecution, NodeExecutionData, NodeExecutionPolicy, RuntimeSecurityLimits, ScopeAccessError,
66    ToolExecutionError, ToolExecutionInput, ToolExecutor, WorkflowEvent, WorkflowEventKind,
67    WorkflowReplayMode, WorkflowRetryEvent, WorkflowRunResult, WorkflowRuntime,
68    WorkflowRuntimeError, WorkflowRuntimeOptions,
69};
70pub use scheduler::DagScheduler;
71pub use state::{CapabilityToken, ScopedState};
72pub use trace::{
73    TraceEvent, TraceEventKind, TraceSequence, TraceTerminalStatus, WorkflowTrace,
74    WorkflowTraceMetadata,
75};
76pub use validation::{
77    validate_and_normalize, Diagnostic, DiagnosticCode, Severity, ValidationError, ValidationErrors,
78};
79pub use visualize::workflow_to_mermaid;
80pub use worker::{
81    CircuitBreakerHooks, WorkerErrorCode, WorkerHandler, WorkerHealth, WorkerHealthStatus,
82    WorkerOperation, WorkerPool, WorkerPoolClient, WorkerPoolError, WorkerPoolOptions,
83    WorkerProtocolError, WorkerRequest, WorkerResponse, WorkerResult, WorkerSecurityPolicy,
84};
85pub use worker_adapter::WorkerPoolToolExecutor;
86pub use yaml_runner::{
87    run_email_workflow_yaml, run_email_workflow_yaml_file,
88    run_email_workflow_yaml_file_with_client,
89    run_email_workflow_yaml_file_with_client_and_custom_worker,
90    run_email_workflow_yaml_file_with_client_and_custom_worker_and_events,
91    run_email_workflow_yaml_with_client, run_email_workflow_yaml_with_client_and_custom_worker,
92    run_email_workflow_yaml_with_client_and_custom_worker_and_events,
93    run_email_workflow_yaml_with_custom_worker,
94    run_email_workflow_yaml_with_custom_worker_and_events, run_workflow_yaml,
95    run_workflow_yaml_file, run_workflow_yaml_file_with_client,
96    run_workflow_yaml_file_with_client_and_custom_worker,
97    run_workflow_yaml_file_with_client_and_custom_worker_and_events,
98    run_workflow_yaml_file_with_client_and_custom_worker_and_events_and_options,
99    run_workflow_yaml_with_client, run_workflow_yaml_with_client_and_custom_worker,
100    run_workflow_yaml_with_client_and_custom_worker_and_events,
101    run_workflow_yaml_with_client_and_custom_worker_and_events_and_options,
102    run_workflow_yaml_with_custom_worker, run_workflow_yaml_with_custom_worker_and_events,
103    run_workflow_yaml_with_custom_worker_and_events_and_options, verify_yaml_workflow,
104    yaml_workflow_file_to_mermaid, yaml_workflow_to_ir, yaml_workflow_to_mermaid,
105    NoopYamlWorkflowEventSink, WorkflowMessage, WorkflowMessageRole, WorkflowRunner,
106    YamlLlmExecutionRequest, YamlStepTiming, YamlToIrError, YamlWorkflow,
107    YamlWorkflowCustomWorkerExecutor, YamlWorkflowDiagnostic, YamlWorkflowDiagnosticSeverity,
108    YamlWorkflowEvent, YamlWorkflowEventSink, YamlWorkflowLlmExecutor, YamlWorkflowPayloadMode,
109    YamlWorkflowRunError, YamlWorkflowRunOptions, YamlWorkflowRunOutput,
110    YamlWorkflowTelemetryConfig, YamlWorkflowTraceContextInput, YamlWorkflowTraceOptions,
111    YamlWorkflowTraceTenantContext,
112};