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