embed

Add an AI agent to a Tauri app

ed-agent-tauri gives your webview commands to chat with Ed, and emits events as the model loads and replies.

cargo add ed-agent ed-agent-tauri

Wire it up

use ed_agent::{Ed, GgufModelConfig};
use ed_agent_tauri::{EdState, TauriSink};
use tauri::{Builder, Manager, State, Wry};

/// Which model to load, and when, is your app's decision.
#[tauri::command]
async fn load_model(ed: State<'_, EdState>) -> Result<(), String> {
    ed.ed()
        .load(GgufModelConfig::qwen25_1_5b(), None, None)
        .await
        .map(|_| ())
        .map_err(|error| error.to_string())
}

/// Call this on your builder, then `.run(tauri::generate_context!())`.
pub fn with_ed(builder: Builder<Wry>) -> Builder<Wry> {
    builder
        .setup(|app| {
            let ed = Ed::with_sink(TauriSink::new(app.handle().clone()));
            app.manage(EdState::new(ed));
            Ok(())
        })
        .invoke_handler(tauri::generate_handler![
            load_model,
            ed_agent_tauri::chat_get_status,
            ed_agent_tauri::chat_get_history,
            ed_agent_tauri::chat_clear_history,
            ed_agent_tauri::chat_send_message,
            ed_agent_tauri::chat_cancel,
        ])
}

From the webview

Call invoke("load_model") once, then invoke("chat_send_message", { message }). Listen for chat_status_changed to show loading state.

This setup is chat only: it rejects tools and denies approvals. For tools, build the agent with Ed::with_agent, or use EdSessions, which sends approval requests to your webview. See docs.rs/ed-agent-tauri.