gemini_adk_fluent_rs/compose/mod.rs
1//! Composition modules -- S, C, P, M, T, A, E, G.
2//!
3//! Eight namespaces for composing different aspects of agent configuration.
4//! Two operators combine them, and each means one thing everywhere:
5//!
6//! - **`a >> b` — then.** Order matters: `b` applies after `a`, to what `a`
7//! produced. State transforms, context rewrites, middleware layers, and
8//! agent pipelines.
9//! - **`a + b` — together.** Both apply; neither sees the other's result.
10//! Prompt sections, tools, guards (every guard must pass), evaluation
11//! criteria, artifact declarations.
12//!
13//! Agents alone also take `|` (run in parallel), `*` (loop) and `/`
14//! (fallback); see [`operators`](crate::operators).
15//!
16//! | Module | Namespace | Operator | Purpose | Consumed by |
17//! |--------|-----------|----------|----------------------------|-------------|
18//! | S | `S::` | `>>` | State transforms | pipeline steps (`agent >> S::pick(..) >> agent`), loop and branch predicates |
19//! | C | `C::` | `>>` | Context rewrites | `AgentBuilder::context` |
20//! | M | `M::` | `>>` | Middleware layers | `.middleware(..)` |
21//! | P | `P::` | `+` | Prompt sections | `.instruction(..)` |
22//! | T | `T::` | `+` | Tools | `.tools(..)` |
23//! | G | `G::` | `+` | Output guards (all must pass) | `AgentBuilder::guard` |
24//! | E | `E::` | `+` | Evaluation criteria | `E::suite(..)` |
25//! | A | `A::` | `+` | Artifact declarations | `AgentBuilder::artifacts`, contract checks |
26//!
27//! # Quick Reference
28//!
29//! ```rust
30//! use gemini_adk_fluent_rs::compose::{S, C, P, T, A, E, G};
31//! use serde_json::json;
32//! use gemini_genai_rs::prelude::Content;
33//!
34//! // S: State transforms — pick, rename, chain with >>
35//! let transform = S::pick(&["a", "b"]) >> S::rename(&[("a", "x")]);
36//!
37//! // C: Context rewrites — applied in order with >>
38//! let context = C::window(10) >> C::user_only();
39//!
40//! // P: Prompt sections — role, task, format, together with +
41//! let prompt = P::role("analyst") + P::task("analyze data") + P::format("JSON");
42//!
43//! // T: Tools — built-ins and custom, together with +
44//! let tools = T::google_search() + T::code_execution();
45//!
46//! // A: Artifact declarations — inputs and outputs, together with +
47//! let artifacts = A::json_output("report", "Analysis report")
48//! + A::text_input("source", "Source document");
49//!
50//! // E: Evaluation — deterministic criteria together with + (LLM-judge
51//! // criteria like E::safety(llm) take a judge model).
52//! let eval = E::response_match() + E::contains_match();
53//!
54//! // G: Guards — output validation, all must pass, together with +
55//! let guards = G::length(1, 1000) + G::json();
56//! ```
57
58pub mod artifacts;
59pub mod context;
60pub mod ctx;
61pub mod eval;
62pub mod guards;
63pub mod judge;
64pub mod middleware;
65pub mod prompt;
66pub mod state;
67pub mod tools;
68
69pub use artifacts::{A, ArtifactOp};
70pub use context::C;
71pub use ctx::Ctx;
72pub use eval::E;
73pub use guards::G;
74pub use middleware::M;
75pub use prompt::P;
76pub use state::S;
77pub use tools::T;