Skip to main content

adk_rs_fluent/
lib.rs

1#![warn(missing_docs)]
2//! # adk-rs-fluent
3//!
4//! Fluent developer experience layer for the Gemini Live agent stack.
5//! This is the highest-level crate in the workspace, providing a builder API,
6//! operator algebra, and composition modules that sit on top of
7//! [`rs_adk`] (agent runtime) and [`rs_genai`] (wire protocol).
8//!
9//! ## Module Organization
10//!
11//! | Module | Purpose |
12//! |--------|---------|
13//! | [`builder`] | Copy-on-write immutable `AgentBuilder` for declarative agent configuration |
14//! | [`compose`] | S·C·T·P·M·A operator algebra for composing agent primitives |
15//! | [`live`] | `Live` session handle — callback-driven full-duplex event handling |
16//! | [`live_builders`] | Builder types for live session configuration |
17//! | [`operators`] | Operator combinators for composing agents |
18//! | [`patterns`] | Pre-built composition patterns for common use cases |
19//! | [`testing`] | Test utilities and mock helpers |
20//!
21//! ## Quick Start
22//!
23//! ```rust,ignore
24//! use adk_rs_fluent::prelude::*;
25//!
26//! let agent = AgentBuilder::new("my-agent")
27//!     .model(GeminiModel::Gemini2_0Flash)
28//!     .instruction("You are a helpful assistant.")
29//!     .build();
30//! ```
31//!
32//! ## Relationship to Other Crates
33//!
34//! - **`rs-genai`** (L0): Wire protocol, transport, types — re-exported via [`rs_genai`]
35//! - **`rs-adk`** (L1): Agent runtime, tools, sessions — re-exported via [`rs_adk`]
36//! - **`adk-rs-fluent`** (L2): This crate — ergonomic builder API and composition
37
38pub mod a2a;
39pub mod builder;
40pub mod compose;
41pub mod live;
42pub mod live_builders;
43pub mod operators;
44pub mod patterns;
45pub mod testing;
46
47pub use rs_adk;
48pub use rs_genai;
49
50/// Clone multiple bindings for use in `move` closures, reducing Arc/clone boilerplate.
51///
52/// # Example
53///
54/// ```rust,ignore
55/// use adk_rs_fluent::let_clone;
56/// use std::sync::Arc;
57///
58/// let state = Arc::new(42);
59/// let writer = Arc::new("hello");
60///
61/// let_clone!(state, writer);
62/// tokio::spawn(async move {
63///     println!("{state} {writer}");
64/// });
65/// ```
66#[macro_export]
67macro_rules! let_clone {
68    ($($name:ident),+ $(,)?) => {
69        $(let $name = $name.clone();)+
70    };
71}
72
73/// Convenience re-exports for common types across all layers.
74pub mod prelude {
75    pub use crate::a2a::{A2AServer, AgentRegistry, RemoteAgent, SkillDeclaration};
76    pub use crate::builder::*;
77    pub use crate::compose::{Ctx, A, C, E, G, M, P, S, T};
78    pub use crate::live::Live;
79    pub use crate::live_builders::*;
80    pub use crate::operators::*;
81    pub use crate::patterns::*;
82    pub use crate::testing::*;
83    // Note: rs_adk::agent::Agent trait is NOT re-exported here because
84    // it conflicts with the L2 Agent type alias (= AgentBuilder).
85    // Use rs_adk::agent::Agent directly if you need the L1 trait.
86    pub use rs_adk::agent_session::*;
87    pub use rs_adk::live::{
88        CallbackMode, ContextDelivery, DefaultResultFormatter, DeferredWriter, EventCallbacks,
89        ExtractionTrigger, FsPersistence, LiveEvent, LiveHandle, LiveSessionBuilder, LlmExtractor,
90        MemoryPersistence, NeedsFulfillment, PendingContext, RepairAction, RepairConfig,
91        ResultFormatter, SessionPersistence, SessionSnapshot, SoftTurnDetector, SteeringMode,
92        ToolExecutionMode, TranscriptBuffer, TranscriptTurn, TurnExtractor,
93    };
94    pub use rs_adk::llm::BaseLlm;
95    pub use rs_adk::state::State;
96    pub use rs_adk::text::{
97        DispatchTextAgent, FallbackTextAgent, FnTextAgent, JoinTextAgent, LlmTextAgent,
98        LoopTextAgent, MapOverTextAgent, ParallelTextAgent, RaceTextAgent, RouteRule,
99        RouteTextAgent, SequentialTextAgent, TapTextAgent, TaskRegistry, TextAgent,
100        TimeoutTextAgent,
101    };
102    // New ADK-JS parity types
103    pub use rs_adk::confirmation::ToolConfirmation;
104    pub use rs_adk::context::{CallbackContext, ToolContext};
105    pub use rs_adk::credentials::{AuthCredential, CredentialService, InMemoryCredentialService};
106    pub use rs_adk::instruction::inject_session_state;
107    pub use rs_adk::llm::LlmRegistry;
108    pub use rs_adk::run_config::{RunConfig, StreamingMode};
109    pub use rs_adk::text_runner::InMemoryRunner;
110    pub use rs_adk::toolset::{StaticToolset, Toolset};
111    pub use rs_genai::prelude::*;
112}