Skip to main content

gemini_adk_rs/live/
mod.rs

1//! Live session management — callback-driven full-duplex event handling.
2
3use std::sync::Arc;
4
5use gemini_genai_rs::session::SessionWriter;
6
7pub use crate::BoxFuture;
8use crate::state::State;
9
10/// How an async hook or effect runs relative to the control lane.
11///
12/// Every control-lane callback in [`EventCallbacks`] has a companion `_mode`
13/// field (e.g. `on_turn_complete_mode`), and every reactor
14/// [`EffectPolicy`] carries one. At the L2 fluent API level, `_concurrent`
15/// suffixed setters (e.g. `on_turn_complete_concurrent()`) set the callback
16/// and select [`Concurrent`](Self::Concurrent) in one call.
17#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
18pub enum ExecutionMode {
19    /// Awaited inline — the control lane waits for completion before the next
20    /// event or effect. Guarantees ordering and state consistency.
21    #[default]
22    Blocking,
23    /// Spawned as a detached tokio task — the control lane continues
24    /// immediately. Use for fire-and-forget work: logging, analytics, webhook
25    /// dispatch, background agent triggering.
26    Concurrent,
27}
28
29/// An async session hook: receives a clone of the shared [`State`] and the
30/// session writer. The shape of phase `on_enter`/`on_exit`, phase
31/// preparations, and temporal-pattern actions.
32pub type SessionHook = Arc<dyn Fn(State, Arc<dyn SessionWriter>) -> BoxFuture<()> + Send + Sync>;
33
34pub mod background_agent_dispatch;
35pub mod background_tool;
36pub mod builder;
37pub mod callbacks;
38pub mod computed;
39pub mod context_builder;
40pub mod context_writer;
41pub mod contract;
42pub(crate) mod control_plane;
43pub mod effect_executor;
44pub mod events;
45pub mod extractor;
46pub mod handle;
47pub mod input_vad;
48pub mod needs;
49pub mod persistence;
50pub mod phase;
51pub mod playback;
52pub(crate) mod processor;
53pub mod reactor;
54pub mod redaction;
55pub mod replay;
56mod reprompt;
57pub mod session_signals;
58pub mod soft_turn;
59pub mod steering;
60pub mod telemetry;
61pub mod temporal;
62pub(crate) mod tool_scope;
63pub mod transcript;
64pub mod turn_commit;
65pub(crate) mod turn_trace;
66pub mod watcher;
67
68pub use background_agent_dispatch::BackgroundAgentDispatcher;
69pub use background_tool::{
70    BackgroundToolTracker, DefaultResultFormatter, ResultFormatter, ToolExecutionMode,
71};
72pub use builder::LiveSessionBuilder;
73pub use callbacks::EventCallbacks;
74pub use computed::{ComputedRegistry, ComputedVar};
75pub use context_builder::ContextBuilder;
76pub use context_writer::{DeferredWriter, PendingContext};
77pub use contract::{
78    ComputedContract, ControlContract, ExtractorContract, PhaseContract, PreparationContract,
79    PromotionContract, RuntimeContract, ToolContract, TransitionContract, WatcherContract,
80};
81pub use effect_executor::LiveEffectExecutor;
82pub use events::{LiveEvent, LiveEventStream};
83pub use extractor::{ExtractionTrigger, FieldPromotion, LlmExtractor, MergePolicy, TurnExtractor};
84pub use handle::LiveHandle;
85pub use input_vad::{ActivityAuthority, BackendInputVad, BackendVadSnapshot, InputAudioProcessor};
86pub use needs::{NeedsFulfillment, RepairAction, RepairConfig};
87pub use persistence::{
88    FsPersistence, MemoryPersistence, PersistenceError, SessionPersistence, SessionSnapshot,
89};
90pub use phase::{
91    EnterContextFn, InstructionModifier, Phase, PhaseInstruction, PhaseMachine, PhasePreparation,
92    Transition, TransitionEvaluation, TransitionRecord, TransitionResult, TransitionTrigger,
93};
94pub use playback::PlaybackClock;
95pub use processor::{Delivery, DeliveryConfig};
96pub use reactor::{
97    EffectPolicy, LiveEffect, LiveReactor, Reaction, ReactorEvent, ReactorRule, VoiceRuntimeState,
98};
99pub use replay::{ReplaySession, attach_session, collect_events_until_idle, replay_session};
100pub use session_signals::{SessionSignals, SessionType};
101pub use soft_turn::SoftTurnDetector;
102pub use steering::{ContextDelivery, SteeringMode};
103pub use telemetry::{
104    LATENCY_BUCKETS_MS, LATENCY_RECENT_WINDOW, LatencyBucket, LatencyStats, SessionTelemetry,
105};
106pub use temporal::{
107    ConsecutiveFailureDetector, PatternDetector, RateDetector, SustainedDetector, TemporalPattern,
108    TemporalRegistry, TurnCountDetector,
109};
110pub use transcript::{ToolCallSummary, TranscriptBuffer, TranscriptTurn, TranscriptWindow};
111pub use turn_commit::{TurnCommitConfig, TurnCommitPolicy, TurnSignal};
112pub use watcher::{PredicateFn, WatchPredicate, Watcher, WatcherRegistry};
113
114mod task_tools;