agent-hub-runtime 0.6.0

AgentHub desktop and companion CLI runtime for Tauri applications
Documentation
use crate::core::{
    error::AppError,
    herdr::{
        hc::{install, Core},
        tools::{HerdrInstallation, HerdrUpdate},
    },
    skill_store::SkillStore,
};
use std::sync::Arc;
use tauri::State;

#[tauri::command]
pub async fn herdr_detect() -> Result<Option<HerdrInstallation>, AppError> {
    tauri::async_runtime::spawn_blocking(move || {
        Core::discover()
            .map(|core| core.installation())
            .transpose()
            .map_err(AppError::io)
    })
    .await?
}

#[tauri::command]
pub async fn herdr_install(
    store: State<'_, Arc<SkillStore>>,
) -> Result<HerdrInstallation, AppError> {
    let store = store.inner().clone();
    tauri::async_runtime::spawn_blocking(move || {
        install::install(store.proxy_url().as_deref(), false).map_err(AppError::io)
    })
    .await?
}

#[tauri::command]
pub async fn herdr_check_update(
    store: State<'_, Arc<SkillStore>>,
) -> Result<HerdrUpdate, AppError> {
    let store = store.inner().clone();
    tauri::async_runtime::spawn_blocking(move || {
        install::check_update(store.proxy_url().as_deref()).map_err(AppError::network)
    })
    .await?
}

#[tauri::command]
pub async fn herdr_update(
    store: State<'_, Arc<SkillStore>>,
) -> Result<HerdrInstallation, AppError> {
    let store = store.inner().clone();
    tauri::async_runtime::spawn_blocking(move || {
        install::install(store.proxy_url().as_deref(), true).map_err(AppError::io)
    })
    .await?
}