pub struct AISession {
pub id: SessionId,
pub config: SessionConfig,
pub status: RwLock<SessionStatus>,
pub context: Arc<RwLock<SessionContext>>,
pub created_at: DateTime<Utc>,
pub last_activity: Arc<RwLock<DateTime<Utc>>>,
pub metadata: Arc<RwLock<HashMap<String, Value>>>,
pub command_history: Arc<RwLock<Vec<CommandRecord>>>,
pub command_count: Arc<RwLock<usize>>,
pub total_tokens: Arc<RwLock<usize>>,
/* private fields */
}Expand description
AI-optimized session
Fields§
§id: SessionIdUnique session ID
config: SessionConfigSession configuration
status: RwLock<SessionStatus>Current status
context: Arc<RwLock<SessionContext>>Session context (AI state, history, etc.)
created_at: DateTime<Utc>Creation time
last_activity: Arc<RwLock<DateTime<Utc>>>Last activity time
metadata: Arc<RwLock<HashMap<String, Value>>>Session metadata
command_history: Arc<RwLock<Vec<CommandRecord>>>Command history tracking
command_count: Arc<RwLock<usize>>Command count
total_tokens: Arc<RwLock<usize>>Total tokens used
Implementations§
Source§impl AISession
impl AISession
Sourcepub async fn new(config: SessionConfig) -> Result<Self>
pub async fn new(config: SessionConfig) -> Result<Self>
Create a new AI session
Sourcepub async fn new_with_id(
id: SessionId,
config: SessionConfig,
created_at: DateTime<Utc>,
) -> Result<Self>
pub async fn new_with_id( id: SessionId, config: SessionConfig, created_at: DateTime<Utc>, ) -> Result<Self>
Create an AI session with a specific ID (for restoration)
Sourcepub async fn send_input(&self, input: &str) -> Result<()>
pub async fn send_input(&self, input: &str) -> Result<()>
Send input to the session
Sourcepub async fn read_output(&self) -> Result<Vec<u8>>
pub async fn read_output(&self) -> Result<Vec<u8>>
Read output from the session
Sourcepub async fn status(&self) -> SessionStatus
pub async fn status(&self) -> SessionStatus
Get current session status
Sourcepub async fn set_metadata(&self, key: String, value: Value) -> Result<()>
pub async fn set_metadata(&self, key: String, value: Value) -> Result<()>
Update session metadata
Sourcepub async fn get_metadata(&self, key: &str) -> Option<Value>
pub async fn get_metadata(&self, key: &str) -> Option<Value>
Get session metadata
Sourcepub async fn execute_command(&self, command: &str) -> Result<String>
pub async fn execute_command(&self, command: &str) -> Result<String>
Execute a command and record it in history
Sourcepub async fn add_tokens(&self, token_count: usize)
pub async fn add_tokens(&self, token_count: usize)
Add tokens to the session total
Sourcepub async fn get_command_history(&self) -> Vec<CommandRecord>
pub async fn get_command_history(&self) -> Vec<CommandRecord>
Get command history
Sourcepub async fn get_command_count(&self) -> usize
pub async fn get_command_count(&self) -> usize
Get command count
Sourcepub async fn get_total_tokens(&self) -> usize
pub async fn get_total_tokens(&self) -> usize
Get total tokens used
Sourcepub async fn trim_command_history(&self, keep_recent: usize)
pub async fn trim_command_history(&self, keep_recent: usize)
Clear command history (keep recent N commands)
Source§impl AISession
impl AISession
Sourcepub async fn get_ai_context(&self) -> Result<SessionContext>
pub async fn get_ai_context(&self) -> Result<SessionContext>
Get AI context
Auto Trait Implementations§
impl !Freeze for AISession
impl !RefUnwindSafe for AISession
impl Send for AISession
impl Sync for AISession
impl Unpin for AISession
impl !UnwindSafe for AISession
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.