feat(tui): implement status bar with connection and turn state indicators feat(tui): create workflow panel for agent status and progress visualization feat(web): introduce web frontend interface with static file serving feat(ws): add WebSocket interface for real-time communication and session management
77 lines
2.3 KiB
Rust
77 lines
2.3 KiB
Rust
//! Remember a lesson or fact as persistent memory.
|
|
|
|
use crate::tools::{Tool, ToolCtx};
|
|
use anyhow::Result;
|
|
use serde_json::{json, Value};
|
|
|
|
use zesdex_domain::cms::{Memory, MemoryRepository};
|
|
|
|
pub struct Remember;
|
|
|
|
impl Tool for Remember {
|
|
fn name(&self) -> &'static str {
|
|
"remember"
|
|
}
|
|
|
|
fn description(&self) -> &'static str {
|
|
"Save a lesson or fact to persistent memory"
|
|
}
|
|
|
|
fn parameters(&self) -> Value {
|
|
json!({
|
|
"type": "object",
|
|
"properties": {
|
|
"name": {
|
|
"type": "string",
|
|
"description": "Unique name for this memory"
|
|
},
|
|
"description": {
|
|
"type": "string",
|
|
"description": "Short summary of the memory"
|
|
},
|
|
"content": {
|
|
"type": "string",
|
|
"description": "Full content of the memory"
|
|
},
|
|
"kind": {
|
|
"type": "string",
|
|
"enum": ["lesson", "reference", "fact"],
|
|
"description": "Category of memory"
|
|
}
|
|
},
|
|
"required": ["name", "description", "content"]
|
|
})
|
|
}
|
|
|
|
fn run(&self, ctx: &ToolCtx, args: &Value) -> Result<String> {
|
|
let name = crate::tools::arg_str(args, "name")?;
|
|
let description = crate::tools::arg_str(args, "description")?;
|
|
let content = crate::tools::arg_str(args, "content")?;
|
|
let kind = args
|
|
.get("kind")
|
|
.and_then(|v| v.as_str())
|
|
.unwrap_or("reference")
|
|
.to_string();
|
|
|
|
let memory = Memory {
|
|
name: name.clone(),
|
|
description,
|
|
content,
|
|
kind,
|
|
created_at: chrono::Utc::now().timestamp(),
|
|
updated_at: chrono::Utc::now().timestamp(),
|
|
outcome: None,
|
|
lifecycle: "active".to_string(),
|
|
scope: None,
|
|
before_snippet: None,
|
|
after_snippet: None,
|
|
provenances: Vec::new(),
|
|
};
|
|
|
|
let repo = crate::persistence::cms::memory_repo::MarkdownMemoryRepository::new();
|
|
repo.save(&ctx.memory_dir, &memory)?;
|
|
|
|
Ok(format!("Memory '{}' saved", name))
|
|
}
|
|
}
|