Skip to main content

life_cli/
cli.rs

1//! CLI argument definitions for `life`.
2
3use clap::{Parser, Subcommand};
4
5use crate::relay::RelayCommand;
6
7#[derive(Parser)]
8#[command(
9    name = "life",
10    about = "Agent Operating System — deploy, configure, and manage agents",
11    version,
12    propagate_version = true
13)]
14pub struct Cli {
15    #[command(subcommand)]
16    pub command: Option<Command>,
17}
18
19#[derive(Subcommand)]
20pub enum Command {
21    /// Interactive setup wizard — configure providers, keys, and modules.
22    Setup,
23
24    /// Deploy an agent to a cloud target.
25    Deploy(DeployArgs),
26
27    /// Check the status of a deployed agent.
28    Status(StatusArgs),
29
30    /// List all deployed agents.
31    List(ListArgs),
32
33    /// Tear down a deployed agent and all its services.
34    Destroy(DestroyArgs),
35
36    /// Manage agent templates.
37    Templates(TemplateArgs),
38
39    /// Show cost tracking for a deployed agent.
40    Cost(CostArgs),
41
42    /// Stream logs from a deployed agent's services.
43    Logs(LogsArgs),
44
45    /// Scale agent services based on Autonomic economic modes.
46    Scale(ScaleArgs),
47
48    /// Manage the relay daemon for remote agent sessions.
49    Relay {
50        #[command(subcommand)]
51        command: RelayCommand,
52    },
53}
54
55#[derive(clap::Args)]
56pub struct DeployArgs {
57    /// Agent template name (e.g., coding-agent, data-agent, support-agent).
58    #[arg(long, short)]
59    pub agent: String,
60
61    /// Deployment target (railway, flyio, ecs).
62    #[arg(long, short, default_value = "railway")]
63    pub target: String,
64
65    /// LLM provider for the agent runtime (anthropic, openai, mock).
66    #[arg(long, default_value = "anthropic")]
67    pub provider: String,
68
69    /// Custom project name override (defaults to life-{agent}).
70    #[arg(long)]
71    pub project_name: Option<String>,
72
73    /// Path to custom template file (overrides built-in templates).
74    #[arg(long)]
75    pub template_path: Option<String>,
76
77    /// Skip health check polling after deployment.
78    #[arg(long)]
79    pub no_wait: bool,
80
81    /// Environment variables to pass to all services (KEY=VALUE).
82    #[arg(long, short = 'e')]
83    pub env: Vec<String>,
84}
85
86#[derive(clap::Args)]
87pub struct StatusArgs {
88    /// Agent name or Railway project ID.
89    #[arg(long, short)]
90    pub agent: String,
91
92    /// Deployment target.
93    #[arg(long, short, default_value = "railway")]
94    pub target: String,
95
96    /// Output format (table, json).
97    #[arg(long, default_value = "table")]
98    pub format: String,
99}
100
101#[derive(clap::Args)]
102pub struct ListArgs {
103    /// Output format (table, json).
104    #[arg(long, default_value = "table")]
105    pub format: String,
106}
107
108#[derive(clap::Args)]
109pub struct DestroyArgs {
110    /// Agent name or Railway project ID.
111    #[arg(long, short)]
112    pub agent: String,
113
114    /// Deployment target.
115    #[arg(long, short, default_value = "railway")]
116    pub target: String,
117
118    /// Skip confirmation prompt.
119    #[arg(long, short = 'y')]
120    pub yes: bool,
121}
122
123#[derive(clap::Args)]
124pub struct TemplateArgs {
125    #[command(subcommand)]
126    pub command: TemplateCommand,
127}
128
129#[derive(Subcommand)]
130pub enum TemplateCommand {
131    /// List available agent templates.
132    List,
133    /// Show details of a specific template.
134    Show {
135        /// Template name.
136        name: String,
137    },
138}
139
140#[derive(clap::Args)]
141pub struct CostArgs {
142    /// Agent name.
143    #[arg(long, short)]
144    pub agent: String,
145
146    /// Deployment target.
147    #[arg(long, short, default_value = "railway")]
148    pub target: String,
149
150    /// Time window for cost data (1h, 24h, 7d, 30d).
151    #[arg(long, default_value = "24h")]
152    pub window: String,
153
154    /// Output format (table, json).
155    #[arg(long, default_value = "table")]
156    pub format: String,
157}
158
159#[derive(clap::Args)]
160pub struct LogsArgs {
161    /// Agent name.
162    #[arg(long, short)]
163    pub agent: String,
164
165    /// Specific service to stream logs from (streams all if omitted).
166    #[arg(long, short)]
167    pub service: Option<String>,
168
169    /// Deployment target.
170    #[arg(long, short, default_value = "railway")]
171    pub target: String,
172
173    /// Number of recent log lines to show (0 = stream live only).
174    #[arg(long, short, default_value = "50")]
175    pub lines: u32,
176}
177
178#[derive(clap::Args)]
179pub struct ScaleArgs {
180    /// Agent name.
181    #[arg(long, short)]
182    pub agent: String,
183
184    /// Service to scale (scales arcan by default).
185    #[arg(long, short, default_value = "arcan")]
186    pub service: String,
187
188    /// Number of replicas (overrides auto-scaling).
189    #[arg(long, short)]
190    pub replicas: Option<u32>,
191
192    /// Use Autonomic economic mode to determine scale.
193    /// Queries the Autonomic service and scales based on its recommendation.
194    #[arg(long)]
195    pub auto: bool,
196
197    /// Deployment target.
198    #[arg(long, short, default_value = "railway")]
199    pub target: String,
200}