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 mod transcript;
63pub mod turn_commit;
64pub(crate) mod turn_trace;
65pub mod watcher;
66
67pub use background_agent_dispatch::BackgroundAgentDispatcher;
68pub use background_tool::{
69    BackgroundToolTracker, DefaultResultFormatter, ResultFormatter, ToolExecutionMode,
70};
71pub use builder::LiveSessionBuilder;
72pub use callbacks::EventCallbacks;
73pub use computed::{ComputedRegistry, ComputedVar};
74pub use context_builder::ContextBuilder;
75pub use context_writer::{DeferredWriter, PendingContext};
76pub use contract::{
77    ComputedContract, ControlContract, ExtractorContract, PhaseContract, PreparationContract,
78    PromotionContract, RuntimeContract, ToolContract, TransitionContract, WatcherContract,
79};
80pub use effect_executor::LiveEffectExecutor;
81pub use events::{LiveEvent, LiveEventStream};
82pub use extractor::{ExtractionTrigger, FieldPromotion, LlmExtractor, MergePolicy, TurnExtractor};
83pub use handle::LiveHandle;
84pub use input_vad::{ActivityAuthority, BackendInputVad, BackendVadSnapshot, InputAudioProcessor};
85pub use needs::{NeedsFulfillment, RepairAction, RepairConfig};
86pub use persistence::{
87    FsPersistence, MemoryPersistence, PersistenceError, SessionPersistence, SessionSnapshot,
88};
89pub use phase::{
90    EnterContextFn, InstructionModifier, Phase, PhaseInstruction, PhaseMachine, PhasePreparation,
91    Transition, TransitionEvaluation, TransitionRecord, TransitionResult, TransitionTrigger,
92};
93pub use playback::PlaybackClock;
94pub use processor::{Delivery, DeliveryConfig};
95pub use reactor::{
96    EffectPolicy, LiveEffect, LiveReactor, Reaction, ReactorEvent, ReactorRule, VoiceRuntimeState,
97};
98pub use replay::{ReplaySession, attach_session, collect_events_until_idle, replay_session};
99pub use session_signals::{SessionSignals, SessionType};
100pub use soft_turn::SoftTurnDetector;
101pub use steering::{ContextDelivery, SteeringMode};
102pub use telemetry::{
103    LATENCY_BUCKETS_MS, LATENCY_RECENT_WINDOW, LatencyBucket, LatencyStats, SessionTelemetry,
104};
105pub use temporal::{
106    ConsecutiveFailureDetector, PatternDetector, RateDetector, SustainedDetector, TemporalPattern,
107    TemporalRegistry, TurnCountDetector,
108};
109pub use transcript::{ToolCallSummary, TranscriptBuffer, TranscriptTurn, TranscriptWindow};
110pub use turn_commit::{TurnCommitConfig, TurnCommitPolicy, TurnSignal};
111pub use watcher::{PredicateFn, WatchPredicate, Watcher, WatcherRegistry};