feat(intelligence): complete Phase 2-3 migration to Rust
Phase 2 - Core Engines: - Heartbeat Engine: Periodic proactive checks with quiet hours support - Context Compactor: Token estimation and message summarization - CJK character handling (1.5 tokens per char) - Rule-based summary generation Phase 3 - Advanced Features: - Reflection Engine: Pattern analysis and improvement suggestions - Agent Identity: SOUL.md/AGENTS.md/USER.md management - Proposal-based changes (requires user approval) - Snapshot history for rollback All modules include: - Tauri commands for frontend integration - Unit tests - Re-exported types via mod.rs Reference: docs/plans/INTELLIGENCE-LAYER-MIGRATION.md Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -21,6 +21,9 @@ mod secure_storage;
|
||||
// Memory commands for persistent storage
|
||||
mod memory_commands;
|
||||
|
||||
// Intelligence Layer (migrated from frontend lib/)
|
||||
mod intelligence;
|
||||
|
||||
use serde::Serialize;
|
||||
use serde_json::{json, Value};
|
||||
use std::fs;
|
||||
@@ -1300,10 +1303,18 @@ pub fn run() {
|
||||
// Initialize memory store state
|
||||
let memory_state: memory_commands::MemoryStoreState = std::sync::Arc::new(tokio::sync::Mutex::new(None));
|
||||
|
||||
// Initialize intelligence layer state
|
||||
let heartbeat_state: intelligence::HeartbeatEngineState = std::sync::Arc::new(tokio::sync::Mutex::new(std::collections::HashMap::new()));
|
||||
let reflection_state: intelligence::ReflectionEngineState = std::sync::Arc::new(tokio::sync::Mutex::new(intelligence::ReflectionEngine::new(None)));
|
||||
let identity_state: intelligence::IdentityManagerState = std::sync::Arc::new(tokio::sync::Mutex::new(intelligence::AgentIdentityManager::new()));
|
||||
|
||||
tauri::Builder::default()
|
||||
.plugin(tauri_plugin_opener::init())
|
||||
.manage(browser_state)
|
||||
.manage(memory_state)
|
||||
.manage(heartbeat_state)
|
||||
.manage(reflection_state)
|
||||
.manage(identity_state)
|
||||
.invoke_handler(tauri::generate_handler![
|
||||
// OpenFang commands (new naming)
|
||||
openfang_status,
|
||||
@@ -1390,7 +1401,43 @@ pub fn run() {
|
||||
memory_commands::memory_stats,
|
||||
memory_commands::memory_export,
|
||||
memory_commands::memory_import,
|
||||
memory_commands::memory_db_path
|
||||
memory_commands::memory_db_path,
|
||||
// Intelligence Layer commands (Phase 2-3)
|
||||
// Heartbeat Engine
|
||||
intelligence::heartbeat::heartbeat_init,
|
||||
intelligence::heartbeat::heartbeat_start,
|
||||
intelligence::heartbeat::heartbeat_stop,
|
||||
intelligence::heartbeat::heartbeat_tick,
|
||||
intelligence::heartbeat::heartbeat_get_config,
|
||||
intelligence::heartbeat::heartbeat_update_config,
|
||||
intelligence::heartbeat::heartbeat_get_history,
|
||||
// Context Compactor
|
||||
intelligence::compactor::compactor_estimate_tokens,
|
||||
intelligence::compactor::compactor_estimate_messages_tokens,
|
||||
intelligence::compactor::compactor_check_threshold,
|
||||
intelligence::compactor::compactor_compact,
|
||||
// Reflection Engine
|
||||
intelligence::reflection::reflection_init,
|
||||
intelligence::reflection::reflection_record_conversation,
|
||||
intelligence::reflection::reflection_should_reflect,
|
||||
intelligence::reflection::reflection_reflect,
|
||||
intelligence::reflection::reflection_get_history,
|
||||
intelligence::reflection::reflection_get_state,
|
||||
// Agent Identity Manager
|
||||
intelligence::identity::identity_get,
|
||||
intelligence::identity::identity_get_file,
|
||||
intelligence::identity::identity_build_prompt,
|
||||
intelligence::identity::identity_update_user_profile,
|
||||
intelligence::identity::identity_append_user_profile,
|
||||
intelligence::identity::identity_propose_change,
|
||||
intelligence::identity::identity_approve_proposal,
|
||||
intelligence::identity::identity_reject_proposal,
|
||||
intelligence::identity::identity_get_pending_proposals,
|
||||
intelligence::identity::identity_update_file,
|
||||
intelligence::identity::identity_get_snapshots,
|
||||
intelligence::identity::identity_restore_snapshot,
|
||||
intelligence::identity::identity_list_agents,
|
||||
intelligence::identity::identity_delete_agent
|
||||
])
|
||||
.run(tauri::generate_context!())
|
||||
.expect("error while running tauri application");
|
||||
|
||||
Reference in New Issue
Block a user