//! Shared agent handle: every subsystem task holds an `Arc<Agent>`.

use std::collections::HashMap;
use std::sync::Arc;
use std::time::Instant;
use tokio::sync::RwLock;
use tokio_util::sync::CancellationToken;

use crate::config::Settings;
use crate::prober::ProbeReport;
use crate::supervisor::Supervisor;

pub struct Agent {
    pub cfg: Settings,
    pub nats: async_nats::Client,
    pub started: Instant,
    pub last_probe: RwLock<Option<ProbeReport>>,
    /// One supervisor per instance, keyed by instance id. The concrete impl
    /// (process vs docker-compose) is chosen per game by the factory in main;
    /// every subsystem talks to the `Supervisor` trait only.
    pub supervisors: HashMap<String, Arc<dyn Supervisor>>,
    pub shutdown: CancellationToken,
}
