pub struct SessionState {
pub messages: Vec<Message>,
pub tool_calls: HashMap<String, ToolCallState>,
pub approved_tools: HashSet<String>,
pub approved_bash_patterns: HashSet<String>,
pub last_event_sequence: u64,
pub metadata: HashMap<String, String>,
pub active_message_id: Option<String>,
pub mcp_servers: HashMap<String, McpServerInfo>,
}Expand description
Mutable session state that changes during execution
Fields§
§messages: Vec<Message>Conversation messages
tool_calls: HashMap<String, ToolCallState>Tool call tracking
approved_tools: HashSet<String>Tools that have been approved for this session
approved_bash_patterns: HashSet<String>Bash commands that have been approved for this session (dynamically added)
last_event_sequence: u64Last processed event sequence number for replay
metadata: HashMap<String, String>Additional runtime metadata
active_message_id: Option<String>The ID of the currently active message (head of selected branch) None means use last message semantics for backward compatibility
mcp_servers: HashMap<String, McpServerInfo>Status of MCP server connections This is a transient field that is rebuilt on session activation
Implementations§
Source§impl SessionState
impl SessionState
Sourcepub fn add_message(&mut self, message: Message)
pub fn add_message(&mut self, message: Message)
Add a message to the conversation
Sourcepub fn message_count(&self) -> usize
pub fn message_count(&self) -> usize
Get the number of messages in the conversation
Sourcepub fn last_message(&self) -> Option<&Message>
pub fn last_message(&self) -> Option<&Message>
Get the last message in the conversation
Sourcepub fn add_tool_call(&mut self, tool_call: ToolCall)
pub fn add_tool_call(&mut self, tool_call: ToolCall)
Add a tool call to tracking
Sourcepub fn update_tool_call_status(
&mut self,
tool_call_id: &str,
status: ToolCallStatus,
) -> Result<(), String>
pub fn update_tool_call_status( &mut self, tool_call_id: &str, status: ToolCallStatus, ) -> Result<(), String>
Update tool call status
Sourcepub fn approve_tool(&mut self, tool_name: String)
pub fn approve_tool(&mut self, tool_name: String)
Approve a tool for future use
Sourcepub fn is_tool_approved(&self, tool_name: &str) -> bool
pub fn is_tool_approved(&self, tool_name: &str) -> bool
Check if a tool is approved
Sourcepub fn apply_event(&mut self, event: &StreamEvent) -> Result<(), String>
pub fn apply_event(&mut self, event: &StreamEvent) -> Result<(), String>
Apply an event to the session state
Trait Implementations§
Source§impl Clone for SessionState
impl Clone for SessionState
Source§fn clone(&self) -> SessionState
fn clone(&self) -> SessionState
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SessionState
impl Debug for SessionState
Source§impl Default for SessionState
impl Default for SessionState
Source§fn default() -> SessionState
fn default() -> SessionState
Source§impl<'de> Deserialize<'de> for SessionState
impl<'de> Deserialize<'de> for SessionState
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<SessionState, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<SessionState, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl Serialize for SessionState
impl Serialize for SessionState
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Auto Trait Implementations§
impl Freeze for SessionState
impl RefUnwindSafe for SessionState
impl Send for SessionState
impl Sync for SessionState
impl Unpin for SessionState
impl UnwindSafe for SessionState
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request