gemini_adk_rs/
lib.rs

1#![warn(missing_docs)]
2//! # gemini-adk-rs
3//!
4//! Full Rust equivalent of Google's `@google/adk` framework.
5//! Agents, tools, sessions, events, middleware, and runtime.
6
7pub mod a2a;
8pub mod agent;
9pub mod agent_config;
10pub mod agent_session;
11pub mod agent_tool;
12pub mod agents;
13pub mod artifacts;
14pub mod auth;
15pub mod callback;
16pub mod code_executors;
17pub mod confirmation;
18pub mod context;
19pub mod credentials;
20pub mod error;
21pub mod evaluation;
22pub mod events;
23pub mod extract;
24pub mod flow;
25pub mod frame;
26pub mod instruction;
27pub mod live;
28pub mod llm;
29pub mod llm_agent;
30pub mod memory;
31pub mod middleware;
32pub mod optimization;
33pub mod orchestration;
34pub mod planners;
35pub mod plugin;
36pub mod processors;
37pub mod router;
38pub mod run_config;
39pub mod runner;
40pub mod session;
41pub mod state;
42pub mod telemetry;
43pub mod text;
44pub mod text_agent_tool;
45pub mod text_runner;
46pub mod tool;
47pub mod tools;
48pub mod toolset;
49pub mod utils;
50
51#[cfg(test)]
52pub(crate) mod test_helpers;
53
54// Ergonomic re-exports — existing
55pub use a2a::{to_a2a_message, to_a2a_parts, to_adk_event, to_genai_parts, A2aMessage, A2aPart};
56pub use agent::Agent;
57pub use agent_tool::AgentTool;
58pub use agents::{LoopAgent, ParallelAgent, SequentialAgent};
59#[cfg(feature = "gcs-artifacts")]
60pub use artifacts::GcsArtifactService;
61pub use artifacts::{Artifact, ArtifactService, FileArtifactService, InMemoryArtifactService};
62pub use auth::{
63    AuthConfig, AuthHandler, AuthScheme, CredentialExchanger, CredentialExchangerRegistry,
64    OAuthGrantType,
65};
66pub use callback::{AfterToolCallback, BeforeToolCallback, BeforeToolResult, ToolCallResult};
67pub use code_executors::{
68    BuiltInCodeExecutor, CodeExecutionInput, CodeExecutionResult, CodeExecutor, CodeFile,
69};
70pub use confirmation::{
71    ConfirmationProvider, ConfirmationRequest, StaticConfirmation, ToolConfirmation,
72};
73pub use context::{AgentEvent, CallbackContext, InvocationContext, ToolContext};
74pub use credentials::{
75    AuthCredential, CredentialError, CredentialService, InMemoryCredentialService,
76};
77pub use error::{AgentError, AgentResult, ToolError};
78pub use events::{Event, EventActions, EventType, StructuredEvent};
79pub use extract::{Extract, Recognizer, RecordExtractor};
80pub use flow::{
81    render_ground, run as run_on_enter, CompiledFlow, Enforcement as FlowMode, Flow, FlowError,
82    FlowErrors, FlowExplanation, FlowMonitor, Guard, SharedFlowMonitor, StepAction, ToolPolicy,
83    Verdict, Violation,
84};
85pub use frame::{ConfirmPolicy, Frame, FrameSpec, SlotRecognizer, SlotSpec, SlotValidator};
86/// Re-exports the `#[tool]`/`#[derive(..)]` macros route their generated code
87/// through, so downstream crates don't need the upstream crate names
88/// (`serde`/`schemars`/`async_trait`/`serde_json`) in scope or under those exact
89/// names. Not public API.
90#[doc(hidden)]
91pub mod __macros {
92    pub use async_trait;
93    pub use schemars;
94    pub use serde;
95    pub use serde_json;
96}
97
98/// The `#[tool]` attribute macro — turns an `async fn` into a registrable Gemini tool.
99///
100/// See the [`gemini_adk_macros_rs::tool`] documentation for details.
101pub use gemini_adk_macros_rs::tool;
102/// The `#[derive(Extract)]` macro — builds an [`extract::Extract`] record from a
103/// struct's `#[recognize(..)]` fields. Shares the name `Extract` with the
104/// struct (macro vs type namespace), so both can be imported together.
105///
106/// See the [`gemini_adk_macros_rs::Extract`](macro@gemini_adk_macros_rs::Extract)
107/// documentation for details.
108pub use gemini_adk_macros_rs::Extract;
109/// Derive macro that generates a [`frame::Frame`] impl from a struct's
110/// `#[slot(..)]` fields. Shares the name `Frame` with the trait (macro vs type
111/// namespace), so both can be imported together.
112pub use gemini_adk_macros_rs::Frame;
113pub use instruction::inject_session_state;
114pub use live::{
115    CallbackMode, EventCallbacks, LiveHandle, LiveSessionBuilder, LlmExtractor, ToolCallSummary,
116    TranscriptBuffer, TranscriptTurn, TurnExtractor,
117};
118pub use llm::{BaseLlm, GeminiLlm, GeminiLlmParams, LlmRegistry, LlmRequest, LlmResponse};
119pub use llm_agent::{LlmAgent, LlmAgentBuilder};
120pub use memory::{InMemoryMemoryService, MemoryEntry, MemoryService};
121pub use middleware::{Middleware, MiddlewareChain};
122pub use orchestration::{call as call_agent, provenance, Mode as AgentMode, Resolver};
123pub use plugin::{Plugin, PluginManager, PluginResult};
124pub use processors::{
125    ContentFilter, InstructionInserter, RequestProcessor, RequestProcessorChain, ResponseProcessor,
126    ResponseProcessorChain,
127};
128pub use router::AgentRegistry;
129pub use run_config::{RunConfig, StreamingMode};
130pub use runner::Runner;
131#[cfg(feature = "database-sessions")]
132pub use session::DatabaseSessionService;
133pub use session::{db_schema, InMemorySessionService, Session, SessionId, SessionService};
134pub use state::PrefixedState;
135pub use state::{FileJournalSink, JournalSink, MemoryJournalSink};
136pub use state::{SlotEvidence, State, StateMutation, StateMutationOrigin};
137pub use text::{
138    DispatchTextAgent, FallbackTextAgent, FnTextAgent, JoinTextAgent, LlmTextAgent, LoopTextAgent,
139    MapOverTextAgent, ParallelTextAgent, RaceTextAgent, RouteRule, RouteTextAgent,
140    SequentialTextAgent, TapTextAgent, TaskRegistry, TextAgent, TimeoutTextAgent,
141};
142pub use text_agent_tool::TextAgentTool;
143pub use text_runner::InMemoryRunner;
144pub use tool::{SimpleTool, ToolDispatcher, ToolFunction, TypedTool};
145pub use tools::long_running::LongRunningFunctionTool;
146pub use tools::mcp::{McpConnectionParams, McpTool, McpToolset};
147pub use tools::GoogleSearchTool;
148pub use toolset::{StaticToolset, Toolset};
149pub use utils::model_name::{extract_model_name, is_gemini2_or_above, is_gemini_model};
150pub use utils::variant::{get_google_llm_variant, GoogleLlmVariant};
151
152// New re-exports — A2A
153pub use a2a::{AgentCard, AgentSkill, RemoteA2aAgent, RemoteA2aAgentConfig};
154
155// New re-exports — Evaluation
156pub use evaluation::{
157    EvalCase, EvalMetric, EvalResult, EvalSet, Evaluator, Invocation, LlmAsJudge,
158    PerInvocationResult, ResponseEvaluator, TrajectoryEvaluator,
159};
160
161// New re-exports — Planners
162pub use planners::{BuiltInPlanner, PlanReActPlanner, Planner, PlannerError};
163
164// New re-exports — Optimization
165pub use optimization::{
166    AgentOptimizer, EvalSample, OptimizerError, OptimizerResult, Sampler, SimplePromptOptimizer,
167    SimplePromptOptimizerConfig,
168};
169
170// New re-exports — Code Executors
171pub use code_executors::{
172    ContainerCodeExecutor, ContainerCodeExecutorConfig, UnsafeLocalCodeExecutor,
173};
174#[cfg(feature = "vertex-ai-code-executor")]
175pub use code_executors::{VertexAiCodeExecutor, VertexAiCodeExecutorConfig};
176
177// New re-exports — Plugins
178pub use plugin::{ContextFilterPlugin, GlobalInstructionPlugin, ReflectRetryToolPlugin};
179
180// New re-exports — Memory
181pub use memory::{VertexAiMemoryBankConfig, VertexAiMemoryBankService};
182#[cfg(feature = "vertex-ai-rag")]
183pub use memory::{VertexAiRagMemoryConfig, VertexAiRagMemoryService};
184
185// New re-exports — Sessions
186#[cfg(feature = "postgres-sessions")]
187pub use session::{PostgresSessionConfig, PostgresSessionService};
188pub use session::{SqliteSessionConfig, SqliteSessionService};
189#[cfg(feature = "vertex-ai-sessions")]
190pub use session::{VertexAiSessionConfig, VertexAiSessionService};
191
192// New re-exports — Tools
193pub use tools::retrieval::{BaseRetrievalTool, FilesRetrievalTool, RetrievalResult};
194#[cfg(feature = "vertex-ai-rag")]
195pub use tools::retrieval::{VertexAiRagConfig, VertexAiRagRetrievalTool};
196pub use tools::{
197    BashToolPolicy, DiscoveryEngineSearchTool, Example, ExampleTool, ExecuteBashTool, ExitLoopTool,
198    GetUserChoiceTool, LoadMemoryTool, PreloadMemoryTool, TransferToAgentTool, UrlContextTool,
199    VertexAiSearchConfig, VertexAiSearchTool,
200};
201
202// New re-exports — Agent Config
203pub use agent_config::{
204    discover_agent_configs, AgentConfig, AgentConfigError, ToolConfig as AgentToolConfig,
205};
206
207// Wire re-export
208pub use gemini_genai_rs;