vtcode_core/pods/state.rs
1use serde::{Deserialize, Serialize};
2use std::collections::BTreeMap;
3
4/// Root state for VT Code pod management.
5#[derive(Debug, Clone, Serialize, Deserialize)]
6pub struct PodsState {
7 /// Schema version for forward-compatible deserialization.
8 pub version: String,
9 /// The currently active pod, or `None` if no pod has been configured.
10 #[serde(default)]
11 pub active_pod: Option<PodState>,
12}
13
14impl Default for PodsState {
15 fn default() -> Self {
16 Self {
17 version: env!("CARGO_PKG_VERSION").to_string(),
18 active_pod: None,
19 }
20 }
21}
22
23/// Active pod definition persisted in the user state directory's `pods/state.json`.
24#[derive(Debug, Clone, Serialize, Deserialize)]
25pub struct PodState {
26 /// Human-readable pod name.
27 pub name: String,
28 /// SSH connection string (e.g. `"ssh root@192.168.1.10"`).
29 pub ssh: String,
30 /// Optional path on the pod where model weights reside.
31 #[serde(default)]
32 pub models_path: Option<String>,
33 /// GPU inventory for this pod.
34 #[serde(default)]
35 pub gpus: Vec<PodGpu>,
36 /// Currently running models keyed by their user-facing name.
37 #[serde(default)]
38 pub models: BTreeMap<String, RunningModel>,
39}
40
41impl PodState {
42 /// Return the total number of GPUs available on this pod.
43 pub fn gpu_count(&self) -> usize {
44 self.gpus.len()
45 }
46}
47
48/// GPU inventory entry for a pod.
49#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
50pub struct PodGpu {
51 /// Device index as reported by `nvidia-smi`.
52 pub id: u32,
53 /// GPU product name (e.g. `"NVIDIA A100-SXM4-80GB"`).
54 pub name: String,
55}
56
57/// Running model metadata stored for later inspection and shutdown.
58#[derive(Debug, Clone, Serialize, Deserialize)]
59pub struct RunningModel {
60 /// Hugging Face model identifier.
61 pub model: String,
62 /// Port the vLLM server is listening on.
63 pub port: u16,
64 /// IDs of GPUs allocated to this model.
65 #[serde(default)]
66 pub gpu_ids: Vec<u32>,
67 /// Remote process ID.
68 pub pid: u32,
69 /// Name of the catalog profile used to launch this model.
70 pub profile: String,
71}
72
73/// Pod runtime health classification.
74#[derive(Debug, Clone, Copy, PartialEq, Eq)]
75pub enum PodHealth {
76 /// Process is alive and the health endpoint responds.
77 Running,
78 /// Process is alive but the health endpoint is not yet ready.
79 Starting,
80 /// Process exited with a known failure pattern in the logs.
81 Crashed,
82 /// Process is not running.
83 Dead,
84}