Skip to main content

agent_hub_runtime/
lib.rs

1//! Shared AgentHub application library for the desktop host and CLI.
2
3mod desktop;
4mod smoke;
5mod window_layout;
6
7#[cfg(feature = "companion-cli")]
8#[path = "cli/agent-hub-cli.rs"]
9pub mod cli;
10
11pub mod product;
12
13pub mod commands;
14pub mod core;
15
16/// Read a resource from the pinned default catalog at compile time.
17macro_rules! default_content {
18    ($path:literal) => {
19        include_str!(concat!(env!("AGENT_HUB_DEFAULT_CONTENT_DIR"), "/", $path))
20    };
21}
22pub(crate) use default_content;
23
24pub use desktop::builder;
25pub use desktop::lifecycle::{quit_app, restart_app, QUITTING};
26pub use desktop::tray::{set_tray_icon_enabled, ProductTrayIcons};
27pub use smoke::run_package_smoke;
28
29pub(crate) use desktop::tray::{refresh_tray_menu, schedule_tray_refresh};
30
31/// Initialize the product identity before constructing a custom desktop host.
32pub fn builder_for_product(
33    identity: product::Identity,
34) -> anyhow::Result<tauri::Builder<tauri::Wry>> {
35    product::initialize(identity)?;
36    builder()
37}
38
39/// Run a desktop host using its configuration and bundled frontend assets.
40///
41/// Generate the Context in the executable crate. Hosts that add plugins can
42/// instead call [`builder`] and then run the configured builder themselves.
43pub fn run(context: tauri::Context<tauri::Wry>) {
44    builder()
45        .expect("Failed to initialize app state")
46        .run(context)
47        .expect("error while running tauri application");
48}