π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
use tauri::{Manager, RunEvent, async_runtime};
mod commands;
mod logging;
#[path = "../../../../crates/ensu/src/platform.rs"]
mod platform;
#[cfg(any(windows, target_os = "linux"))]
mod single_instance;
fn main() {
logging::install_panic_hook();
logging::log("App", "starting Tauri backend");
let builder = tauri::Builder::default();
#[cfg(any(windows, target_os = "linux"))]
let builder = builder.plugin(single_instance::plugin());
let app = builder
.plugin(tauri_plugin_dialog::init())
.plugin(tauri_plugin_fs::init())
.plugin(tauri_plugin_opener::init())
.plugin(tauri_plugin_process::init())
.plugin(tauri_plugin_updater::Builder::new().build())
.manage(commands::llm::State::default())
.manage(commands::chat_db::ChatDbState::default())
.manage(commands::knowledge::State::default())
.manage(commands::conversation::State::default())
.manage(commands::followup::State::default())
.setup(|app| {
logging::init_logging(app.handle());
logging::log("App", "setup started");
app.manage(commands::llm::ModelDownloadState::new(
app.path().app_data_dir()?,
));
let notes_available = match commands::notes::State::new(app.path().app_data_dir()?) {
Ok(state) => {
app.manage(state);
true
}
Err(error) => {
logging::log(
"Notes",
format!(
"initialization failed; Notes disabled error={}",
error.message
),
);
false
}
};
if let Some(window) = app.get_webview_window("main")
&& let Err(err) = window.show()
{
logging::log("App", format!("failed to show main window error={err}"));
return Err(Box::new(err));
}
if notes_available {
let notes_app = app.handle().clone();
async_runtime::spawn(async move {
commands::notes::initialize_for_app(notes_app).await;
});
}
logging::log("App", "setup complete");
Ok(())
})
.invoke_handler(tauri::generate_handler![
commands::crypto::chat_crypto_generate_key,
commands::crypto::chat_crypto_encrypt_payload,
commands::crypto::chat_crypto_decrypt_payload,
commands::crypto::chat_crypto_encrypt_field,
commands::crypto::chat_crypto_decrypt_field,
commands::crypto::chat_crypto_encrypt_attachment,
commands::crypto::chat_crypto_decrypt_attachment,
commands::secure_storage::secure_storage_get,
commands::secure_storage::secure_storage_set,
commands::secure_storage::secure_storage_delete,
commands::chat_db::chat_db_list_sessions,
commands::chat_db::chat_db_list_sessions_with_preview,
commands::chat_db::chat_db_get_session,
commands::chat_db::chat_db_create_session,
commands::chat_db::chat_db_update_session_title,
commands::chat_db::chat_db_delete_session,
commands::chat_db::chat_db_get_messages,
commands::chat_db::chat_db_insert_message,
commands::chat_db::chat_db_upsert_session,
commands::chat_db::chat_db_insert_message_with_uuid,
commands::chat_db::chat_db_compress_attachment_image_file,
commands::chat_db::chat_db_open,
commands::chat_db::chat_db_has_existing_store,
commands::llm::llm_init_backend,
commands::llm::llm_load_model,
commands::llm::llm_create_context,
commands::llm::llm_free_context,
commands::llm::llm_free_model,
commands::llm::llm_prewarm_multimodal_context,
commands::llm::llm_generate_chat_stream,
commands::conversation::conversation_prepare,
commands::followup::conversation_resolve_followup,
commands::llm::llm_cancel,
commands::llm::llm_retrieval_epoch,
commands::llm::llm_model_state_epoch,
commands::system::system_info,
commands::config::desktop_model_policy,
commands::llm::llm_model_status,
commands::llm::llm_model_download_size,
commands::llm::llm_migrate_models,
commands::llm::llm_download_model,
commands::llm::llm_cancel_model_download,
commands::knowledge::knowledge_catalog,
commands::knowledge::knowledge_download_pack,
commands::knowledge::knowledge_cancel_pack_download,
commands::knowledge::knowledge_retrieve,
commands::notes::notes_list_collections,
commands::notes::notes_add_collection,
commands::notes::notes_remove_collection,
commands::notes::notes_index_collection,
commands::notes::notes_open_document,
])
.build(tauri::generate_context!())
.unwrap_or_else(|err| {
logging::log("App", format!("tauri build failed error={err}"));
panic!("error while building tauri application: {err}");
});
app.run(|app_handle, event| {
if matches!(event, RunEvent::ExitRequested { .. } | RunEvent::Exit) {
commands::cleanup_for_exit(app_handle);
}
});
}