Skip to main content

MemoryStore

Struct MemoryStore 

Source
pub struct MemoryStore { /* private fields */ }
Expand description

A ConversationStore kept in memory, for runtime tests.

Implementations§

Source§

impl MemoryStore

Source

pub fn new(clock: Arc<dyn Clock>) -> Self

An empty store reading time from clock.

Source

pub fn runs(&self) -> Vec<AgentRunRecord>

Recorded agent runs, oldest first.

Source

pub fn recorded_tool_calls(&self) -> Vec<ToolCallRecord>

Recorded tool calls, oldest first.

Trait Implementations§

Source§

impl ConversationStore for MemoryStore

Source§

fn mark_seen<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, channel: &'life1 ChannelId, event_id: &'life2 str, ttl: Duration, ) -> Pin<Box<dyn Future<Output = Result<bool, StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Records an inbound event id. Returns false when it was already seen within ttl.
Source§

fn append<'life0, 'async_trait>( &'life0 self, message: NewMessage, ) -> Pin<Box<dyn Future<Output = Result<(), StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Appends a message to a conversation.
Source§

fn recent<'life0, 'life1, 'async_trait>( &'life0 self, conversation: &'life1 ConversationKey, limit: usize, ) -> Pin<Box<dyn Future<Output = Result<Vec<StoredMessage>, StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

The newest limit messages after the last reset, oldest first.
Source§

fn reset<'life0, 'life1, 'async_trait>( &'life0 self, conversation: &'life1 ConversationKey, ) -> Pin<Box<dyn Future<Output = Result<(), StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Starts a fresh history for the conversation (/reset). Old messages stay for audit until retention removes them.
Source§

fn session<'life0, 'life1, 'async_trait>( &'life0 self, conversation: &'life1 ConversationKey, ) -> Pin<Box<dyn Future<Output = Result<Option<(String, String)>, StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

The native agent session of a conversation: (backend, session id).
Source§

fn set_session<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, conversation: &'life1 ConversationKey, backend: &'life2 str, session: &'life3 str, ) -> Pin<Box<dyn Future<Output = Result<(), StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Remembers the native agent session of a conversation (cleared by ConversationStore::reset).
Source§

fn owners<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Vec<(ChannelId, UserId)>, StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Accounts of the owner of a personal bot (paired with ConversationStore::redeem_pairing_code).
Source§

fn remove_owner<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, channel: &'life1 ChannelId, user: &'life2 UserId, ) -> Pin<Box<dyn Future<Output = Result<bool, StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Removes an owner account. Returns whether it was one.
Source§

fn create_pairing_code<'life0, 'life1, 'async_trait>( &'life0 self, code: &'life1 str, ttl: Duration, ) -> Pin<Box<dyn Future<Output = Result<(), StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Stores a one-time pairing code, valid for ttl.
Source§

fn redeem_pairing_code<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, code: &'life1 str, channel: &'life2 ChannelId, user: &'life3 UserId, ) -> Pin<Box<dyn Future<Output = Result<bool, StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Consumes code and makes (channel, user) an owner account when the code is valid. Read more
Source§

fn record_run<'life0, 'async_trait>( &'life0 self, run: AgentRunRecord, ) -> Pin<Box<dyn Future<Output = Result<(), StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Records an agent run.
Source§

fn claim_fire<'life0, 'life1, 'async_trait>( &'life0 self, task_id: &'life1 str, fire_at: Timestamp, ) -> Pin<Box<dyn Future<Output = Result<Fire, StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Claims a task firing: records it as FireState::Sending the first time and returns its current record, so a firing that was already sent is never sent again.
Source§

fn set_fire<'life0, 'life1, 'async_trait>( &'life0 self, task_id: &'life1 str, fire_at: Timestamp, state: FireState, attempts: u32, ) -> Pin<Box<dyn Future<Output = Result<(), StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Updates a claimed firing.
Source§

fn recent_fires<'life0, 'async_trait>( &'life0 self, limit: usize, ) -> Pin<Box<dyn Future<Output = Result<Vec<Fire>, StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

The newest limit firings, newest first (for okbot doctor and okbot task).
Source§

fn set_direct_chat<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, channel: &'life1 ChannelId, user: &'life2 UserId, conversation: &'life3 ConversationKey, ) -> Pin<Box<dyn Future<Output = Result<(), StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Remembers the direct conversation of user on channel (reminders sent there).
Source§

fn direct_chat<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, channel: &'life1 ChannelId, user: &'life2 UserId, ) -> Pin<Box<dyn Future<Output = Result<Option<ConversationKey>, StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

The latest direct conversation of user on channel.
Source§

fn usage_since<'life0, 'life1, 'async_trait>( &'life0 self, person: &'life1 str, since: Timestamp, ) -> Pin<Box<dyn Future<Output = Result<Usage, StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Turns and tokens of person (person_key) in runs started at or after since.
Source§

fn record_tool_call<'life0, 'async_trait>( &'life0 self, call: ToolCallRecord, ) -> Pin<Box<dyn Future<Output = Result<(), StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Records a tool call.
Source§

fn tool_calls<'life0, 'async_trait>( &'life0 self, since: Timestamp, limit: usize, ) -> Pin<Box<dyn Future<Output = Result<Vec<ToolCallRecord>, StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Tool calls made at or after since, newest first, at most limit.
Source§

fn grant_role<'life0, 'async_trait>( &'life0 self, grant: RoleGrant, ) -> Pin<Box<dyn Future<Output = Result<(), StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Grants a role until grant.expires_at, replacing an earlier grant of the same role to the same account.
Source§

fn revoke_role<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, role: &'life1 str, account: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<bool, StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Ends a grant before it expires. Returns whether there was one.
Source§

fn role_grants<'life0, 'async_trait>( &'life0 self, now: Timestamp, ) -> Pin<Box<dyn Future<Output = Result<Vec<RoleGrant>, StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Grants that have not expired at now.
Source§

fn purge_before<'life0, 'async_trait>( &'life0 self, before: Timestamp, ) -> Pin<Box<dyn Future<Output = Result<u64, StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Deletes messages, runs, tool calls, expired grants, dedupe marks, finished firings and automation records older than before. Returns rows removed.
Source§

fn sealed<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, kind: &'life1 str, server: &'life2 str, subject: &'life3 str, ) -> Pin<Box<dyn Future<Output = Result<Option<Vec<u8>>, StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

A sealed secret (ADR 0012): the runtime seals and opens it; the store only keeps bytes.
Source§

fn set_sealed<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, kind: &'life1 str, server: &'life2 str, subject: &'life3 str, sealed: Vec<u8>, ) -> Pin<Box<dyn Future<Output = Result<(), StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Stores or replaces a sealed secret.
Source§

fn delete_sealed<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, kind: &'life1 str, server: &'life2 str, subject: &'life3 str, ) -> Pin<Box<dyn Future<Output = Result<bool, StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Deletes a sealed secret. Returns whether there was one.
Source§

fn sealed_entries<'life0, 'life1, 'async_trait>( &'life0 self, kind: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Vec<SealedEntry>, StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

The sealed secrets of kind, without their values, by server and subject.
Source§

fn claim_items<'life0, 'life1, 'async_trait>( &'life0 self, automation: &'life1 str, items: Vec<String>, ) -> Pin<Box<dyn Future<Output = Result<Vec<String>, StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Records items as seen by automation and returns those that were not seen before, in their order.
Source§

fn release_items<'life0, 'life1, 'async_trait>( &'life0 self, automation: &'life1 str, items: Vec<String>, ) -> Pin<Box<dyn Future<Output = Result<(), StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Forgets that automation saw items, so they count as new again (items not acted on).
Source§

fn record_automation_run<'life0, 'async_trait>( &'life0 self, run: AutomationRun, ) -> Pin<Box<dyn Future<Output = Result<(), StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Records a run of an automation.
Source§

fn automation_runs<'life0, 'life1, 'async_trait>( &'life0 self, automation: Option<&'life1 str>, since: Timestamp, limit: usize, ) -> Pin<Box<dyn Future<Output = Result<Vec<AutomationRun>, StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Runs at or after since, of one automation or of all, newest first, at most limit.
Source§

fn put_peer_task<'life0, 'async_trait>( &'life0 self, task: PeerTaskRecord, ) -> Pin<Box<dyn Future<Output = Result<(), StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Stores a peer task (ADR 0014), replacing the one with the same id and direction.
Source§

fn peer_task<'life0, 'life1, 'async_trait>( &'life0 self, inbound: bool, id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<PeerTaskRecord>, StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

A peer task by its id and direction.
Source§

fn peer_task_by_message<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, inbound: bool, team: &'life1 str, peer: &'life2 str, message_id: &'life3 str, ) -> Pin<Box<dyn Future<Output = Result<Option<PeerTaskRecord>, StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

The task a message created, if any (a retried request returns the same task).
Source§

fn peer_tasks<'life0, 'async_trait>( &'life0 self, limit: usize, ) -> Pin<Box<dyn Future<Output = Result<Vec<PeerTaskRecord>, StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Peer tasks, newest first, at most limit.
Source§

fn interrupt_peer_tasks<'life0, 'async_trait>( &'life0 self, now: Timestamp, ) -> Pin<Box<dyn Future<Output = Result<u64, StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Marks inbound tasks that were not finished as failed (“interrupted”), at start-up: work with side effects is never re-run by itself. Returns how many.
Source§

impl Debug for MemoryStore

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.