// AUTO-GENERATED by adk-transpiler -- do not edit manually
// Source: adk-js
// Generated: 2026-03-02T01:19:11Z
#![allow(dead_code, unused_imports, clippy::type_complexity)]
use crate::context::AgentEvent;
use crate::{Agent, AgentError, InvocationContext, ToolFunction};
use async_trait::async_trait;
use std::sync::Arc;
// BaseAgent — base class, fields merged into child agents via inheritance.
// ---- LlmAgent ----
/// The configuration options for creating an LLM-based agent.
/// (Inherits fields from BaseAgent)
// Cannot derive Clone: contains trait objects
pub struct LlmAgentConfig {
pub name: String,
/// The model to use for the agent.
pub model: Option<String>,
/// Instructions for the LLM model, guiding the agent's behavior.
pub instruction: Option<String>,
/// Instructions for all the agents in the entire agent tree. ONLY the globalInstruction in root agent will take effect. For example: use globalInstruction to make all agents have a stable identity or personality.
pub global_instruction: Option<String>,
/// Tools available to this agent.
pub tools: Option<Vec<Arc<dyn ToolFunction>>>,
/// The additional content generation configurations. NOTE: not all fields are usable, e.g. tools must be configured via `tools`, thinking_config must be configured via `planner` in LlmAgent. For example: use this config to adjust model temperature, configure safety settings, etc.
pub generate_content_config: Option<serde_json::Value>,
/// Disallows LLM-controlled transferring to the parent agent. NOTE: Setting this as True also prevents this agent to continue reply to the end-user. This behavior prevents one-way transfer, in which end-user may be stuck with one agent that cannot transfer to other agents in the agent tree.
pub disallow_transfer_to_parent: Option<bool>,
/// Disallows LLM-controlled transferring to the peer agents.
pub disallow_transfer_to_peers: Option<bool>,
/// Controls content inclusion in model requests. Options: default: Model receives relevant conversation history none: Model receives no prior history, operates solely on current instruction and input
pub include_contents: Option<String>,
/// The input schema when agent is used as a tool.
pub input_schema: Option<serde_json::Value>,
/// The output schema when agent replies.
pub output_schema: Option<serde_json::Value>,
/// The key in session state to store the output of the agent. Typically use cases: - Extracts agent reply for later use, such as in tools, callbacks, etc. - Connects agents to coordinate with each other.
pub output_key: Option<String>,
/// Processors to run before the LLM request is sent.
pub request_processors: Option<Vec<serde_json::Value>>,
/// Processors to run after the LLM response is received.
pub response_processors: Option<Vec<serde_json::Value>>,
/// Instructs the agent to make a plan and execute it step by step.
pub code_executor: Option<serde_json::Value>,
pub description: Option<String>,
pub parent_agent: Option<Arc<dyn Agent>>,
pub sub_agents: Option<Vec<Arc<dyn Agent>>>,
/// Callbacks to be called before calling the LLM.
pub before_model_callback: Option<Box<dyn Fn(&InvocationContext) + Send + Sync>>,
/// Callbacks to be called after calling the LLM.
pub after_model_callback: Option<Box<dyn Fn(&InvocationContext) + Send + Sync>>,
/// Callbacks to be called before calling the tool.
pub before_tool_callback: Option<Box<dyn Fn(&InvocationContext) + Send + Sync>>,
/// Callbacks to be called after calling the tool.
pub after_tool_callback: Option<Box<dyn Fn(&InvocationContext) + Send + Sync>>,
pub before_agent_callback: Option<Box<dyn Fn(&InvocationContext) + Send + Sync>>,
pub after_agent_callback: Option<Box<dyn Fn(&InvocationContext) + Send + Sync>>,
}
impl LlmAgentConfig {
pub fn new(name: impl Into<String>) -> Self {
Self {
name: name.into(),
model: None,
instruction: None,
global_instruction: None,
tools: None,
generate_content_config: None,
disallow_transfer_to_parent: None,
disallow_transfer_to_peers: None,
include_contents: None,
input_schema: None,
output_schema: None,
output_key: None,
request_processors: None,
response_processors: None,
code_executor: None,
description: None,
parent_agent: None,
sub_agents: None,
before_model_callback: None,
after_model_callback: None,
before_tool_callback: None,
after_tool_callback: None,
before_agent_callback: None,
after_agent_callback: None,
}
}
}
pub struct LlmAgentBuilder {
config: LlmAgentConfig,
}
impl LlmAgentBuilder {
pub fn new(name: impl Into<String>) -> Self {
Self {
config: LlmAgentConfig::new(name),
}
}
pub fn model(mut self, value: String) -> Self {
self.config.model = Some(value);
self
}
pub fn instruction(mut self, value: String) -> Self {
self.config.instruction = Some(value);
self
}
pub fn global_instruction(mut self, value: String) -> Self {
self.config.global_instruction = Some(value);
self
}
pub fn tools(mut self, value: Vec<Arc<dyn ToolFunction>>) -> Self {
self.config.tools = Some(value);
self
}
pub fn generate_content_config(mut self, value: serde_json::Value) -> Self {
self.config.generate_content_config = Some(value);
self
}
pub fn disallow_transfer_to_parent(mut self, value: bool) -> Self {
self.config.disallow_transfer_to_parent = Some(value);
self
}
pub fn disallow_transfer_to_peers(mut self, value: bool) -> Self {
self.config.disallow_transfer_to_peers = Some(value);
self
}
pub fn include_contents(mut self, value: String) -> Self {
self.config.include_contents = Some(value);
self
}
pub fn input_schema(mut self, value: serde_json::Value) -> Self {
self.config.input_schema = Some(value);
self
}
pub fn output_schema(mut self, value: serde_json::Value) -> Self {
self.config.output_schema = Some(value);
self
}
pub fn output_key(mut self, value: String) -> Self {
self.config.output_key = Some(value);
self
}
pub fn request_processors(mut self, value: Vec<serde_json::Value>) -> Self {
self.config.request_processors = Some(value);
self
}
pub fn response_processors(mut self, value: Vec<serde_json::Value>) -> Self {
self.config.response_processors = Some(value);
self
}
pub fn code_executor(mut self, value: serde_json::Value) -> Self {
self.config.code_executor = Some(value);
self
}
pub fn description(mut self, value: String) -> Self {
self.config.description = Some(value);
self
}
pub fn parent_agent(mut self, value: Arc<dyn Agent>) -> Self {
self.config.parent_agent = Some(value);
self
}
pub fn sub_agents(mut self, value: Vec<Arc<dyn Agent>>) -> Self {
self.config.sub_agents = Some(value);
self
}
pub fn build(self) -> LlmAgent {
LlmAgent {
config: self.config,
}
}
}
pub struct LlmAgent {
pub config: LlmAgentConfig,
}
// Agent trait impl for LlmAgent should be provided by the application.
// ---- LoopAgent ----
/// The configuration options for creating a loop agent.
/// (Inherits fields from BaseAgent)
// Cannot derive Clone: contains trait objects
pub struct LoopAgentConfig {
pub name: String,
/// The maximum number of iterations the loop agent will run. If not provided, the loop agent will run indefinitely.
pub max_iterations: Option<f64>,
pub description: Option<String>,
pub parent_agent: Option<Arc<dyn Agent>>,
pub sub_agents: Option<Vec<Arc<dyn Agent>>>,
pub before_agent_callback: Option<Box<dyn Fn(&InvocationContext) + Send + Sync>>,
pub after_agent_callback: Option<Box<dyn Fn(&InvocationContext) + Send + Sync>>,
}
impl LoopAgentConfig {
pub fn new(name: impl Into<String>) -> Self {
Self {
name: name.into(),
max_iterations: None,
description: None,
parent_agent: None,
sub_agents: None,
before_agent_callback: None,
after_agent_callback: None,
}
}
}
pub struct LoopAgentBuilder {
config: LoopAgentConfig,
}
impl LoopAgentBuilder {
pub fn new(name: impl Into<String>) -> Self {
Self {
config: LoopAgentConfig::new(name),
}
}
pub fn max_iterations(mut self, value: f64) -> Self {
self.config.max_iterations = Some(value);
self
}
pub fn description(mut self, value: String) -> Self {
self.config.description = Some(value);
self
}
pub fn parent_agent(mut self, value: Arc<dyn Agent>) -> Self {
self.config.parent_agent = Some(value);
self
}
pub fn sub_agents(mut self, value: Vec<Arc<dyn Agent>>) -> Self {
self.config.sub_agents = Some(value);
self
}
pub fn build(self) -> LoopAgent {
LoopAgent {
config: self.config,
}
}
}
pub struct LoopAgent {
pub config: LoopAgentConfig,
}
#[async_trait]
impl Agent for LoopAgent {
fn name(&self) -> &str {
&self.config.name
}
fn sub_agents(&self) -> Vec<Arc<dyn Agent>> {
self.config.sub_agents.clone().unwrap_or_default()
}
async fn run_live(&self, ctx: &mut InvocationContext) -> Result<(), AgentError> {
let inner = crate::agents::loop_agent::LoopAgent::new(
&self.config.name,
self.sub_agents(),
self.config.max_iterations.map(|v| v as u32).unwrap_or(10),
);
inner.run_live(ctx).await
}
}
// ---- ActiveStreamingToolParams ----
/// The parameters for creating an ActiveStreamingTool.
#[derive(Debug, Clone, Default)]
pub struct ActiveStreamingToolParams {
pub task: Option<serde_json::Value>,
pub stream: Option<serde_json::Value>,
}
// ---- AgentTool ----
/// The configuration of the agent tool.
// Cannot derive Clone: contains trait objects
pub struct AgentTool {
/// The reference to the agent instance.
pub agent: Arc<dyn Agent>,
/// Whether to skip summarization of the agent output.
pub skip_summarization: Option<bool>,
}
// ---- Auth ----
/// The auth config sent by tool asking client to collect auth credentials and adk and client will help to fill in the response.
#[derive(Debug, Clone, Default)]
pub struct Auth {
/// The auth scheme used to collect credentials
pub auth_scheme: serde_json::Value,
/// The raw auth credential used to collect credentials. The raw auth credentials are used in some auth scheme that needs to exchange auth credentials. e.g. OAuth2 and OIDC. For other auth scheme, it could be undefined.
pub raw_auth_credential: Option<serde_json::Value>,
/// The exchanged auth credential used to collect credentials. adk and client will work together to fill it. For those auth scheme that doesn't need to exchange auth credentials, e.g. API key, service account etc. It's filled by client directly. For those auth scheme that need to exchange auth credentials, e.g. OAuth2 and OIDC, it's first filled by adk. If the raw credentials passed by tool only has client id and client credential, adk will help to generate the corresponding authorization uri and state and store the processed credential in this field. If the raw credentials passed by tool already has authorization uri, state, etc. then it's copied to this field. Client will use this field to guide the user through the OAuth2 flow and fill auth response in this field
pub exchanged_auth_credential: Option<serde_json::Value>,
/// A user specified key used to load and save this credential in a credential service.
pub credential_key: String,
}
// ---- BaseToolParams ----
/// Parameters for the BaseTool constructor.
#[derive(Debug, Clone, Default)]
pub struct BaseToolParams {
pub name: String,
pub description: String,
pub is_long_running: Option<bool>,
}
// ---- RunAsyncToolRequest ----
/// The parameters for `runAsync`.
#[derive(Debug, Clone, Default)]
pub struct RunAsyncToolRequest {
pub args: serde_json::Value,
pub tool_context: serde_json::Value,
}
// ---- ToolProcessLlmRequest ----
/// The parameters for `processLlmRequest`.
#[derive(Debug, Clone, Default)]
pub struct ToolProcessLlmRequest {
pub tool_context: serde_json::Value,
pub llm_request: serde_json::Value,
}
// ---- TraceMergedToolCallsParams ----
#[derive(Debug, Clone, Default)]
pub struct TraceMergedToolCallsParams {
pub response_event_id: String,
pub function_response_event: serde_json::Value,
}
// ---- TraceToolCallParams ----
// Cannot derive Clone: contains trait objects
pub struct TraceToolCallParams {
pub tool: Arc<dyn ToolFunction>,
pub args: serde_json::Value,
pub function_response_event: serde_json::Value,
}
// ============================================================
// General type definitions extracted from ADK-JS source
// ============================================================
// ---- A2AMetadataKeys (module: a2a) ----
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum A2AMetadataKeys {
PARTIAL,
TaskId,
ContextId,
ESCALATE,
TransferToAgent,
LongRunning,
THOUGHT,
}
// ---- ActivityEvent (module: events) ----
/// Represents a generic activity or status update.
#[derive(Debug, Clone, Default)]
pub struct ActivityEvent {
pub r#type: serde_json::Value,
pub kind: String,
pub detail: serde_json::Value,
}
// ---- ApigeeLlmParams (module: models) ----
#[derive(Debug, Clone, Default)]
pub struct ApigeeLlmParams {
/// The name of the model to use. The model string specifies the LLM provider (e.g., Vertex AI, Gemini), API version, and the model ID. Supported format: `apigee/[<provider>/][<version>/]<model_id>` Components: `provider` (optional): `vertex_ai` or `gemini`. `version` (optional): The API version (e.g., `v1`, `v1beta`). If not provided, a default version will selected based on the provider. `model_id` (required): The model identifier (e.g., `gemini-2.5-flash`). Examples: - `apigee/gemini-2.5-flash` - `apigee/v1/gemini-2.5-flash` - `apigee/vertex_ai/gemini-2.5-flash` - `apigee/gemini/v1/gemini-2.5-flash` - `apigee/vertex_ai/v1beta/gemini-2.5-flash`
pub model: String,
/// The proxy URL for the provider API. If not provided, it will look for the APIGEE_PROXY_URL environment variable.
pub proxy_url: Option<String>,
/// API key to use. If not provided, it will look for the GOOGLE_GENAI_API_KEY or GEMINI_API_KEY environment variable. If gemini provider is selected and no key is provided, the fake key "-" will be used for the "x-goog-api-key" header.
pub api_key: Option<String>,
}
// ---- AppendEventRequest (module: sessions) ----
/// The parameters for `appendEvent`.
#[derive(Debug, Clone, Default)]
pub struct AppendEventRequest {
/// The session to append the event to.
pub session: serde_json::Value,
/// The event to append.
pub event: serde_json::Value,
}
// ---- ArtifactVersion (module: artifacts) ----
/// Metadata for a file artifact version.
#[derive(Debug, Clone, Default)]
pub struct ArtifactVersion {
/// The version number.
pub version: f64,
/// The canonical URI of the artifact.
pub canonical_uri: Option<String>,
/// Custom metadata associated with the artifact.
pub custom_metadata: Option<serde_json::Value>,
/// The MIME type of the artifact.
pub mime_type: Option<String>,
}
// ---- AuthCredential (module: auth) ----
/// Data class representing an authentication credential. To exchange for the actual credential, please use CredentialExchanger.exchangeCredential(). @example // API Key Auth const authCredential: AuthCredential = { authType: AuthCredentialTypes.API_KEY, apiKey: "your_api_key", }; @example // HTTP Auth const authCredential: AuthCredential = { authType: AuthCredentialTypes.HTTP, http: { scheme: "basic", credentials: { username: "user", password: "password", }, } } @example // OAuth2 Bearer Token in HTTP Header const authCredential: AuthCredential = { authType: AuthCredentialTypes.HTTP, http: { scheme: "bearer", credentials: { token: "your_access_token", }, } } @example // OAuth2 Auth with Authorization Code Flow const authCredential: AuthCredential = { authType: AuthCredentialTypes.OAUTH2, oauth2: { clientId: "your_client_id", clientSecret: "your_client_secret", } } @example: // Open ID Connect Auth const authCredential: AuthCredential = { authType: AuthCredentialTypes.OPEN_ID_CONNECT, oauth2: { clientId: "1234", clientSecret: "secret", redirectUri: "https://example.com", scopes: ["scope1", "scope2"], } } @example: // Auth with resource reference const authCredential: AuthCredential = { authType: AuthCredentialTypes.API_KEY, resourceRef: "projects/1234/locations/us-central1/resources/resource1" }
#[derive(Debug, Clone, Default)]
pub struct AuthCredential {
pub auth_type: serde_json::Value,
/// Resource reference for the credential. This will be supported in the future.
pub resource_ref: Option<String>,
pub api_key: Option<String>,
pub http: Option<serde_json::Value>,
pub service_account: Option<serde_json::Value>,
pub oauth2: Option<serde_json::Value>,
}
// ---- AuthToolArguments (module: auth) ----
/// The arguments for the special long running function tool that is used to request end user credentials.
#[derive(Debug, Clone, Default)]
pub struct AuthToolArguments {
pub function_call_id: String,
pub auth_config: serde_json::Value,
}
// ---- BaseArtifactService (module: artifacts) ----
/// Interface for artifact services.
#[derive(Debug, Clone, Default)]
pub struct BaseArtifactService {
/// Gets metadata for a specific artifact version.
pub request: serde_json::Value,
}
// ---- BaseCredentialExchanger (module: auth) ----
/// Base interface for credential exchangers. Credential exchangers are responsible for exchanging credentials from one format or scheme to another.
#[derive(Debug, Clone, Default)]
pub struct BaseCredentialExchanger {
pub auth_credential: serde_json::Value,
pub auth_scheme: Option<serde_json::Value>,
}
// ---- BaseCredentialService (module: auth) ----
/// Abstract class for Service that loads / saves tool credentials from / to the backend credential store.
#[derive(Debug, Clone, Default)]
pub struct BaseCredentialService {
pub auth_config: serde_json::Value,
pub tool_context: serde_json::Value,
}
// ---- BaseLlmConnection (module: models) ----
/// The base class for a live model connection.
#[derive(Debug, Clone, Default)]
pub struct BaseLlmConnection {}
// ---- BaseMemoryService (module: memory) ----
/// Base interface for memory services. The service provides functionalities to ingest sessions into memory so that the memory can be used for user queries.
#[derive(Debug, Clone, Default)]
pub struct BaseMemoryService {}
// ---- BasePolicyEngine (module: plugins) ----
#[derive(Debug, Clone, Default)]
pub struct BasePolicyEngine {}
// ---- CallCodeEvent (module: events) ----
/// Represents a request to execute code.
#[derive(Debug, Clone)]
pub struct CallCodeEvent {
pub r#type: serde_json::Value,
pub code: rs_genai::prelude::ExecutableCode,
}
// ---- CodeExecutionInput (module: code_executors) ----
/// A structure that contains the input of code execution. */
#[derive(Debug, Clone, Default)]
pub struct CodeExecutionInput {
/// The code to execute.
pub code: String,
/// The input files available to the code.
pub input_files: Vec<serde_json::Value>,
/// The execution ID for the stateful code execution.
pub execution_id: Option<String>,
}
// ---- CodeExecutionResult (module: code_executors) ----
#[derive(Debug, Clone, Default)]
pub struct CodeExecutionResult {
pub code: String,
pub result_stdout: String,
pub result_stderr: String,
pub timestamp: f64,
}
// ---- CodeGroupMatch (module: code_executors) ----
#[derive(Debug, Clone, Default)]
pub struct CodeGroupMatch {
pub groups: Option</* {prefix?: string; codeStr?: string} */ String>,
pub index: Option<f64>,
pub length: Option<f64>,
}
// ---- CodeResultEvent (module: events) ----
/// Represents the result of code execution.
#[derive(Debug, Clone)]
pub struct CodeResultEvent {
pub r#type: serde_json::Value,
pub result: rs_genai::prelude::CodeExecutionResult,
}
// ---- ContentEvent (module: events) ----
/// Represents partial content (text delta) intended for the user.
#[derive(Debug, Clone, Default)]
pub struct ContentEvent {
pub r#type: serde_json::Value,
pub content: String,
}
// ---- CreateSessionRequest (module: sessions) ----
/// The parameters for `createSession`.
#[derive(Debug, Clone, Default)]
pub struct CreateSessionRequest {
/// The name of the application.
pub app_name: String,
/// The ID of the user.
pub user_id: String,
/// The initial state of the session.
pub state: Option<serde_json::Value>,
/// The ID of the session. A new ID will be generated if not provided.
pub session_id: Option<String>,
}
// ---- DataPartType (module: a2a) ----
/// The types of data parts.
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum DataPartType {
FunctionCall,
FunctionResponse,
CodeExecResult,
CodeExecutableCode,
}
// ---- DeleteArtifactRequest (module: artifacts) ----
/// The parameters for `deleteArtifact`.
#[derive(Debug, Clone, Default)]
pub struct DeleteArtifactRequest {
/// The app name.
pub app_name: String,
/// The user ID.
pub user_id: String,
/// The session ID.
pub session_id: String,
/// The filename of the artifact.
pub filename: String,
}
// ---- DeleteSessionRequest (module: sessions) ----
/// The parameters for `deleteSession`.
#[derive(Debug, Clone, Default)]
pub struct DeleteSessionRequest {
/// The name of the application.
pub app_name: String,
/// The ID of the user.
pub user_id: String,
/// The ID of the session.
pub session_id: String,
}
// ---- ErrorEvent (module: events) ----
/// Represents a runtime error.
#[derive(Debug, Clone, Default)]
pub struct ErrorEvent {
pub r#type: serde_json::Value,
pub error: serde_json::Value,
}
// ---- Event (module: events) ----
/// Represents an event in a conversation between agents and users. It is used to store the content of the conversation, as well as the actions taken by the agents like function calls, etc.
#[derive(Debug, Clone, Default)]
pub struct Event {
/// The unique identifier of the event. Do not assign the ID. It will be assigned by the session.
pub id: String,
/// The invocation ID of the event. Should be non-empty before appending to a session.
pub invocation_id: String,
/// "user" or the name of the agent, indicating who appended the event to the session.
pub author: Option<String>,
/// The actions taken by the agent.
pub actions: serde_json::Value,
/// Set of ids of the long running function calls. Agent client will know from this field about which function call is long running. Only valid for function call event
pub long_running_tool_ids: Option<Vec<String>>,
/// The branch of the event. The format is like agent_1.agent_2.agent_3, where agent_1 is the parent of agent_2, and agent_2 is the parent of agent_3. Branch is used when multiple sub-agent shouldn't see their peer agents' conversation history.
pub branch: Option<String>,
/// The timestamp of the event.
pub timestamp: f64,
}
// ---- EventActions (module: events) ----
/// Represents the actions attached to an event.
#[derive(Debug, Clone, Default)]
pub struct EventActions {
/// If true, it won't call model to summarize function response. Only used for function_response event.
pub skip_summarization: Option<bool>,
/// Indicates that the event is updating the state with the given delta.
pub state_delta: String,
/// Indicates that the event is updating an artifact. key is the filename, value is the version.
pub artifact_delta: String,
/// If set, the event transfers to the specified agent.
pub transfer_to_agent: Option<String>,
/// The agent is escalating to a higher level agent.
pub escalate: Option<bool>,
/// Authentication configurations requested by tool responses. This field will only be set by a tool response event indicating tool request auth credential. - Keys: The function call id. Since one function response event could contain multiple function responses that correspond to multiple function calls. Each function call could request different auth configs. This id is used to identify the function call. - Values: The requested auth config.
pub requested_auth_configs: String,
/// A dict of tool confirmation requested by this event, keyed by the function call id.
pub requested_tool_confirmations: String,
}
// ---- EventType (module: events) ----
/// The types of events that can be parsed from a raw Event.
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum EventType {
THOUGHT,
CONTENT,
ToolCall,
ToolResult,
CallCode,
CodeResult,
ERROR,
ACTIVITY,
ToolConfirmation,
FINISHED,
}
// ---- Example (module: examples) ----
/// A few-shot example.
#[derive(Debug, Clone)]
pub struct Example {
/// The input content for the example.
pub input: rs_genai::prelude::Content,
/// The expected output content for the example.
pub output: Vec<rs_genai::prelude::Content>,
}
// ---- ExecuteCodeParams (module: code_executors) ----
/// The parameters for executing code. */
#[derive(Debug, Clone, Default)]
pub struct ExecuteCodeParams {
/// The invocation context of the code execution.
pub invocation_context: serde_json::Value,
/// The input of the code execution.
pub code_execution_input: serde_json::Value,
}
// ---- ExecutorContext (module: a2a) ----
/// The A2A Agent Executor context.
#[derive(Debug, Clone)]
pub struct ExecutorContext {
pub user_id: String,
pub session_id: String,
pub agent_name: String,
pub readonly_state: serde_json::Value,
pub events: Vec<serde_json::Value>,
pub user_content: rs_genai::prelude::Content,
pub request_context: serde_json::Value,
}
// ---- File (module: code_executors) ----
/// A structure that contains a file name and its content
#[derive(Debug, Clone, Default)]
pub struct File {
/// The name of the file with file extension(e.g., ' file.csv')
pub name: String,
/// The base64 - encoded bytes of the file content.
pub content: String,
/// The mime type of the file (e.g., ' image / png')
pub mime_type: String,
}
// ---- FileArtifactVersion (module: artifacts) ----
/// Metadata for a file artifact version.
#[derive(Debug, Clone, Default)]
pub struct FileArtifactVersion {
pub file_name: Option<String>,
}
// ---- FinishedEvent (module: events) ----
/// Represents the final completion of the agent's task.
#[derive(Debug, Clone, Default)]
pub struct FinishedEvent {
pub r#type: serde_json::Value,
pub output: Option<serde_json::Value>,
}
// ---- GeminiParams (module: models) ----
/// The parameters for creating a Gemini instance.
#[derive(Debug, Clone, Default)]
pub struct GeminiParams {
/// The name of the model to use. Defaults to 'gemini-2.5-flash'.
pub model: Option<String>,
/// The API key to use for the Gemini API. If not provided, it will look for the GOOGLE_GENAI_API_KEY or GEMINI_API_KEY environment variable.
pub api_key: Option<String>,
/// Whether to use Vertex AI. If true, `project`, `location` should be provided.
pub vertexai: Option<bool>,
/// The Vertex AI project ID. Required if `vertexai` is true.
pub project: Option<String>,
/// The Vertex AI location. Required if `vertexai` is true.
pub location: Option<String>,
/// Headers to merge with internally crafted headers.
pub headers: Option<serde_json::Value>,
}
// ---- GetSessionConfig (module: sessions) ----
/// The configuration of getting a session.
#[derive(Debug, Clone, Default)]
pub struct GetSessionConfig {
/// The number of recent events to retrieve.
pub num_recent_events: Option<f64>,
/// Retrieve events after this timestamp.
pub after_timestamp: Option<f64>,
}
// ---- GetSessionRequest (module: sessions) ----
/// The parameters for `getSession`.
#[derive(Debug, Clone, Default)]
pub struct GetSessionRequest {
/// The name of the application.
pub app_name: String,
/// The ID of the user.
pub user_id: String,
/// The ID of the session.
pub session_id: String,
/// The configurations for getting the session.
pub config: Option<serde_json::Value>,
}
// ---- HttpAuth (module: auth) ----
/// The credentials and metadata for HTTP authentication.
#[derive(Debug, Clone, Default)]
pub struct HttpAuth {
/// The name of the HTTP Authorization scheme to be used in the Authorization header as defined in RFC7235. The values used SHOULD be registered in the IANA Authentication Scheme registry. Examples: 'basic', 'bearer'
pub scheme: String,
pub credentials: serde_json::Value,
}
// ---- HttpCredentials (module: auth) ----
/// Represents the secret token value for HTTP authentication, like user name, password, oauth token, etc.
#[derive(Debug, Clone, Default)]
pub struct HttpCredentials {
pub username: Option<String>,
pub password: Option<String>,
pub token: Option<String>,
}
// ---- InvocationContextParams (module: agents) ----
/// The parameters for creating an invocation context.
// Cannot derive Clone or Default
pub struct InvocationContextParams {
pub artifact_service: Option<serde_json::Value>,
pub session_service: Option<serde_json::Value>,
pub memory_service: Option<serde_json::Value>,
pub credential_service: Option<serde_json::Value>,
pub invocation_id: String,
pub branch: Option<String>,
pub agent: Arc<dyn Agent>,
pub user_content: Option<rs_genai::prelude::Content>,
pub session: serde_json::Value,
pub end_invocation: Option<bool>,
pub transcription_cache: Option<Vec<serde_json::Value>>,
pub run_config: Option<serde_json::Value>,
pub live_request_queue: Option<serde_json::Value>,
pub active_streaming_tools: Option<serde_json::Value>,
pub plugin_manager: serde_json::Value,
}
// ---- ListArtifactKeysRequest (module: artifacts) ----
/// The parameters for `listArtifactKeys`.
#[derive(Debug, Clone, Default)]
pub struct ListArtifactKeysRequest {
/// The app name.
pub app_name: String,
/// The user ID.
pub user_id: String,
/// The session ID.
pub session_id: String,
}
// ---- ListSessionsRequest (module: sessions) ----
/// The parameters for `listSessions`.
#[derive(Debug, Clone, Default)]
pub struct ListSessionsRequest {
/// The name of the application.
pub app_name: String,
/// The ID of the user.
pub user_id: String,
}
// ---- ListSessionsResponse (module: sessions) ----
/// The response of listing sessions. The events and states are not set within each Session object.
#[derive(Debug, Clone, Default)]
pub struct ListSessionsResponse {
/// A list of sessions.
pub sessions: Vec<serde_json::Value>,
}
// ---- ListVersionsRequest (module: artifacts) ----
/// The parameters for `listVersions`.
#[derive(Debug, Clone, Default)]
pub struct ListVersionsRequest {
/// The app name.
pub app_name: String,
/// The user ID.
pub user_id: String,
/// The session ID.
pub session_id: String,
/// The filename of the artifact.
pub filename: String,
}
// ---- LiveRequest (module: agents) ----
/// Request sent to live agents.
#[derive(Debug, Clone, Default)]
pub struct LiveRequest {
/// If set, send the content to the model in turn-by-turn mode.
pub content: Option<rs_genai::prelude::Content>,
/// If set, send the blob to the model in realtime mode.
pub blob: Option<rs_genai::prelude::Blob>,
/// If set, signal the start of user activity to the model.
pub activity_start: Option<rs_genai::prelude::ActivityStart>,
/// If set, signal the end of user activity to the model.
pub activity_end: Option<rs_genai::prelude::ActivityEnd>,
/// If set, close the queue.
pub close: Option<bool>,
}
// ---- LlmRequest (module: models) ----
/// LLM request class that allows passing in tools, output schema and system instructions to the model.
#[derive(Debug, Clone)]
pub struct LlmRequest {
/// The model name.
pub model: Option<String>,
/// The contents to send to the model.
pub contents: Vec<rs_genai::prelude::Content>,
/// Additional config for the generate content request. Tools in generateContentConfig should not be set directly; use appendTools.
pub config: Option<serde_json::Value>,
pub live_connect_config: serde_json::Value,
/// The tools dictionary. Excluded from JSON serialization.
pub tools_dict: String,
}
// ---- LlmResponse (module: models) ----
/// LLM response class that provides the first candidate response from the model if available. Otherwise, returns error code and message.
#[derive(Debug, Clone, Default)]
pub struct LlmResponse {
/// The content of the response.
pub content: Option<rs_genai::prelude::Content>,
/// The grounding metadata of the response.
pub grounding_metadata: Option<rs_genai::prelude::GroundingMetadata>,
/// Indicates whether the text content is part of a unfinished text stream. Only used for streaming mode and when the content is plain text.
pub partial: Option<bool>,
/// Indicates whether the response from the model is complete. Only used for streaming mode.
pub turn_complete: Option<bool>,
/// Error code if the response is an error. Code varies by model.
pub error_code: Option<String>,
/// Error message if the response is an error.
pub error_message: Option<String>,
/// Flag indicating that LLM was interrupted when generating the content. Usually it's due to user interruption during a bidi streaming.
pub interrupted: Option<bool>,
/// The custom metadata of the LlmResponse. An optional key-value pair to label an LlmResponse. NOTE: the entire object must be JSON serializable.
pub custom_metadata: Option</* {[key: string]: unknown} */ String>,
/// The usage metadata of the LlmResponse.
pub usage_metadata: Option<serde_json::Value>,
/// The finish reason of the response.
pub finish_reason: Option<serde_json::Value>,
/// The session resumption update of the LlmResponse
pub live_session_resumption_update: Option<rs_genai::prelude::SessionResumptionUpdatePayload>,
/// Audio transcription of user input.
pub input_transcription: Option<rs_genai::prelude::TranscriptionPayload>,
/// Audio transcription of model output.
pub output_transcription: Option<rs_genai::prelude::TranscriptionPayload>,
}
// ---- LoadArtifactRequest (module: artifacts) ----
/// The parameters for `loadArtifact`.
#[derive(Debug, Clone, Default)]
pub struct LoadArtifactRequest {
/// The app name.
pub app_name: String,
/// The user ID.
pub user_id: String,
/// The session ID.
pub session_id: String,
/// The filename of the artifact.
pub filename: String,
/// The version of the artifact to load. If not provided, the latest version of the artifact is loaded.
pub version: Option<f64>,
}
// ---- LogLevel (module: utils) ----
/// Log levels for the logger.
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum LogLevel {
DEBUG,
INFO,
WARN,
ERROR,
}
// ---- Logger (module: utils) ----
/// Logger interface for ADK.
#[derive(Debug, Clone, Default)]
pub struct Logger {}
// ---- MemoryEntry (module: memory) ----
/// Represents one memory entry.
#[derive(Debug, Clone)]
pub struct MemoryEntry {
/// The content of the memory entry.
pub content: rs_genai::prelude::Content,
/// The author of the memory.
pub author: Option<String>,
/// The timestamp when the original content of this memory happened. This string will be forwarded to LLM. Preferred format is ISO 8601 format.
pub timestamp: Option<String>,
}
// ---- MetadataKeys (module: a2a) ----
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum MetadataKeys {
TYPE,
LongRunning,
THOUGHT,
}
// ---- OAuth2Auth (module: auth) ----
/// Represents credential value and its metadata for a OAuth2 credential.
#[derive(Debug, Clone, Default)]
pub struct OAuth2Auth {
pub client_id: Option<String>,
pub client_secret: Option<String>,
/// tool or adk can generate the authUri with the state info thus client can verify the state
pub auth_uri: Option<String>,
pub state: Option<String>,
/// tool or adk can decide the redirect_uri if they don't want client to decide
pub redirect_uri: Option<String>,
pub auth_response_uri: Option<String>,
pub auth_code: Option<String>,
pub access_token: Option<String>,
pub refresh_token: Option<String>,
pub expires_at: Option<f64>,
pub expires_in: Option<f64>,
}
// ---- OAuthGrantType (module: auth) ----
/// Represents the OAuth2 flow (or grant type).
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum OAuthGrantType {
ClientCredentials,
AuthorizationCode,
IMPLICIT,
PASSWORD,
}
// ---- OTelHooks (module: telemetry) ----
/// Configuration hooks for OpenTelemetry setup. This interface defines the structure for configuring OpenTelemetry components including span processors, metric readers, and log record processors.
#[derive(Debug, Clone, Default)]
pub struct OTelHooks {
pub span_processors: Option<Vec<serde_json::Value>>,
pub metric_readers: Option<Vec<serde_json::Value>>,
pub log_record_processors: Option<Vec<serde_json::Value>>,
}
// ---- OtelExportersConfig (module: telemetry) ----
#[derive(Debug, Clone, Default)]
pub struct OtelExportersConfig {
pub enable_tracing: Option<bool>,
pub enable_metrics: Option<bool>,
pub enable_logging: Option<bool>,
}
// ---- ParsedVersion (module: utils) ----
#[derive(Debug, Clone, Default)]
pub struct ParsedVersion {
pub valid: bool,
pub major: f64,
pub minor: f64,
pub patch: f64,
}
// ---- PolicyCheckResult (module: plugins) ----
#[derive(Debug, Clone, Default)]
pub struct PolicyCheckResult {
pub outcome: String,
pub reason: Option<String>,
}
// ---- RunConfig (module: agents) ----
/// Configs for runtime behavior of agents.
#[derive(Debug, Clone, Default)]
pub struct RunConfig {
/// Speech configuration for the live agent.
pub speech_config: Option<rs_genai::prelude::SpeechConfig>,
/// The output modalities. If not set, it's default to AUDIO.
pub response_modalities: Option<Vec<rs_genai::prelude::Modality>>,
/// Whether or not to save the input blobs as artifacts.
pub save_input_blobs_as_artifacts: Option<bool>,
/// Whether to support CFC (Compositional Function Calling). Only applicable for StreamingMode.SSE. If it's true. the LIVE API will be invoked. Since only LIVE API supports CFC WARNING: This feature is **experimental** and its API or behavior may change in future releases.
pub support_cfc: Option<bool>,
/// Streaming mode, None or StreamingMode.SSE or StreamingMode.BIDI.
pub streaming_mode: Option<serde_json::Value>,
/// Output audio transcription config.
pub output_audio_transcription: Option<serde_json::Value>,
/// Input transcription for live agents with audio input from user.
pub input_audio_transcription: Option<serde_json::Value>,
/// If enabled, the model will detect emotions and adapt its responses accordingly.
pub enable_affective_dialog: Option<bool>,
/// Configures the proactivity of the model. This allows the model to respond proactively to the input and to ignore irrelevant input.
pub proactivity: Option<rs_genai::prelude::ProactivityConfig>,
/// Realtime input config for live agents with audio input from user.
pub realtime_input_config: Option<rs_genai::prelude::RealtimeInputConfig>,
/// A limit on the total number of llm calls for a given run. Valid Values: - More than 0 and less than sys.maxsize: The bound on the number of llm calls is enforced, if the value is set in this range. - Less than or equal to 0: This allows for unbounded number of llm calls.
pub max_llm_calls: Option<f64>,
/// If true, the agent loop will suspend on ANY tool call, allowing the client to intercept and execute tools (Client-Side Tool Execution).
pub pause_on_tool_calls: Option<bool>,
}
// ---- RunnerConfig (module: runner) ----
/// The configuration parameters for the Runner.
// Cannot derive Clone or Default
pub struct RunnerConfig {
/// The application name.
pub app_name: String,
/// The agent to run.
pub agent: Arc<dyn Agent>,
pub plugins: Option<Vec<serde_json::Value>>,
pub artifact_service: Option<serde_json::Value>,
pub session_service: serde_json::Value,
pub memory_service: Option<serde_json::Value>,
pub credential_service: Option<serde_json::Value>,
}
// ---- SaveArtifactRequest (module: artifacts) ----
/// The parameters for `saveArtifact`.
#[derive(Debug, Clone)]
pub struct SaveArtifactRequest {
/// The app name.
pub app_name: String,
/// The user ID.
pub user_id: String,
/// The session ID.
pub session_id: String,
/// The filename of the artifact.
pub filename: String,
/// The artifact to save.
pub artifact: rs_genai::prelude::Part,
/// Optional custom metadata to save with the artifact.
pub custom_metadata: Option<serde_json::Value>,
}
// ---- SearchMemoryRequest (module: memory) ----
/// The parameters for `searchMemory`.
#[derive(Debug, Clone, Default)]
pub struct SearchMemoryRequest {
pub app_name: String,
pub user_id: String,
pub query: String,
}
// ---- SearchMemoryResponse (module: memory) ----
/// Represents the response from a memory search.
#[derive(Debug, Clone, Default)]
pub struct SearchMemoryResponse {
/// A list of memory entries that are related to the search query.
pub memories: Vec<serde_json::Value>,
}
// ---- ServiceAccount (module: auth) ----
/// Represents Google Service Account configuration.
#[derive(Debug, Clone, Default)]
pub struct ServiceAccount {
pub service_account_credential: Option<serde_json::Value>,
pub scopes: Option<Vec<String>>,
pub use_default_credential: Option<bool>,
}
// ---- ServiceAccountCredential (module: auth) ----
/// Represents Google Service Account configuration. @example config = { type: "service_account", projectId: "your_project_id", privateKeyId: "your_private_key_id", privateKey: "-----BEGIN PRIVATE KEY-----...", clientEmail: "...@....iam.gserviceaccount.com", clientId: "your_client_id", authUri: "https://accounts.google.com/o/oauth2/auth", tokenUri: "https://oauth2.googleapis.com/token", authProviderX509CertUrl: "https://www.googleapis.com/oauth2/v1/certs", clientX509CertUrl: "https://www.googleapis.com/robot/v1/metadata/x509/...", universeDomain: "googleapis.com", }
#[derive(Debug, Clone, Default)]
pub struct ServiceAccountCredential {
/// The type should be 'service_account'.
pub r#type: String,
/// The project ID of the Google Cloud project.
pub project_id: String,
/// The ID of the private key.
pub private_key_id: String,
/// The private key value.
pub private_key: String,
/// The client email.
pub client_email: String,
/// The client ID.
pub client_id: String,
/// The authorization URI.
pub auth_uri: String,
/// The token URI.
pub token_uri: String,
/// URL for auth provider's X.509 cert.
pub auth_provider_x509_cert_url: String,
/// URL for the client's X.509 cert.
pub client_x509_cert_url: String,
/// The universe domain.
pub universe_domain: String,
}
// ---- Session (module: sessions) ----
/// Represents a session in a conversation between agents and users.
#[derive(Debug, Clone, Default)]
pub struct Session {
/// The unique identifier of the session.
pub id: String,
/// The name of the app.
pub app_name: String,
/// The id of the user.
pub user_id: String,
/// The state of the session.
pub state: serde_json::Value,
/// The events of the session, e.g. user input, model response, function call/response, etc.
pub events: Vec<serde_json::Value>,
/// The last update time of the session.
pub last_update_time: f64,
}
// ---- StdioConnectionParams (module: tools) ----
/// Defines the parameters for establishing a connection to an MCP server using standard input/output (stdio). This is typically used for running MCP servers as local child processes.
#[derive(Debug, Clone, Default)]
pub struct StdioConnectionParams {
pub r#type: String,
pub server_params: serde_json::Value,
pub timeout: Option<f64>,
}
// ---- StreamableHTTPConnectionParams (module: tools) ----
/// Defines the parameters for establishing a connection to an MCP server over HTTP using Server-Sent Events (SSE) for streaming. Usage: const connectionParams: StreamableHTTPConnectionParams = { type: 'StreamableHTTPConnectionParams', url: 'http://localhost:8788/mcp' };
#[derive(Debug, Clone, Default)]
pub struct StreamableHTTPConnectionParams {
pub r#type: String,
pub url: String,
/// Use transportOptions.requestInit.headers instead. This field will be ignored if transportOptions is provided even if no headers are specified in transportOptions.
pub header: Option<serde_json::Value>,
pub timeout: Option<f64>,
pub sse_read_timeout: Option<f64>,
pub terminate_on_close: Option<bool>,
pub transport_options: Option<serde_json::Value>,
}
// ---- StreamingMode (module: agents) ----
/// The streaming mode for the run config.
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum StreamingMode {
NONE,
SSE,
BIDI,
}
// ---- ThoughtEvent (module: events) ----
/// Represents a reasoning trace (thought) from the agent.
#[derive(Debug, Clone, Default)]
pub struct ThoughtEvent {
pub r#type: serde_json::Value,
pub content: String,
}
// ---- ToolCallEvent (module: events) ----
/// Represents a request to execute a tool.
#[derive(Debug, Clone)]
pub struct ToolCallEvent {
pub r#type: serde_json::Value,
pub call: rs_genai::prelude::FunctionCall,
}
// ---- ToolCallPolicyContext (module: plugins) ----
// Cannot derive Clone or Default
pub struct ToolCallPolicyContext {
pub tool: Arc<dyn ToolFunction>,
pub tool_args: serde_json::Value,
}
// ---- ToolConfirmationEvent (module: events) ----
/// Represents a request for tool confirmation.
#[derive(Debug, Clone, Default)]
pub struct ToolConfirmationEvent {
pub r#type: serde_json::Value,
pub confirmations: serde_json::Value,
}
// ---- ToolResultEvent (module: events) ----
/// Represents the result of a tool execution.
#[derive(Debug, Clone)]
pub struct ToolResultEvent {
pub r#type: serde_json::Value,
pub result: rs_genai::prelude::FunctionResponse,
}
// ---- TraceAgentInvocationParams (module: telemetry) ----
// Cannot derive Clone or Default
pub struct TraceAgentInvocationParams {
pub agent: Arc<dyn Agent>,
pub invocation_context: serde_json::Value,
}
// ---- TraceCallLlmParams (module: telemetry) ----
#[derive(Debug, Clone, Default)]
pub struct TraceCallLlmParams {
pub invocation_context: serde_json::Value,
pub event_id: String,
pub llm_request: serde_json::Value,
pub llm_response: serde_json::Value,
}
// ---- TraceSendDataParams (module: telemetry) ----
#[derive(Debug, Clone)]
pub struct TraceSendDataParams {
/// The invocation context for the current agent run.
pub invocation_context: serde_json::Value,
/// The ID of the event.
pub event_id: String,
/// A list of content objects.
pub data: Vec<rs_genai::prelude::Content>,
}
// ---- TranscriptionEntry (module: agents) ----
/// Store the data that can be used for transcription.
#[derive(Debug, Clone)]
pub struct TranscriptionEntry {
/// The role that created this data, typically "user" or "model". For function call, this is undefined.
pub role: Option<String>,
pub data: rs_genai::prelude::Blob,
}
// ---- UpdateCodeExecutionResultParams (module: code_executors) ----
/// The parameters for updating the code execution result. */
#[derive(Debug, Clone, Default)]
pub struct UpdateCodeExecutionResultParams {
pub invocation_id: String,
pub code: String,
pub result_stdout: String,
pub result_stderr: String,
}