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
88
89
90
//! # Functional API for Graph Workflows
//!
//! The Functional API provides a higher-level programming model for `adk-graph`
//! that allows developers to write agent workflows as normal async Rust functions
//! with automatic checkpointing, typed state reducers, and interrupt/resume support.
//!
//! ## Overview
//!
//! Rather than manually constructing nodes, edges, and routers, developers annotate
//! functions with `#[entrypoint]` and `#[task]` macros and use standard Rust control
//! flow (`if`, `for`, `match`, `loop`) to express workflow logic.
//!
//! This module is gated behind the `functional` feature flag.
//!
//! ## Features
//!
//! - **[`TaskContext`]**: Runtime context for tasks providing state, checkpointing, and streaming
//! - **[`ReducedValue<T>`](ReducedValue)**: Append-only state container persisted across checkpoints
//! - **[`UntrackedValue<T>`](UntrackedValue)**: Transient state container excluded from checkpoints
//! - **[`MessagesValue`]**: Chat message container with ID-based deduplication
//! - **[`TypedReducer`]**: Custom merge strategies for typed state values
//! - **[`ExecutionLog`]**: Task completion tracking for resume-skip behavior
//! - **[`StateSchemaValidator`]**: Schema validation for initial state and task output
//!
//! ## Quick Start
//!
//! ```rust,ignore
//! use adk_graph::functional::{TaskContext, ReducedValue, MessagesValue};
//! use adk_rust_macros::{entrypoint, task};
//!
//! #[task]
//! async fn fetch_data(ctx: &mut TaskContext) -> Result<String, FunctionalError> {
//! ctx.emit(serde_json::json!({"status": "fetching"})).await;
//! Ok("data result".to_string())
//! }
//!
//! #[task(retry(max_attempts = 3, backoff = "1s"))]
//! async fn process(ctx: &mut TaskContext, data: &str) -> Result<String, FunctionalError> {
//! Ok(format!("processed: {data}"))
//! }
//!
//! #[entrypoint]
//! async fn my_workflow(ctx: &mut TaskContext) -> Result<(), FunctionalError> {
//! let data = fetch_data(ctx).await?;
//! let result = process(ctx, &data).await?;
//! ctx.set("output", serde_json::json!(result));
//! Ok(())
//! }
//! ```
//!
//! ## Typed State Reducers
//!
//! ```rust,ignore
//! use adk_graph::functional::{ReducedValue, UntrackedValue, MessagesValue, ChatMessage, MessageRole};
//!
//! // Append-only accumulator — persisted across checkpoints
//! let mut results: ReducedValue<String> = ReducedValue::default();
//! results.push("step 1 output".to_string());
//! results.push("step 2 output".to_string());
//! assert_eq!(results.len(), 2);
//!
//! // Transient value — excluded from checkpoints
//! let mut temp: UntrackedValue<Vec<u8>> = UntrackedValue::default();
//! temp.set(vec![1, 2, 3]);
//!
//! // Chat messages with deduplication
//! let mut messages = MessagesValue::default();
//! messages.push(ChatMessage {
//! id: "msg-1".to_string(),
//! role: MessageRole::User,
//! content: "Hello".to_string(),
//! metadata: Default::default(),
//! });
//! ```
pub use TaskContext;
pub use FunctionalError;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;