pub struct Archive { /* private fields */ }Expand description
Key management and content framing over a Storage for the context manager’s offloaded
content (Archive).
Each agent archives under context/<sessionId>/scopes/agent/<agentId>/. Keys are deterministic
(<toolUseId>_<index> for tool result content, <trackingId>_<blockIndex> for other blocks),
so placeholders can name them before the content is stored again after a restore. Clones share
the same archive.
Implementations§
Source§impl Archive
impl Archive
Sourcepub fn new(
storage: Arc<dyn Storage>,
session_id: &str,
agent_id: &str,
) -> Result<Self>
pub fn new( storage: Arc<dyn Storage>, session_id: &str, agent_id: &str, ) -> Result<Self>
An archive for agent_id in session_id, under context/<sessionId>/scopes/agent/<agentId>/
of storage.
§Errors
An id that does not form a valid storage prefix.
Sourcepub fn storage_type_name(&self) -> &str
pub fn storage_type_name(&self) -> &str
The type name of the base storage, recorded in session snapshots of a durable archive.
Sourcepub async fn store(
&self,
id: &str,
block_index: usize,
data: &[u8],
) -> Result<String>
pub async fn store( &self, id: &str, block_index: usize, data: &[u8], ) -> Result<String>
Stores serialized data under <id>_<blockIndex> and returns that reference (store).
§Errors
The storage’s write error.
Sourcepub async fn store_message(
&self,
message: &Message,
skip_tool_use_ids: Option<&HashSet<String>>,
stored_keys: Option<&HashSet<String>>,
)
pub async fn store_message( &self, message: &Message, skip_tool_use_ids: Option<&HashSet<String>>, stored_keys: Option<&HashSet<String>>, )
Stores every block of a message as it arrives (storeMessage). Protocol blocks, offload
placeholders and tool results in skip_tool_use_ids are left out, and a block already
stored under one of stored_keys keeps its entry, since a restored history can hold a
placeholder where the stored original was. Failures are logged.
Sourcepub async fn retrieve(&self, reference: &str) -> Result<Option<JsonValue>>
pub async fn retrieve(&self, reference: &str) -> Result<Option<JsonValue>>
The stored JSON of a reference, or None when there is none (retrieve).
§Errors
The storage’s read error, or stored bytes that are not JSON.
Sourcepub async fn list(&self, prefix: &str) -> Result<Vec<String>>
pub async fn list(&self, prefix: &str) -> Result<Vec<String>>
The stored references starting with prefix; every one for "" (list).
§Errors
The storage’s list error.
Sourcepub async fn clear(&self) -> Result<()>
pub async fn clear(&self) -> Result<()>
Deletes every entry of this archive (clear). On a caller-scoped archive this is the whole
shared view, other agents’ entries included.
§Errors
The storage’s list or delete error.
Sourcepub async fn clear_session(&self) -> Result<()>
pub async fn clear_session(&self) -> Result<()>
Deletes the archive data of this session for every agent, context/<sessionId>/ on the base
storage. A caller-scoped archive may be shared beyond the session and is
left in place.
§Errors
The storage’s list or delete error.
Sourcepub async fn take_snapshot(&self) -> Result<JsonObject>
pub async fn take_snapshot(&self) -> Result<JsonObject>
Every entry as reference to stored JSON, for a session snapshot.
§Errors
The storage’s errors, or stored bytes that are not JSON.
Sourcepub async fn load_snapshot(&self, entries: &JsonObject) -> Result<()>
pub async fn load_snapshot(&self, entries: &JsonObject) -> Result<()>
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Archive
impl !UnwindSafe for Archive
impl Freeze for Archive
impl Send for Archive
impl Sync for Archive
impl Unpin for Archive
impl UnsafeUnpin for Archive
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more