Files
zclaw_openfang/desktop/src-tauri/src/intelligence/mod.rs
iven 215c079d29
Some checks failed
CI / Lint & TypeCheck (push) Has been cancelled
CI / Unit Tests (push) Has been cancelled
CI / Build Frontend (push) Has been cancelled
CI / Rust Check (push) Has been cancelled
CI / Security Scan (push) Has been cancelled
CI / E2E Tests (push) Has been cancelled
fix(intelligence): Heartbeat 统一健康系统 — 6处断链修复 + 健康面板 + SaaS自动恢复
Rust 后端 (heartbeat.rs):
- 告警实时推送: OnceLock<AppHandle> + Tauri emit heartbeat:alert
- 动态间隔: tokio::select! + Notify 替代不可变 interval
- Config 持久化: update_config 写入 VikingStorage
- heartbeat_init 从 VikingStorage 恢复 config
- 移除 dead code (subscribe, HeartbeatCheckFn)
- Memory stats fallback 分层处理

新增 health_snapshot.rs:
- HealthSnapshot Tauri 命令 — 按需查询引擎/记忆状态
- 注册到 lib.rs invoke_handler

前端修复:
- HeartbeatConfig handleSave 同步到 Rust 后端
- App.tsx 读 localStorage 持久化配置 + heartbeat:alert 监听 + toast
- saasStore 降级后指数退避探测恢复 + saas-recovered 事件
- 新增 HealthPanel.tsx 只读健康面板 (4卡片 + 告警列表)
- SettingsLayout 添加 health 导航入口

清理:
- 删除 intelligence-client/ 目录版 (9文件 -1640行, 单文件版是活跃代码)
2026-04-15 23:19:24 +08:00

67 lines
2.2 KiB
Rust

//! Intelligence Layer - Migrated from frontend lib/
//!
//! This module contains the intelligence components that were previously
//! implemented in TypeScript/JavaScript in the frontend.
//!
//! ## Modules
//!
//! - `heartbeat` - Periodic proactive checks with quiet hours support
//! - `compactor` - Context compaction for infinite-length conversations
//! - `reflection` - Agent self-improvement through conversation analysis
//! - `identity` - Agent identity file management (SOUL.md, AGENTS.md, USER.md)
//!
//! ## Migration Status
//!
//! | Component | Status | Notes |
//! |-----------|--------|-------|
//! | Heartbeat Engine | ✅ Active | Integrated via intelligence_hooks |
//! | Context Compactor | ✅ Active | Integrated in kernel AgentLoop |
//! | Reflection Engine | ✅ Active | Integrated via intelligence_hooks |
//! | Agent Identity | ✅ Active | Integrated via intelligence_hooks |
//!
//! Removed (dead code, never called from frontend):
//! - `pattern_detector` - 2026-03-26
//! - `recommender` - 2026-03-26 (was only used by mesh)
//! - `mesh` - 2026-03-26
//! - `trigger_evaluator` - 2026-03-26
//! - `persona_evolver` - 2026-03-26
// Hermes 管线子模块:部分函数由 Tauri 命令或中间件 hooks 按需调用,
// 编译期无法检测到跨 crate 引用,统一抑制 dead_code 警告。
#![allow(dead_code)]
pub mod heartbeat;
pub mod compactor;
pub mod reflection;
pub mod identity;
pub mod validation;
pub mod extraction_adapter;
pub mod pain_aggregator;
pub mod solution_generator;
pub mod personality_detector;
pub mod pain_storage;
pub mod experience;
pub mod triggers;
pub mod user_profiler;
pub mod trajectory_compressor;
pub mod health_snapshot;
// Re-export main types for convenience
pub use heartbeat::HeartbeatEngineState;
pub use reflection::{
ReflectionEngine, ReflectionEngineState,
};
pub use identity::{
AgentIdentityManager, IdentityManagerState,
};
// Suppress dead-code warnings for extraction adapter accessors — they are
// consumed externally via full path (crate::intelligence::extraction_adapter::*).
#[allow(unused_imports)]
use extraction_adapter::{
configure_extraction_driver as _,
is_extraction_driver_configured as _,
get_extraction_driver as _,
TauriExtractionDriver as _,
};