diff --git a/crates/jarvis-core/src/i18n/locales/en.ftl b/crates/jarvis-core/src/i18n/locales/en.ftl index 2c6e690..7f5a15e 100644 --- a/crates/jarvis-core/src/i18n/locales/en.ftl +++ b/crates/jarvis-core/src/i18n/locales/en.ftl @@ -161,4 +161,5 @@ settings-profile = Profile # Header buttons header-macros = Macros -header-scheduler = Schedule \ No newline at end of file +header-scheduler = Schedule +header-memory = Memory \ No newline at end of file diff --git a/crates/jarvis-core/src/i18n/locales/ru.ftl b/crates/jarvis-core/src/i18n/locales/ru.ftl index 8a8d4a5..a0744d4 100644 --- a/crates/jarvis-core/src/i18n/locales/ru.ftl +++ b/crates/jarvis-core/src/i18n/locales/ru.ftl @@ -161,4 +161,5 @@ settings-profile = Профиль # Header buttons header-macros = Макросы -header-scheduler = Расписание \ No newline at end of file +header-scheduler = Расписание +header-memory = Память \ No newline at end of file diff --git a/crates/jarvis-core/src/i18n/locales/ua.ftl b/crates/jarvis-core/src/i18n/locales/ua.ftl index c40bf96..519d3c1 100644 --- a/crates/jarvis-core/src/i18n/locales/ua.ftl +++ b/crates/jarvis-core/src/i18n/locales/ua.ftl @@ -161,4 +161,5 @@ settings-profile = Профіль # Header buttons header-macros = Макроси -header-scheduler = Розклад \ No newline at end of file +header-scheduler = Розклад +header-memory = Пам'ять \ No newline at end of file diff --git a/crates/jarvis-gui/src/main.rs b/crates/jarvis-gui/src/main.rs index f495bdb..312a19a 100644 --- a/crates/jarvis-gui/src/main.rs +++ b/crates/jarvis-gui/src/main.rs @@ -122,6 +122,12 @@ fn main() { tauri_commands::scheduler_list, tauri_commands::scheduler_remove, tauri_commands::scheduler_clear, + + // Long-term memory facts + tauri_commands::memory_list, + tauri_commands::memory_remember, + tauri_commands::memory_forget, + tauri_commands::memory_search, ]) .run(tauri::generate_context!()) .expect("error while running tauri application"); diff --git a/crates/jarvis-gui/src/tauri_commands.rs b/crates/jarvis-gui/src/tauri_commands.rs index 44c7a06..c507333 100644 --- a/crates/jarvis-gui/src/tauri_commands.rs +++ b/crates/jarvis-gui/src/tauri_commands.rs @@ -49,4 +49,8 @@ pub use macros::*; // Scheduler tasks mod scheduler; -pub use scheduler::*; \ No newline at end of file +pub use scheduler::*; + +// Long-term memory facts +mod memory; +pub use memory::*; \ No newline at end of file diff --git a/crates/jarvis-gui/src/tauri_commands/memory.rs b/crates/jarvis-gui/src/tauri_commands/memory.rs new file mode 100644 index 0000000..16cd58a --- /dev/null +++ b/crates/jarvis-gui/src/tauri_commands/memory.rs @@ -0,0 +1,45 @@ +//! Tauri commands for the long-term memory store. + +use serde::Serialize; + +#[derive(Serialize)] +pub struct MemoryFact { + pub key: String, + pub value: String, + pub created_at: i64, + pub last_used_at: i64, + pub use_count: u64, +} + +#[tauri::command] +pub fn memory_list() -> Vec { + jarvis_core::long_term_memory::all().into_iter().map(|r| MemoryFact { + key: r.key, + value: r.value, + created_at: r.created_at, + last_used_at: r.last_used_at, + use_count: r.use_count, + }).collect() +} + +#[tauri::command] +pub fn memory_remember(key: String, value: String) -> Result<(), String> { + jarvis_core::long_term_memory::remember(&key, &value) +} + +#[tauri::command] +pub fn memory_forget(key: String) -> bool { + jarvis_core::long_term_memory::forget(&key) +} + +#[tauri::command] +pub fn memory_search(query: String, limit: Option) -> Vec { + jarvis_core::long_term_memory::search(&query, limit.unwrap_or(10)) + .into_iter().map(|r| MemoryFact { + key: r.key, + value: r.value, + created_at: r.created_at, + last_used_at: r.last_used_at, + use_count: r.use_count, + }).collect() +} diff --git a/frontend/src/components/Header.svelte b/frontend/src/components/Header.svelte index e00d9a4..c6a8161 100644 --- a/frontend/src/components/Header.svelte +++ b/frontend/src/components/Header.svelte @@ -80,6 +80,10 @@ {t('header-scheduler') || 'Расписание'} + + diff --git a/frontend/src/routes/memory/index.svelte b/frontend/src/routes/memory/index.svelte new file mode 100644 index 0000000..15cf678 --- /dev/null +++ b/frontend/src/routes/memory/index.svelte @@ -0,0 +1,249 @@ + + + + +

Память

+ + Долговременные факты о пользователе. LLM получает их в системном промпте автоматически, + когда фразой пересекаются. Хранятся в long_term_memory.json. + + + + +
+
+ + + +
+
+ + + + + + + +{#if error} + { error = "" }} + > + {error} + + +{/if} + +{#if loading} + +{:else if facts.length === 0} + + Память пустая. Добавь факт сверху или скажи Jarvis-у "запомни что я люблю чай улун". + +{:else if visible.length === 0} + + По фильтру ничего не найдено. Всего фактов: {facts.length}. + +{:else} +
+ {#each visible as fact} +
+
+ {fact.key} +
+ + {fact.use_count}× использований + +
+
+
+ {fact.value} +
+
+ Создан: {fmtDate(fact.created_at)} + Последний доступ: {fmtDate(fact.last_used_at)} +
+
+ +
+
+ {/each} +
+{/if} + + + + + + +