Skip to main content

agentmux_srv/server/
native_memory_versions.rs

1// Copyright 2026, AgentMux Corp.
2// SPDX-License-Identifier: Apache-2.0
3
4//! Personal Memory versions as the history RPCs and MCP tools serve them,
5//! each with its size and estimated tokens (SPEC_MEMORY_PANE_TOKENS_2026_10_15.md ยง5.5).
6
7use crate::backend::rpc_types::NativeMemoryVersionMeta;
8use crate::backend::storage::{NativeMemoryVersion, NativeMemoryVersionSummary};
9
10pub(crate) fn version_summary_to_meta(v: NativeMemoryVersionSummary) -> NativeMemoryVersionMeta {
11    NativeMemoryVersionMeta {
12        id: v.id,
13        content_hash: v.content_hash,
14        parent_version_id: v.parent_version_id,
15        source: v.source,
16        source_detail: v.source_detail,
17        session_id: v.session_id,
18        created_at: v.created_at,
19        size_bytes: v.size_bytes,
20        tokens_est: v.tokens_est,
21    }
22}
23
24pub(crate) fn version_to_meta(v: &NativeMemoryVersion) -> NativeMemoryVersionMeta {
25    NativeMemoryVersionMeta {
26        id: v.id.clone(),
27        content_hash: v.content_hash.clone(),
28        parent_version_id: v.parent_version_id.clone(),
29        source: v.source.clone(),
30        source_detail: v.source_detail.clone(),
31        session_id: v.session_id.clone(),
32        created_at: v.created_at,
33        size_bytes: v.content.len() as u64,
34        tokens_est: agentmux_common::tokens::estimate_tokens(&v.content),
35    }
36}