use serde::{Deserialize, Serialize};
use crate::types::*;
use crate::types::{AgentId, MemoryId, SpaceId};
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum MemoryType {
Episodic,
Semantic,
Procedural,
AntiPattern,
Reasoning,
Correction,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct MemoryNode {
pub id: MemoryId,
pub agent_id: AgentId,
pub memory_type: MemoryType,
pub embedding: Embedding,
pub content: String,
pub created_at: Timestamp,
pub accessed_at: Timestamp,
pub access_count: u32,
pub salience: Salience,
pub confidence: Confidence,
pub space_id: SpaceId,
pub attributes: std::collections::HashMap<String, AttributeValue>,
pub tags: Vec<String>,
}
impl MemoryNode {
pub fn new(
agent_id: AgentId,
memory_type: MemoryType,
content: String,
embedding: Embedding,
) -> Self {
let now = std::time::SystemTime::now()
.duration_since(std::time::UNIX_EPOCH)
.unwrap_or_default()
.as_micros() as u64;
Self {
id: MemoryId::new(),
agent_id,
memory_type,
embedding,
content,
created_at: now,
accessed_at: now,
access_count: 0,
salience: 1.0,
confidence: 1.0,
space_id: SpaceId::nil(),
attributes: std::collections::HashMap::new(),
tags: Vec::new(),
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum AttributeValue {
String(String),
Integer(i64),
Float(f64),
Boolean(bool),
Bytes(Vec<u8>),
}