Files
Agent-Tools/apps/desktop/src-tauri/src/lib.rs
T
总工 a2fd5e369b Wave 2.1: 返工黑屏/安装进度/官方配置三层/文档深度/真机列表
老板实测 5 条修复:DiagTab Hooks 黑屏、安装三阶段进度、配置按官方字段三层分组、FR-09 中文文档、detectCliAll 接入列表页。
2026-08-25 11:57:10 +08:00

64 lines
2.2 KiB
Rust
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
mod commands;
use std::path::PathBuf;
use std::sync::Arc;
use tauri::Manager;
use agentdock_core::Engine;
use agentdock_secrets::KeyringSecretStore;
/// 解析适配器目录。
/// 优先级:环境变量 AGENTDOCK_ADAPTERS_DIR > CWD 相对路径(tauri dev 时 CWD=apps/desktop
/// > CARGO_MANIFEST_DIR 相对路径(仓库根)。
fn adapters_dir() -> PathBuf {
if let Ok(dir) = std::env::var("AGENTDOCK_ADAPTERS_DIR") {
return PathBuf::from(dir);
}
let cwd = std::env::current_dir().unwrap_or_default();
let cargo_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
let candidates = [
cwd.join("../../adapters"),
cargo_dir.join("../../../adapters"),
];
for c in candidates {
if c.join("catalog.yaml").exists() {
return c;
}
}
cargo_dir.join("../../../adapters")
}
#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
tauri::Builder::default()
.setup(|app| {
// 自测标记:`tauri dev` 启动后日志出现该行即代表壳已就绪
println!("[agentdock] window-ready");
// Wave 0:初始化 SQLite 空库(架构 §2 状态存储层)
let _ = agentdock_store::Store::open_default();
// Wave 2:初始化编排引擎(适配器目录 + 系统密钥库)
let secrets: Arc<dyn agentdock_secrets::SecretStore> = Arc::new(KeyringSecretStore::new());
let engine = Engine::new(adapters_dir(), secrets);
app.manage(engine);
Ok(())
})
.invoke_handler(tauri::generate_handler![
commands::env::detect_env,
commands::catalog::list_catalog,
commands::cli::detect_cli,
commands::cli::detect_cli_all,
commands::cli::get_adapter,
commands::cli::preview_action,
commands::cli::run_action,
commands::cli::read_config,
commands::cli::write_config,
commands::cli::verify_config,
commands::cli::auth_status,
commands::cli::diagnose,
])
.run(tauri::generate_context!())
.expect("error while running tauri application");
}