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
Trait Implementations§
Source§impl Clone for SessionState
impl Clone for SessionState
Source§fn clone(&self) -> SessionState
fn clone(&self) -> SessionState
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
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
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for SessionState
impl<'de> Deserialize<'de> for SessionState
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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>
Wrap the input message
T in a tonic::Request