pub mod bash_command;
pub mod context_save;
pub mod file_write_or_edit;
pub mod initialize;
pub mod read_files;
pub mod read_image;
use std::sync::Arc;
use tokio::sync::Mutex; use tracing::info;
use crate::state::bash_state::BashState;
pub type SharedBashState = Arc<Mutex<Option<BashState>>>;
#[allow(dead_code)]
const MCP_PROTOCOL_VERSION: &str = "2024-11-05";
#[derive(Debug, Clone)]
pub struct WinxService {
bash_state: SharedBashState,
version: String,
start_time: std::time::Instant,
}
impl Default for WinxService {
fn default() -> Self {
Self::new()
}
}
impl WinxService {
pub fn new() -> Self {
info!("Creating new WinxService instance");
Self {
bash_state: Arc::new(Mutex::new(None)),
version: env!("CARGO_PKG_VERSION").to_string(),
start_time: std::time::Instant::now(),
}
}
pub fn uptime(&self) -> std::time::Duration {
self.start_time.elapsed()
}
pub fn version(&self) -> &str {
&self.version
}
#[allow(dead_code)]
async fn lock_bash_state(&self) -> tokio::sync::MutexGuard<'_, Option<BashState>> {
self.bash_state.lock().await
}
}