1pub mod cli;
7pub mod config;
8pub mod engine;
9pub mod http;
10pub mod runtime;
11pub mod service;
12pub mod sys;
13pub mod telemetry;
14#[doc(hidden)]
15pub mod test_support;
16pub mod types;
17#[cfg(feature = "ui")]
18pub mod ui;
19pub mod update;
20
21pub const AGENT_VERSION: &str = env!("CARGO_PKG_VERSION");
22
23pub const RELEASE_NAME: &str = concat!(env!("CARGO_PKG_NAME"), "@", env!("CARGO_PKG_VERSION"));
28
29pub async fn run_cli(args: cli::Cli) -> anyhow::Result<()> {
32 match args.command {
33 cli::Command::Run => runtime::run(args.config.as_deref()).await,
34 cli::Command::Register {
35 bootstrap_token,
36 api_base_url,
37 } => runtime::register(args.config.as_deref(), bootstrap_token, api_base_url).await,
38 cli::Command::Status => runtime::status(args.config.as_deref()).await,
39 cli::Command::InstallService => service::install(args.config.as_deref()),
40 cli::Command::UninstallService => service::uninstall(),
41 cli::Command::Enable => runtime::set_enabled(args.config.as_deref(), true),
42 cli::Command::Disable => runtime::set_enabled(args.config.as_deref(), false),
43 cli::Command::SetThreshold { gb } => runtime::set_threshold(args.config.as_deref(), gb),
44 cli::Command::Config => runtime::show_config(args.config.as_deref()),
45 cli::Command::CheckUpdate => runtime::check_update(args.config.as_deref()).await,
46 cli::Command::Ui => run_ui(args.config.as_deref()).await,
47 }
48}
49
50#[cfg(feature = "ui")]
51async fn run_ui(config_path: Option<&str>) -> anyhow::Result<()> {
52 ui::run(config_path)
53}
54
55#[cfg(not(feature = "ui"))]
56async fn run_ui(_config_path: Option<&str>) -> anyhow::Result<()> {
57 anyhow::bail!(
58 "this build of studio-worker was compiled without the `ui` cargo feature.\n\
59 Reinstall with `cargo install studio-worker --features ui` (or use the \
60 desktop installer from the releases page) to enable the native UI."
61 )
62}