//! Shared agent state: sysinfo handles and hot JSON cache. use std::sync::atomic::AtomicUsize; use std::{collections::HashMap, sync::Arc}; use sysinfo::{Components, Disks, Networks, System}; use tokio::sync::{Mutex, Notify, RwLock}; pub type SharedSystem = Arc>; pub type SharedNetworks = Arc>; pub type SharedTotals = Arc>>; pub type SharedComponents = Arc>; pub type SharedDisks = Arc>; #[derive(Clone)] pub struct AppState { // Persistent sysinfo handles pub sys: SharedSystem, pub nets: SharedNetworks, pub net_totals: SharedTotals, // iface -> (rx_total, tx_total) pub components: SharedComponents, pub disks: SharedDisks, // Last serialized JSON snapshot for fast WS responses pub last_json: Arc>, // Adaptive sampling controls pub client_count: Arc, pub wake_sampler: Arc, pub auth_token: Option, }