gemini_adk_fluent_rs/compose/ctx.rs
1//! Ctx — Declarative state-to-narrative context composition.
2//!
3//! Builds a [`ContextBuilder`] that renders session state into a
4//! natural-language summary appended to the phase instruction.
5//!
6//! # Example
7//!
8//! ```no_run
9//! use gemini_adk_fluent_rs::prelude::*;
10//!
11//! let ctx = Ctx::section("Caller")
12//! .field("caller_name", "Name")
13//! .flag("is_known_contact", "Known contact")
14//! .section("Call")
15//! .field("call_purpose", "Purpose")
16//! .sentiment("caller_sentiment")
17//! .build();
18//!
19//! // Use with phase_defaults:
20//! Live::builder()
21//! .phase_defaults(|d| d.context(ctx));
22//! ```
23
24pub use gemini_adk_rs::live::context_builder::{ContextBuilder, SectionBuilder};
25
26/// The `Ctx` namespace — factory methods for declarative context builders.
27pub struct Ctx;
28
29impl Ctx {
30 /// Start a context with its first section, labelled `name`.
31 ///
32 /// Returns a [`SectionBuilder`] — add fields, flags, sentiments, open
33 /// further sections with `.section(..)`, then call `.build()` to get a
34 /// [`ContextBuilder`].
35 ///
36 /// # Example
37 ///
38 /// ```
39 /// # use gemini_adk_fluent_rs::prelude::*;
40 /// let ctx = Ctx::section("Caller")
41 /// .field("caller_name", "Name")
42 /// .field("caller_organization", "Organization")
43 /// .flag("is_known_contact", "Known contact")
44 /// .section("Call")
45 /// .field("call_purpose", "Purpose")
46 /// .sentiment("caller_sentiment")
47 /// .build();
48 /// ```
49 pub fn section(name: &str) -> SectionBuilder {
50 ContextBuilder::new().section(name)
51 }
52}