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:
@@ -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<PathBuf>) -> Result<Self> {
|
||||
let path = path.into();
|
||||
|
||||
@@ -85,6 +85,7 @@ impl AgentRegistry {
|
||||
system_prompt: config.system_prompt.clone(),
|
||||
temperature: config.temperature,
|
||||
max_tokens: config.max_tokens,
|
||||
user_profile: None,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -171,6 +171,9 @@ pub struct AgentInfo {
|
||||
pub system_prompt: Option<String>,
|
||||
pub temperature: Option<f32>,
|
||||
pub max_tokens: Option<u32>,
|
||||
/// UserProfile from zclaw-memory UserProfileStore (populated on-demand by agent_get)
|
||||
#[serde(default)]
|
||||
pub user_profile: Option<serde_json::Value>,
|
||||
}
|
||||
|
||||
impl From<AgentConfig> for AgentInfo {
|
||||
@@ -189,6 +192,7 @@ impl From<AgentConfig> 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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -33,6 +33,7 @@ export interface AgentInfo {
|
||||
systemPrompt?: string;
|
||||
temperature?: number;
|
||||
maxTokens?: number;
|
||||
userProfile?: Record<string, unknown>;
|
||||
}
|
||||
|
||||
export interface CreateAgentRequest {
|
||||
|
||||
Reference in New Issue
Block a user