mirror of
https://github.com/tinyhumansai/openhuman.git
synced 2026-07-30 23:14:37 +00:00
* Add AI intelligence system with memory, sessions, skills and constitution Implements a client-side AI system inspired by OpenClaw's architecture: Rust backend (src-tauri/src/ai/): - SQLite memory database with FTS5 full-text search (memory_db.rs) - AES-256-GCM encryption with Argon2id key derivation (encryption.rs) - Session JSONL file I/O and memory file management (sessions.rs) - 30 new Tauri commands for memory, encryption, and session operations TypeScript AI modules (src/lib/ai/): - Constitution framework: safety rules, memory principles, action validation - Memory system: markdown chunking, hybrid FTS5+vector search, encryption - Prompt system: modular builder with 7 sections (constitution, identity, crypto-intelligence, memory-recall, skills, tools, context) - Session system: JSONL transcripts, context compaction, memory flush - Skills framework: SKILL.md loader, registry, GitHub installer - LLM providers: pluggable interface with custom and OpenAI implementations - AI tools: memory_search, memory_read, memory_write, web_search Integration: - Redux aiSlice with persisted config - AIProvider in the app provider chain - All data encrypted at rest, zero-knowledge architecture Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * Apply cargo fmt formatting Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * Add unit tests for AI intelligence system Cover constitution (loader, validator), memory (chunker), prompts (system-prompt, sections), providers (embeddings), sessions (types), skills (frontmatter, registry), tools (registry), and Redux aiSlice. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * Enhance AI system with entity management and constitution updates - Introduced EntityManager and EntityQuery classes for managing entity relationships and queries within the AI platform. - Updated constitution loader to fetch the constitution from a public GitHub repository, with fallback to a bundled default. - Enhanced constitution parsing to support new formats and improved error handling. - Updated memory schema to reflect changes in storage management. - Added support for loading skill definitions from TypeScript files, improving skill lifecycle management. This update strengthens the AI system's capabilities in entity management and constitution handling, ensuring better compliance and functionality. --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
63 lines
1.8 KiB
Rust
63 lines
1.8 KiB
Rust
use crate::models::socket::{ConnectionStatus, SocketState};
|
|
use crate::services::socket_service::SOCKET_SERVICE;
|
|
use tauri::AppHandle;
|
|
|
|
/// Request the frontend to connect to the socket server
|
|
#[tauri::command]
|
|
pub fn socket_connect(app: AppHandle, backend_url: String, token: String) -> Result<(), String> {
|
|
// Set app handle for event emission
|
|
SOCKET_SERVICE.set_app_handle(app);
|
|
|
|
// Request frontend to connect
|
|
SOCKET_SERVICE.request_connect(&backend_url, &token)
|
|
}
|
|
|
|
/// Request the frontend to disconnect from the socket server
|
|
#[tauri::command]
|
|
pub fn socket_disconnect() -> Result<(), String> {
|
|
SOCKET_SERVICE.request_disconnect()
|
|
}
|
|
|
|
/// Get current socket state
|
|
#[tauri::command]
|
|
pub fn get_socket_state() -> SocketState {
|
|
SOCKET_SERVICE.get_state()
|
|
}
|
|
|
|
/// Check if socket is connected
|
|
#[tauri::command]
|
|
pub fn is_socket_connected() -> bool {
|
|
SOCKET_SERVICE.is_connected()
|
|
}
|
|
|
|
/// Report socket connected (called by frontend)
|
|
#[tauri::command]
|
|
pub fn report_socket_connected(socket_id: Option<String>) {
|
|
SOCKET_SERVICE.report_connected(socket_id);
|
|
}
|
|
|
|
/// Report socket disconnected (called by frontend)
|
|
#[tauri::command]
|
|
pub fn report_socket_disconnected() {
|
|
SOCKET_SERVICE.report_disconnected();
|
|
}
|
|
|
|
/// Report socket error (called by frontend)
|
|
#[tauri::command]
|
|
pub fn report_socket_error(error: String) {
|
|
SOCKET_SERVICE.report_error(&error);
|
|
}
|
|
|
|
/// Update socket status (called by frontend)
|
|
#[tauri::command]
|
|
pub fn update_socket_status(status: String, socket_id: Option<String>) {
|
|
let status = match status.as_str() {
|
|
"connected" => ConnectionStatus::Connected,
|
|
"connecting" => ConnectionStatus::Connecting,
|
|
"reconnecting" => ConnectionStatus::Reconnecting,
|
|
"error" => ConnectionStatus::Error,
|
|
_ => ConnectionStatus::Disconnected,
|
|
};
|
|
SOCKET_SERVICE.update_status(status, socket_id);
|
|
}
|