chore: 提交所有工作进度 — SaaS 后端增强、Admin UI、桌面端集成

包含大量 SaaS 平台改进、Admin 管理后台更新、桌面端集成完善、
文档同步、测试文件重构等内容。为 QA 测试准备干净工作树。
This commit is contained in:
iven
2026-03-29 10:46:26 +08:00
parent 9a5fad2b59
commit 5fdf96c3f5
268 changed files with 22011 additions and 3886 deletions

View File

@@ -5,7 +5,7 @@
//!
//! Architecture: kernel_commands.rs → intelligence_hooks → intelligence modules → Viking/Kernel
use tracing::debug;
use tracing::{debug, warn};
use std::sync::Arc;
@@ -26,13 +26,28 @@ pub async fn pre_conversation_hook(
identity_state: &IdentityManagerState,
) -> Result<String, String> {
// Step 1: Build memory context from Viking storage
let memory_context = build_memory_context(agent_id, user_message).await
.unwrap_or_default();
let memory_context = match build_memory_context(agent_id, user_message).await {
Ok(ctx) => ctx,
Err(e) => {
warn!(
"[intelligence_hooks] Failed to build memory context for agent {}: {}",
agent_id, e
);
String::new()
}
};
// Step 2: Build identity-enhanced system prompt
let enhanced_prompt = build_identity_prompt(agent_id, &memory_context, identity_state)
.await
.unwrap_or_default();
let enhanced_prompt = match build_identity_prompt(agent_id, &memory_context, identity_state).await {
Ok(prompt) => prompt,
Err(e) => {
warn!(
"[intelligence_hooks] Failed to build identity prompt for agent {}: {}",
agent_id, e
);
String::new()
}
};
Ok(enhanced_prompt)
}
@@ -76,8 +91,16 @@ pub async fn post_conversation_hook(
);
// Query actual memories from VikingStorage for reflection analysis
let memories = query_memories_for_reflection(agent_id).await
.unwrap_or_default();
let memories = match query_memories_for_reflection(agent_id).await {
Ok(m) => m,
Err(e) => {
warn!(
"[intelligence_hooks] Failed to query memories for reflection (agent {}): {}",
agent_id, e
);
Vec::new()
}
};
debug!(
"[intelligence_hooks] Fetched {} memories for reflection",
@@ -133,9 +156,10 @@ async fn build_memory_context(
&entry.content
};
// Truncate long entries
let truncated = if text.len() > 100 {
format!("{}...", &text[..100])
// Truncate long entries (char-safe for CJK text)
let truncated = if text.chars().count() > 100 {
let truncated: String = text.chars().take(100).collect();
format!("{}...", truncated)
} else {
text.to_string()
};