Wave 2.2: 流式安装输出、软件内授权四模式、本机环境一键装与总览缓存
EOF Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
use agentdock_adapter::{AdapterAction, DryRunPlan};
|
||||
use agentdock_core::{ActionEvent, ActionOpts, AuthStatus, ConfigFormState, ConfigVerifyResult, DetectResult, Engine, WriteResult};
|
||||
use agentdock_core::{ActionEvent, ActionOpts, AuthFlowEvent, AuthStatus, ConfigFormState, ConfigVerifyResult, DetectResult, Engine, WriteResult};
|
||||
use agentdock_diag::DiagnosticReport;
|
||||
use serde_json::json;
|
||||
use tauri::Emitter;
|
||||
@@ -125,9 +125,44 @@ pub fn auth_status(id: String, state: tauri::State<'_, Engine>) -> Result<AuthSt
|
||||
state.auth_status(&id).map_err(|e| e.to_string())
|
||||
}
|
||||
|
||||
/// 软件内授权(authorize):按官方授权方式运行登录命令,事件经 `cli-auth-event` 流式回传。
|
||||
#[tauri::command(rename = "authorize")]
|
||||
pub fn authorize(
|
||||
app: tauri::AppHandle,
|
||||
id: String,
|
||||
mode: String,
|
||||
state: tauri::State<'_, Engine>,
|
||||
) -> Result<(), String> {
|
||||
let engine = state.inner().clone();
|
||||
std::thread::spawn(move || {
|
||||
let cli_id = id.clone();
|
||||
let m = mode.clone();
|
||||
let result = engine.authorize_stream(&id, &mode, |ev| {
|
||||
let _ = app.emit("cli-auth-event", &ev);
|
||||
});
|
||||
if let Err(e) = result {
|
||||
let _ = app.emit("cli-auth-event", AuthFlowEvent::error(&cli_id, &m, e.to_string()));
|
||||
}
|
||||
});
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// 取消正在进行的授权流程。
|
||||
#[tauri::command(rename = "cancelAuthorize")]
|
||||
pub fn cancel_authorize(id: String, mode: String, state: tauri::State<'_, Engine>) {
|
||||
state.cancel_authorize(&id, &mode);
|
||||
}
|
||||
|
||||
/// 诊断(diagnose):内部实时取本机环境快照。
|
||||
#[tauri::command(rename = "diagnose")]
|
||||
pub fn diagnose(id: String, state: tauri::State<'_, Engine>) -> Result<DiagnosticReport, String> {
|
||||
let env = agentdock_platform::detect::detect_env();
|
||||
state.diagnose(&id, &env).map_err(|e| e.to_string())
|
||||
}
|
||||
|
||||
/// 批量诊断全部已装工具(总览「立即诊断」入口用),内部实时取本机环境快照。
|
||||
#[tauri::command(rename = "diagnoseAll")]
|
||||
pub fn diagnose_all(state: tauri::State<'_, Engine>) -> Result<Vec<DiagnosticReport>, String> {
|
||||
let env = agentdock_platform::detect::detect_env();
|
||||
state.diagnose_all(&env).map_err(|e| e.to_string())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user