feat(kernel): agent_get 返回值扩展 UserProfile 字段

- AgentInfo 增加 user_profile: Option<Value> (serde default)
- SqliteStorage 增加 pool() getter
- agent_get 命令查询 UserProfileStore 填充 user_profile
- 前端 AgentInfo 类型同步更新
复用已有 UserProfileStore,不新增 Tauri 命令。
This commit is contained in:
iven
2026-04-11 12:51:27 +08:00
parent d974af3042
commit d50d1ab882
5 changed files with 25 additions and 2 deletions

View File

@@ -163,7 +163,7 @@ pub async fn agent_list(
Ok(kernel.list_agents())
}
/// Get agent info
/// Get agent info (with optional UserProfile from memory store)
// @connected
#[tauri::command]
pub async fn agent_get(
@@ -180,7 +180,19 @@ pub async fn agent_get(
let id: AgentId = agent_id.parse()
.map_err(|_| "Invalid agent ID format".to_string())?;
Ok(kernel.get_agent(&id))
let mut info = kernel.get_agent(&id);
// Extend with UserProfile if available
if let Some(ref mut agent_info) = info {
if let Ok(storage) = crate::viking_commands::get_storage().await {
let profile_store = zclaw_memory::UserProfileStore::new(storage.pool().clone());
if let Ok(Some(profile)) = profile_store.get(&agent_id).await {
agent_info.user_profile = Some(serde_json::to_value(profile).unwrap_or_default());
}
}
}
Ok(info)
}
/// Delete an agent