Skip to main content

Module archive

Module archive 

Source
Expand description

Archive lifecycle, browsing, and previews for agent session zones.

Structs§

ArchiveSummary
A single archive row. Mirrors the shape of RecentSessionRow’s preview fields so the frontend can reuse the same row component.

Constants§

MAX_PREVIEW_SNAPSHOT_BYTES 🔒
Snapshots larger than this are not parsed for a preview, so a corrupted one can’t stall a listing.

Functions§

archive_global_current
Archive the agent’s GLOBAL agent:<defId>:current content into a local (per-filestore) archive zone, so a cross-channel viewer’s conversation is preserved + browsable in this channel before the global current is cleared.
archive_session
Archive agent:<defId>:current to agent:<defId>:archive:<now_ms>.
clear_global_current_zone
Delete output.state.json + output from the agent’s GLOBAL agent:<defId>:current zone, if a global store is installed. Best-effort: a missing file is the expected “agent never mirrored” case (silent), other errors are logged but never propagated. Keeps the global zone in lockstep with the per-channel :current clear in archive_session.
clear_local_current_zone
Delete output.state.json + output from a per-channel :current zone, only for files that are present (so absence isn’t logged as an error). Best-effort — used after the global-preferred archive has persisted the content, to retire this channel’s (subset) copy.
collapse_preview 🔒
Collapse newlines + extra whitespace, cap at 240 chars. Output is safe to render inline in a single-line preview row.
copy_tsidx_best_effort 🔒
Copy the output.tsidx sidecar from src zone to dst zone, best-effort: absence is normal (pre-sidecar history), and no failure here may abort the surrounding archive — the sidecar is auxiliary timing data, not conversation content.
list_archives
List archive zones for definition_id, newest first.
read_archive_preview 🔒
Pull a small preview + node_count out of an archive’s output.state.json. Returns ("", 0) on any error.
read_snapshot_bytes 🔒
Read a zone file’s full bytes, mapping absence to Ok(None).
snapshot_preview 🔒
(preview, node_count) from an output.state.json snapshot’s bytes, or ("", 0) when they don’t parse or have no nodes array. The preview is the first user_message, skipping a leading “# Session Context” bootstrap message when a later one exists, collapsed to one line of at most 240 chars.