Module prelude

Module prelude 

Source
Expand description

Convenience re-exports for common types across all layers.

Re-exports§

pub use crate::a2a::A2AServer;
pub use crate::a2a::AgentRegistry;
pub use crate::a2a::RemoteAgent;
pub use crate::a2a::SkillDeclaration;
pub use crate::compose::Ctx;
pub use crate::compose::A;
pub use crate::compose::C;
pub use crate::compose::E;
pub use crate::compose::G;
pub use crate::compose::M;
pub use crate::compose::P;
pub use crate::compose::S;
pub use crate::compose::T;
pub use crate::live::Live;
pub use crate::builder::*;
pub use crate::live_builders::*;
pub use crate::operators::*;
pub use crate::patterns::*;
pub use crate::testing::*;

Modules§

client
Client → Server message types for the Gemini Live wire protocol.
server
Server → Client message types for the Gemini Live wire protocol.

Structs§

ActivityEnd
Marker for speech activity end.
ActivitySignalMessage
Activity signal for client-side VAD events.
ActivitySignalPayload
Payload for activity signals.
ActivityStart
Marker for speech activity start.
AgentSession
Intercepting wrapper around a SessionWriter.
AudioJitterBuffer
Adaptive jitter buffer for audio playback.
AuthCredential
An authentication credential with optional token, refresh, and metadata.
AutomaticActivityDetection
Automatic activity detection (VAD) settings.
BargeInConfig
Configuration for barge-in behavior.
BargeInDetector
Barge-in detector — checks whether user speech should interrupt model output.
Blob
A blob of inline data (audio, image, etc.) sent to or received from Gemini.
CallbackContext
Rich context for callbacks — provides access to state, artifacts, memory, and event actions for mutation.
Candidate
A single response candidate.
CitationMetadata
Citation metadata for a response.
CitationSource
A single citation source.
Client
Unified Gemini API client.
ClientContentMessage
Client content message for sending text or conversation history.
ClientContentPayload
Payload for client content.
CodeExecutionResult
Result of code execution.
ConnectBuilder
Builder for advanced connection configuration.
Content
A content message containing a role and a sequence of parts.
ContextWindowCompressionConfig
Context window compression configuration for long sessions.
DefaultResultFormatter
Default formatter that wraps results in a status object.
DeferredWriter
A SessionWriter wrapper that flushes pending context before user content.
DispatchTextAgent
Fire-and-forget background task launcher with global task budget.
EventCallbacks
Typed callback registry for Live session events.
ExecutableCode
Executable code returned by the model.
FallbackTextAgent
Tries each child agent in sequence. Returns the first successful result. If all fail, returns the last error.
FieldPromotion
Rule for promoting one raw extraction field into authoritative state.
FileData
Reference to an uploaded file.
FnTextAgent
Zero-cost state transform agent — executes a closure, no LLM call.
FsPersistence
File-system persistence (good for development and single-server deployments).
FunctionCall
A function call request from the model.
FunctionCallingConfig
Configuration for function calling behavior.
FunctionDeclaration
Schema for a single function that the model can call.
FunctionResponse
A function call response sent back to the model.
GeminiLlm
Concrete Gemini LLM implementation using gemini-live Client.
GeminiLlmParams
Parameters for constructing a GeminiLlm.
GenerateContentConfig
Configuration for a generateContent request.
GenerateContentResponse
Top-level response from generateContent.
GenerationConfig
Generation config sent in the setup message.
GoAwayMessage
Server GoAway signal — requesting graceful disconnect.
GoAwayPayload
Payload for GoAway.
GoogleAIAuth
Google AI API key authentication.
GoogleAITokenAuth
Google AI OAuth2 access token authentication.
GoogleSearch
Google Search tool configuration (empty — presence enables the feature).
GoogleSearchRetrieval
Google Search retrieval tool configuration.
GroundingMetadata
Grounding metadata for server content with search results.
HttpClient
HTTP client wrapping reqwest with retry and telemetry.
HttpConfig
Configuration for the HTTP client.
InMemoryCredentialService
In-memory credential service for testing and development.
InMemoryRunner
Runs TextAgents with full service wiring (session, memory, artifacts, plugins).
InputAudioTranscription
Input audio transcription configuration.
JitterConfig
Configuration for the jitter buffer.
JoinTextAgent
Waits for dispatched background tasks and collects their results.
JsonCodec
Default JSON codec — current behavior extracted from connection.rs.
LiveHandle
Handle for interacting with a running Live session.
LiveSessionBuilder
Builder for a callback-driven Live session.
LlmExtractor
LLM-backed turn extractor that sends transcript windows to an OOB LLM with a structured extraction prompt.
LlmRegistry
Registry that maps model name patterns to LLM factory functions.
LlmRequest
Configuration for an LLM generation request.
LlmResponse
The response from an LLM generation request.
LlmTextAgent
Core text agent — calls BaseLlm::generate(), dispatches tools, loops until the model produces a final text response.
LoopTextAgent
Runs a text agent repeatedly until max iterations or a state predicate.
MapOverTextAgent
Iterates a single agent over each item in a state list. Reads state[list_key], runs agent per item (setting state[item_key]), collects results into state[output_key].
MediaChunk
A single chunk of media data (audio). Deprecated — use Blob in audio field.
MemoryPersistence
In-memory persistence (good for tests).
MockTransport
Mock transport for unit testing.
ModalityTokenCount
Token count breakdown by modality (text, audio, image, video).
NeedsFulfillment
Tracks need fulfillment per phase and recommends repair actions.
NoOpSessionWriter
A SessionWriter that discards all writes. Used for isolated agent execution (AgentTool) where no real WebSocket exists.
OutputAudioTranscription
Output audio transcription configuration.
ParallelTextAgent
Runs text agents concurrently. All branches share state. Results are collected and joined with newlines.
PendingContext
Thread-safe buffer for pending context turns awaiting delivery.
PrebuiltVoiceConfig
Prebuilt voice selection.
ProactivityConfig
Proactivity configuration — controls whether the model can initiate responses.
RaceTextAgent
Runs agents concurrently, returns the first to complete. Cancels the rest.
RealtimeInputConfig
Server-side VAD configuration for the setup message.
RealtimeInputMessage
Realtime audio input sent as a stream of chunks.
RealtimeInputPayload
Payload for realtime audio input.
RepairConfig
Configuration for the conversation repair system.
ResumeInfo
Session resumption information from the server.
RouteRule
A routing rule: predicate over state → target agent.
RouteTextAgent
State-driven deterministic branching — evaluates predicates in order, dispatches to the first matching agent. Falls back to default if none match.
RunConfig
Configuration for an agent execution run.
SafetyRating
Per-category safety assessment of generated content.
SafetySetting
Per-category safety configuration for content generation.
SequentialTextAgent
Runs text agents sequentially. Each agent sees state mutations from previous agents. The final agent’s output is the pipeline’s output.
ServerContentMessage
Server content message containing model output.
ServerContentPayload
Payload for server content.
ServerMessageWrapper
Server message wrapper — includes optional usage metadata alongside the message.
SessionConfig
Complete session configuration — the builder entrypoint.
SessionHandle
The public API surface for a Gemini Live session.
SessionResumptionConfig
Session resumption configuration.
SessionResumptionResult
Session resumption result from server.
SessionResumptionUpdateMessage
Session resumption update from server (sent during active session).
SessionResumptionUpdatePayload
Payload for session resumption update.
SessionSnapshot
Serializable snapshot of the control plane state.
SetupCompleteMessage
Server setup complete acknowledgment.
SetupCompletePayload
Payload for setup complete.
SetupMessage
Top-level setup message sent immediately after WebSocket connect.
SetupPayload
Payload of the setup message.
SlidingWindow
Sliding window configuration for context compression.
SoftTurnDetector
Detects proactive silence — user stopped speaking but model didn’t respond.
SpeechConfig
Speech configuration for audio output.
SpscRing
Lock-free single-producer single-consumer ring buffer.
State
A concurrent, type-safe state container that agents read from and write to.
StateKey
A compile-time typed state key that eliminates typo bugs and type mismatches.
StaticToolset
A simple toolset backed by a fixed list of tools.
TapTextAgent
Read-only observation agent. Calls a function with the state but cannot mutate it. Returns empty string. No LLM call.
TaskRegistry
Shared registry for dispatched background tasks.
TelemetryConfig
Telemetry configuration.
ThinkingConfig
Configuration for model thinking/reasoning (Gemini 2.5+).
TimeoutTextAgent
Wraps an agent with a time limit. Returns AgentError::Timeout if exceeded.
Tool
A tool declaration sent in the setup message. Each Tool object can contain one of: function declarations, urlContext, googleSearch, codeExecution, or googleSearchRetrieval.
ToolCallCancellationMessage
Server tool call cancellation message.
ToolCallCancellationPayload
Payload for tool call cancellation.
ToolCallMessage
Server tool call request message.
ToolCallPayload
Payload for tool call.
ToolCodeExecution
Code execution tool configuration (empty — presence enables the feature).
ToolConfig
Controls how and when the model uses tools.
ToolConfirmation
Represents a user’s confirmation decision for a tool call.
ToolContext
Extended context for tool execution — adds function call ID and confirmation.
ToolResponseMessage
Tool response message sent after executing function calls.
ToolResponsePayload
Payload for tool response.
TranscriptBuffer
Accumulates input/output transcripts and segments them by turn boundaries.
TranscriptTurn
A single completed conversation turn with accumulated transcripts.
TranscriptionPayload
Transcription text from server.
TransportConfig
Configuration for the transport layer.
TungsteniteTransport
WebSocket transport using tokio-tungstenite.
TurnDetectionConfig
Configuration for client-side turn detection.
TurnDetector
Client-side turn detector.
UrlContext
URL context tool configuration (empty — presence enables the feature).
UrlContextMetadata
URL context metadata for content sourced from URLs.
UsageMetadata
Usage metadata returned by the server on messages.
VadConfig
VAD configuration parameters.
VertexAIAuth
Vertex AI Bearer token authentication.
VertexConfig
Configuration for connecting through Vertex AI.
VoiceActivityDetector
Voice Activity Detector with adaptive noise floor.
VoiceActivityMessage
Server-side voice activity detection event.
VoiceActivityPayload
Payload for voice activity detection.
VoiceConfig
Voice configuration within speech config.

Enums§

ActivityHandling
Controls how incoming audio interacts with model output.
AgentError
Errors that can occur during agent execution.
ApiEndpoint
API endpoint selector — Google AI (direct), Google AI with OAuth token, or Vertex AI.
AudioFormat
Audio encoding formats supported by the Gemini Live API.
AuthError
Authentication-specific errors.
BargeInAction
Result of a barge-in check.
CallbackMode
Controls how a control-lane callback is executed relative to the event loop.
CodecError
Error during encoding or decoding.
ContextDelivery
When to deliver model-role context turns to the wire.
ExtractionTrigger
Controls WHEN an extractor runs.
FinishReason
Why the model stopped generating.
FunctionCallingBehavior
Whether tool calls block model output or run concurrently.
FunctionCallingMode
How the model should decide when to execute tool calls.
FunctionResponseScheduling
Scheduling mode for non-blocking function responses.
GeminiModel
Gemini models that support the Multimodal Live API.
GenerateError
Errors specific to the Generate API.
HarmBlockThreshold
Blocking threshold for safety settings.
HarmCategory
Categories of potential harm in model output.
HarmProbability
Probability that content is harmful.
HttpError
Errors from HTTP client operations.
InputEvent
Input events broadcast to input-streaming tools. Distinct from SessionCommand — this is observation-only.
LiveEvent
Semantic events emitted by the Live session processor.
MediaResolution
Media resolution for image/video inputs.
MergePolicy
How an extracted field should be merged into authoritative session state.
Modality
Output modalities the model can produce.
Part
A single part of a Content message. Parts are polymorphic — discriminated by field presence, not a type tag.
Platform
Which platform variant to use for the Gemini API.
RepairAction
What action the repair system recommends.
Role
Role in a conversation.
Sensitivity
Voice activity detection sensitivity level.
ServerMessage
Unified server message enum — parsed from incoming WebSocket text frames.
ServiceEndpoint
Identifies which Gemini API service to connect to.
SessionCommand
Commands sent from application code to the session transport.
SessionError
Errors that can occur during a session.
SessionEvent
Events emitted by the session, consumed by application code.
SessionPhase
The lifecycle phase of a Gemini Live session.
SetupError
Errors during the setup handshake phase.
SteeringMode
How the phase machine steers the model’s behavior.
StreamingMode
How the agent communicates with clients.
ToolError
Errors that can occur during tool execution.
ToolExecutionMode
Execution mode for a tool.
TurnCoverage
Controls which input counts toward a user’s conversation turn.
TurnDetectionEvent
Events from the turn detector.
VadEvent
Events emitted by the VAD.
Voice
Available voice presets for Gemini Live audio output.
VoiceActivityType
Type of voice activity event from the server.
WebSocketError
WebSocket-level errors with structured detail.

Traits§

AuthProvider
Provides authentication credentials and URL construction for Gemini API connections.
BaseLlm
Trait for LLM providers — decouples agents from specific models.
Codec
Encodes client commands into wire bytes and decodes server bytes into messages.
CredentialService
Trait for credential persistence — load, save, delete.
ResultFormatter
Formats tool responses for background execution lifecycle.
SessionPersistence
Trait for persisting session state across process restarts.
SessionReader
Read-side of a session — subscribe to events and observe phase.
SessionWriter
Write-side of a session — send commands without owning the full handle.
TextAgent
A text-based agent that runs via BaseLlm::generate() (request/response).
ToolProvider
Declares tools for a Gemini session setup message. Implement this trait to provide tools from any source (runtime ToolDispatcher, etc.).
Toolset
A collection of tools that can be enumerated.
Transport
A bidirectional message transport.
TurnExtractor
Trait for between-turn extraction from transcript windows.

Functions§

bytes_to_i16
Convert raw bytes to i16 PCM samples (zero-copy via bytemuck).
connect
Connect to the Gemini Multimodal Live API and return a session handle.
connect_with
Connect with a custom transport and codec.
i16_to_bytes
Convert a slice of i16 PCM samples to raw bytes (zero-copy via bytemuck).
inject_session_state
Replace {key} placeholders in template with values from state.
into_shared
Wrap raw bytes as a shared Bytes handle for zero-copy fan-out.
quick_connect
Connect to Gemini Live with minimal configuration.
quick_connect_vertex
Connect via Vertex AI with minimal configuration.
recv_event
Receive the next event from a broadcast receiver, handling lag gracefully.

Type Aliases§

ToolDeclaration
Backward-compatible alias for Tool.