feat: v0.9.0 — Usage analytics, Communication config, 晴辰云 branding, multi-agent channels, 7 bug fixes

This commit is contained in:
晴天
2026-03-14 07:09:50 +08:00
parent 8bd8b82351
commit 205d349917
28 changed files with 1163 additions and 63 deletions

View File

@@ -25,7 +25,8 @@ pub async fn list_agents() -> Result<Value, String> {
}
let stdout = String::from_utf8_lossy(&output.stdout);
serde_json::from_str(&stdout).map_err(|e| format!("解析 JSON 失败: {e}"))
crate::commands::skills::extract_json_pub(&stdout)
.ok_or_else(|| "解析 JSON 失败: 输出中未找到有效 JSON".to_string())
}
/// 创建新 agent

View File

@@ -564,6 +564,30 @@ pub async fn get_version_info() -> Result<VersionInfo, String> {
})
}
/// 获取 OpenClaw 运行时状态摘要openclaw status --json
/// 包含 runtimeVersion、会话列表含 token 用量、fastMode 等标签)
#[tauri::command]
pub async fn get_status_summary() -> Result<Value, String> {
let output = crate::utils::openclaw_command_async()
.args(["status", "--json"])
.output()
.await;
match output {
Ok(o) if o.status.success() => {
let stdout = String::from_utf8_lossy(&o.stdout);
// CLI 输出可能含非 JSON 行,复用 skills 模块的 extract_json
crate::commands::skills::extract_json_pub(&stdout)
.ok_or_else(|| "解析失败: 输出中未找到有效 JSON".to_string())
}
Ok(o) => {
let stderr = String::from_utf8_lossy(&o.stderr);
Err(format!("openclaw status 失败: {}", stderr.trim()))
}
Err(e) => Err(format!("执行 openclaw 失败: {e}")),
}
}
/// npm 包名映射
fn npm_package_name(source: &str) -> &'static str {
match source {

View File

@@ -45,9 +45,10 @@ pub fn read_log_tail(log_name: String, lines: Option<u32>) -> Result<String, Str
file.seek(SeekFrom::Start(start_pos))
.map_err(|e| format!("Seek 失败: {e}"))?;
let mut buf = String::new();
file.read_to_string(&mut buf)
let mut raw = Vec::new();
file.read_to_end(&mut raw)
.map_err(|e| format!("读取日志失败: {e}"))?;
let buf = String::from_utf8_lossy(&raw).into_owned();
let mut all_lines: Vec<&str> = buf.lines().collect();

View File

@@ -34,7 +34,8 @@ async fn agent_workspace(agent_id: &str) -> Result<PathBuf, String> {
let stdout = String::from_utf8_lossy(&output.stdout);
let agents: serde_json::Value =
serde_json::from_str(&stdout).map_err(|e| format!("解析 JSON 失败: {e}"))?;
crate::commands::skills::extract_json_pub(&stdout)
.ok_or_else(|| "解析 JSON 失败: 输出中未找到有效 JSON".to_string())?;
if let Some(arr) = agents.as_array() {
for a in arr {

View File

@@ -220,6 +220,11 @@ pub async fn skills_clawhub_search(query: String) -> Result<Value, String> {
Ok(Value::Array(items))
}
/// Public wrapper for extract_json, used by config.rs get_status_summary
pub fn extract_json_pub(text: &str) -> Option<Value> {
extract_json(text)
}
/// Extract the first valid JSON object or array from a string that may contain
/// non-JSON lines (Node.js warnings, npm update prompts, etc.)
fn extract_json(text: &str) -> Option<Value> {

View File

@@ -97,6 +97,7 @@ pub fn run() {
config::auto_install_git,
config::configure_git_https,
config::invalidate_path_cache,
config::get_status_summary,
// 设备密钥 + Gateway 握手
device::create_connect_frame,
// 设备配对