From d50d1ab882b8c96dd5c744a4c45fa7e10441a088 Mon Sep 17 00:00:00 2001 From: iven Date: Sat, 11 Apr 2026 12:51:27 +0800 Subject: [PATCH] =?UTF-8?q?feat(kernel):=20agent=5Fget=20=E8=BF=94?= =?UTF-8?q?=E5=9B=9E=E5=80=BC=E6=89=A9=E5=B1=95=20UserProfile=20=E5=AD=97?= =?UTF-8?q?=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - AgentInfo 增加 user_profile: Option (serde default) - SqliteStorage 增加 pool() getter - agent_get 命令查询 UserProfileStore 填充 user_profile - 前端 AgentInfo 类型同步更新 复用已有 UserProfileStore,不新增 Tauri 命令。 --- crates/zclaw-growth/src/storage/sqlite.rs | 5 +++++ crates/zclaw-kernel/src/registry.rs | 1 + crates/zclaw-types/src/agent.rs | 4 ++++ desktop/src-tauri/src/kernel_commands/agent.rs | 16 ++++++++++++++-- desktop/src/lib/kernel-types.ts | 1 + 5 files changed, 25 insertions(+), 2 deletions(-) diff --git a/crates/zclaw-growth/src/storage/sqlite.rs b/crates/zclaw-growth/src/storage/sqlite.rs index 3c2b723..15db689 100644 --- a/crates/zclaw-growth/src/storage/sqlite.rs +++ b/crates/zclaw-growth/src/storage/sqlite.rs @@ -41,6 +41,11 @@ pub(crate) struct MemoryRow { } impl SqliteStorage { + /// Get a reference to the underlying connection pool + pub fn pool(&self) -> &SqlitePool { + &self.pool + } + /// Create a new SQLite storage at the given path pub async fn new(path: impl Into) -> Result { let path = path.into(); diff --git a/crates/zclaw-kernel/src/registry.rs b/crates/zclaw-kernel/src/registry.rs index f696a39..69fc9fd 100644 --- a/crates/zclaw-kernel/src/registry.rs +++ b/crates/zclaw-kernel/src/registry.rs @@ -85,6 +85,7 @@ impl AgentRegistry { system_prompt: config.system_prompt.clone(), temperature: config.temperature, max_tokens: config.max_tokens, + user_profile: None, }) } diff --git a/crates/zclaw-types/src/agent.rs b/crates/zclaw-types/src/agent.rs index ed84fc8..5763a78 100644 --- a/crates/zclaw-types/src/agent.rs +++ b/crates/zclaw-types/src/agent.rs @@ -171,6 +171,9 @@ pub struct AgentInfo { pub system_prompt: Option, pub temperature: Option, pub max_tokens: Option, + /// UserProfile from zclaw-memory UserProfileStore (populated on-demand by agent_get) + #[serde(default)] + pub user_profile: Option, } impl From for AgentInfo { @@ -189,6 +192,7 @@ impl From for AgentInfo { system_prompt: config.system_prompt, temperature: config.temperature, max_tokens: config.max_tokens, + user_profile: None, // Populated on-demand by agent_get command } } } diff --git a/desktop/src-tauri/src/kernel_commands/agent.rs b/desktop/src-tauri/src/kernel_commands/agent.rs index abe3675..7cdc8a2 100644 --- a/desktop/src-tauri/src/kernel_commands/agent.rs +++ b/desktop/src-tauri/src/kernel_commands/agent.rs @@ -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 diff --git a/desktop/src/lib/kernel-types.ts b/desktop/src/lib/kernel-types.ts index 58fef8b..a8998af 100644 --- a/desktop/src/lib/kernel-types.ts +++ b/desktop/src/lib/kernel-types.ts @@ -33,6 +33,7 @@ export interface AgentInfo { systemPrompt?: string; temperature?: number; maxTokens?: number; + userProfile?: Record; } export interface CreateAgentRequest {