Raw
1 pub mod app_info;
2 pub mod chat;
3 pub mod constants;
4 pub mod events;
5 pub mod setup;
6
7 /// Re-export onde's inference helpers so `crate::inference::*` paths work.
8 pub mod inference {
9 pub use onde::inference::{models, token};
10 }
11
12 use app_info::app_build_version;
13 use chat::{
14 chat_download_progress, chat_list_models, chat_load_model, chat_remove_model,
15 chat_send_message, chat_set_model, chat_unload_model,
16 };
17 use ed_agent::Ed;
18 use ed_agent_tauri::{EdState, TauriSink};
19 use tauri::Manager;
20
21 #[cfg_attr(mobile, tauri::mobile_entry_point)]
22 pub fn run() {
23 tauri::Builder::default()
24 .plugin(
25 tauri_plugin_log::Builder::new()
26 .level(log::LevelFilter::Info)
27 // Quiet the chattiest inference/download dependencies.
28 .level_for("tokenizers", log::LevelFilter::Warn)
29 .level_for("hf_hub", log::LevelFilter::Warn)
30 .level_for("rustls", log::LevelFilter::Warn)
31 .level_for("hyper", log::LevelFilter::Warn)
32 .level_for("candle_core", log::LevelFilter::Warn)
33 .level_for("candle_nn", log::LevelFilter::Warn)
34 .target(tauri_plugin_log::Target::new(
35 tauri_plugin_log::TargetKind::Stdout,
36 ))
37 .build(),
38 )
39 .plugin(tauri_plugin_opener::init())
40 .setup(|app| {
41 // Disable telemetry + redirect the model cache into the shared
42 // App Group container. Must run before any onde / hf-hub code.
43 setup::setup(app)?;
44
45 // Ed owns the engine; it reports status, text deltas and replies
46 // to the webview through `TauriSink`. Created after `setup` so the
47 // pulse switch and cache redirect are in place first.
48 app.manage(EdState::new(Ed::with_sink(TauriSink::new(
49 app.handle().clone(),
50 ))));
51 Ok(())
52 })
53 .invoke_handler(tauri::generate_handler![
54 // Chat commands: fully on-device LLM inference
55 chat_load_model,
56 chat_unload_model,
57 chat_send_message,
58 // Status and history come straight from the SDK. The command macros
59 // need the full path.
60 ed_agent_tauri::chat_get_status,
61 ed_agent_tauri::chat_clear_history,
62 ed_agent_tauri::chat_get_history,
63 chat_list_models,
64 chat_set_model,
65 chat_remove_model,
66 chat_download_progress,
67 // App metadata
68 app_build_version,
69 ])
70 .run(tauri::generate_context!())
71 .expect("error while running tauri application");
72 }