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    /// Commands endpoint URL for the deployment
61    #[serde(skip_serializing_if = "Option::is_none")]
62    pub commands_url: Option<String>,
63    /// Deployment status (running, provisioning, etc.)
64    pub status: DeploymentStatus,
65    /// Resources deployed by this agent (keyed by resource name)
66    pub resources: HashMap<String, DevResourceInfo>,
67    /// ISO 8601 timestamp when agent was created
68    pub created_at: String,
69    /// Error if this agent has failed
70    #[serde(skip_serializing_if = "Option::is_none")]
71    pub error: Option<AlienError>,
72}
73
74/// Information about a deployed resource
75#[derive(Debug, Clone, Serialize, Deserialize)]
76#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
77#[serde(rename_all = "camelCase")]
78pub struct DevResourceInfo {
79    /// Resource URL (e.g., http://localhost:8080)
80    pub url: String,
81    /// Resource type ("function" | "container")
82    #[serde(skip_serializing_if = "Option::is_none")]
83    pub resource_type: Option<String>,
84}