Skip to main content

alien_core/
dev_status.rs

1//! Types for `alien dev` status file output
2
3use crate::DeploymentStatus;
4use alien_error::AlienError;
5use serde::{Deserialize, Serialize};
6use std::collections::HashMap;
7
8/// Overall status of the dev server
9#[derive(Debug, Clone, Serialize, Deserialize)]
10#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
11#[serde(rename_all = "camelCase")]
12pub struct DevStatus {
13    /// Dev server process ID
14    pub pid: u32,
15    /// Platform (always "local" for dev server)
16    pub platform: String,
17    /// Stack ID (always "dev" for dev server)
18    pub stack_id: String,
19    /// Path to state directory
20    pub state_dir: String,
21    /// Dev server API URL (e.g., http://localhost:9090)
22    pub api_url: String,
23    /// ISO 8601 timestamp when dev server started
24    pub started_at: String,
25    /// Overall dev server status
26    pub status: DevStatusState,
27    /// Agents being managed by this dev server (keyed by agent name)
28    pub agents: HashMap<String, AgentStatus>,
29    /// ISO 8601 timestamp of last status update
30    pub last_updated: String,
31    /// Global error if dev server itself has an error
32    #[serde(skip_serializing_if = "Option::is_none")]
33    pub error: Option<AlienError>,
34}
35
36/// Overall dev server status
37#[derive(Debug, Clone, Serialize, Deserialize)]
38#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
39#[serde(rename_all = "camelCase")]
40pub enum DevStatusState {
41    /// Dev server is starting up
42    Initializing,
43    /// At least one agent is running
44    Ready,
45    /// Dev server or agents encountered errors
46    Error,
47    /// Dev server is shutting down
48    ShuttingDown,
49}
50
51/// Status of a single agent in the dev server
52#[derive(Debug, Clone, Serialize, Deserialize)]
53#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
54#[serde(rename_all = "camelCase")]
55pub struct AgentStatus {
56    /// Agent ID (e.g., ag_xyz123)
57    pub id: String,
58    /// Agent name (from --agent-name flag)
59    pub name: String,
60    /// Deployment status (running, provisioning, etc.)
61    pub status: DeploymentStatus,
62    /// Resources deployed by this agent (keyed by resource name)
63    pub resources: HashMap<String, DevResourceInfo>,
64    /// ISO 8601 timestamp when agent was created
65    pub created_at: String,
66    /// Error if this agent has failed
67    #[serde(skip_serializing_if = "Option::is_none")]
68    pub error: Option<AlienError>,
69}
70
71/// Information about a deployed resource
72#[derive(Debug, Clone, Serialize, Deserialize)]
73#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
74#[serde(rename_all = "camelCase")]
75pub struct DevResourceInfo {
76    /// Resource URL (e.g., http://localhost:8080)
77    pub url: String,
78    /// Resource type ("function" | "container")
79    #[serde(skip_serializing_if = "Option::is_none")]
80    pub resource_type: Option<String>,
81}