pub struct AgentSession { /* private fields */ }Expand description
Intercepting wrapper around a SessionWriter.
Adds input fan-out, middleware hooks, and state tracking without introducing a second queue (avoids double-queuing).
Implementations§
Source§impl AgentSession
impl AgentSession
Sourcepub fn new(session: SessionHandle) -> Self
pub fn new(session: SessionHandle) -> Self
Create a new AgentSession wrapping a SessionHandle.
Sourcepub fn from_writer(
writer: Arc<dyn SessionWriter>,
event_tx: Sender<SessionEvent>,
) -> Self
pub fn from_writer( writer: Arc<dyn SessionWriter>, event_tx: Sender<SessionEvent>, ) -> Self
Create from a trait-object writer (enables mock testing and middleware injection).
Sourcepub async fn send_audio(&self, data: Vec<u8>) -> Result<(), AgentError>
pub async fn send_audio(&self, data: Vec<u8>) -> Result<(), AgentError>
Send audio data. Fans out to input-streaming tools ONLY if listeners exist.
Sourcepub async fn send_text(&self, text: impl Into<String>) -> Result<(), AgentError>
pub async fn send_text(&self, text: impl Into<String>) -> Result<(), AgentError>
Send a text message.
Sourcepub async fn send_tool_response(
&self,
responses: Vec<FunctionResponse>,
) -> Result<(), AgentError>
pub async fn send_tool_response( &self, responses: Vec<FunctionResponse>, ) -> Result<(), AgentError>
Send tool responses.
Sourcepub async fn send_client_content(
&self,
turns: Vec<Content>,
turn_complete: bool,
) -> Result<(), AgentError>
pub async fn send_client_content( &self, turns: Vec<Content>, turn_complete: bool, ) -> Result<(), AgentError>
Send client content (conversation history or context injection).
Sourcepub async fn send_video(&self, jpeg_data: Vec<u8>) -> Result<(), AgentError>
pub async fn send_video(&self, jpeg_data: Vec<u8>) -> Result<(), AgentError>
Send video/image data (raw JPEG bytes).
Sourcepub async fn update_instruction(
&self,
instruction: impl Into<String>,
) -> Result<(), AgentError>
pub async fn update_instruction( &self, instruction: impl Into<String>, ) -> Result<(), AgentError>
Update the system instruction mid-session.
Sourcepub async fn signal_activity_start(&self) -> Result<(), AgentError>
pub async fn signal_activity_start(&self) -> Result<(), AgentError>
Signal activity start (user started speaking).
Sourcepub async fn signal_activity_end(&self) -> Result<(), AgentError>
pub async fn signal_activity_end(&self) -> Result<(), AgentError>
Signal activity end (user stopped speaking).
Sourcepub async fn disconnect(&self) -> Result<(), AgentError>
pub async fn disconnect(&self) -> Result<(), AgentError>
Gracefully disconnect.
Sourcepub fn subscribe_input(&self) -> Receiver<InputEvent>
pub fn subscribe_input(&self) -> Receiver<InputEvent>
Subscribe to input events (for input-streaming tools).
Sourcepub fn subscribe_events(&self) -> Receiver<SessionEvent>
pub fn subscribe_events(&self) -> Receiver<SessionEvent>
Subscribe to session events.
Sourcepub fn writer(&self) -> &dyn SessionWriter
pub fn writer(&self) -> &dyn SessionWriter
Access the underlying session writer.
Sourcepub fn input_subscriber_count(&self) -> usize
pub fn input_subscriber_count(&self) -> usize
Number of input-streaming subscribers (for diagnostics).
Trait Implementations§
Source§impl Clone for AgentSession
impl Clone for AgentSession
Source§fn clone(&self) -> AgentSession
fn clone(&self) -> AgentSession
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more