PostgresAdapter

Struct PostgresAdapter 

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

PostgreSQL database adapter

Implementations§

Source§

impl PostgresAdapter

Source

pub async fn set_current_agent(&self, agent_id: Uuid) -> Result<()>

Set current agent context for RLS policies

Source

pub async fn new(database_url: &str) -> Result<Self>

Create a new PostgreSQL adapter

Source

pub async fn with_pool(pool: PgPool) -> Self

Create with custom pool options

Source§

impl PostgresAdapter

Source

pub async fn persist_llm_cost(&self, record: LLMCostRecord) -> Result<()>

Trait Implementations§

Source§

impl IDatabaseAdapter for PostgresAdapter

Source§

fn db(&self) -> &dyn Any

Get database instance (type-erased)
Source§

fn initialize<'life0, 'async_trait>( &'life0 mut self, _config: Option<Value>, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Initialize database connection
Source§

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

Check if database is ready
Source§

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

Close database connection
Source§

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

Get database connection (type-erased)
Source§

fn run_plugin_migrations<'life0, 'async_trait>( &'life0 self, plugins: Vec<PluginMigration>, options: MigrationOptions, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Run plugin schema migrations
Source§

fn get_agent<'life0, 'async_trait>( &'life0 self, agent_id: UUID, ) -> Pin<Box<dyn Future<Output = Result<Option<Agent>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get agent by ID
Source§

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

Get all agents
Source§

fn create_agent<'life0, 'life1, 'async_trait>( &'life0 self, agent: &'life1 Agent, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Create agent
Source§

fn update_agent<'life0, 'life1, 'async_trait>( &'life0 self, agent_id: UUID, agent: &'life1 Agent, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Update agent
Source§

fn delete_agent<'life0, 'async_trait>( &'life0 self, agent_id: UUID, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Delete agent
Source§

fn ensure_embedding_dimension<'life0, 'async_trait>( &'life0 self, dimension: usize, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Ensure embedding dimension
Source§

fn get_entities_by_ids<'life0, 'async_trait>( &'life0 self, entity_ids: Vec<UUID>, ) -> Pin<Box<dyn Future<Output = Result<Vec<Entity>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get entities by IDs
Source§

fn get_entities_for_room<'life0, 'async_trait>( &'life0 self, room_id: UUID, _include_components: bool, ) -> Pin<Box<dyn Future<Output = Result<Vec<Entity>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get entities for room
Source§

fn create_entities<'life0, 'async_trait>( &'life0 self, entities: Vec<Entity>, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Create entities
Source§

fn update_entity<'life0, 'life1, 'async_trait>( &'life0 self, entity: &'life1 Entity, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Update entity
Source§

fn get_entity_by_id<'life0, 'async_trait>( &'life0 self, entity_id: UUID, ) -> Pin<Box<dyn Future<Output = Result<Option<Entity>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get entity by ID
Source§

fn get_component<'life0, 'life1, 'async_trait>( &'life0 self, entity_id: UUID, component_type: &'life1 str, world_id: Option<UUID>, source_entity_id: Option<UUID>, ) -> Pin<Box<dyn Future<Output = Result<Option<Component>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get component
Source§

fn get_components<'life0, 'async_trait>( &'life0 self, entity_id: UUID, world_id: Option<UUID>, source_entity_id: Option<UUID>, ) -> Pin<Box<dyn Future<Output = Result<Vec<Component>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get all components for an entity
Source§

fn create_component<'life0, 'life1, 'async_trait>( &'life0 self, component: &'life1 Component, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Create component
Source§

fn update_component<'life0, 'life1, 'async_trait>( &'life0 self, component: &'life1 Component, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Update component
Source§

fn delete_component<'life0, 'async_trait>( &'life0 self, component_id: UUID, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Delete component
Source§

fn get_memories<'life0, 'async_trait>( &'life0 self, params: MemoryQuery, ) -> Pin<Box<dyn Future<Output = Result<Vec<Memory>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get memories matching criteria
Source§

fn create_memory<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, memory: &'life1 Memory, _table_name: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<UUID>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Create memory
Source§

fn search_memories_by_embedding<'life0, 'async_trait>( &'life0 self, params: SearchMemoriesParams, ) -> Pin<Box<dyn Future<Output = Result<Vec<Memory>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Search memories by embedding
Source§

fn get_cached_embeddings<'life0, 'async_trait>( &'life0 self, params: MemoryQuery, ) -> Pin<Box<dyn Future<Output = Result<Vec<Memory>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get cached embeddings
Source§

fn update_memory<'life0, 'life1, 'async_trait>( &'life0 self, memory: &'life1 Memory, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Update memory
Source§

fn remove_memory<'life0, 'life1, 'async_trait>( &'life0 self, memory_id: UUID, _table_name: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Remove memory
Source§

fn remove_all_memories<'life0, 'life1, 'async_trait>( &'life0 self, agent_id: UUID, _table_name: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Remove all memories for agent
Source§

fn count_memories<'life0, 'async_trait>( &'life0 self, params: MemoryQuery, ) -> Pin<Box<dyn Future<Output = Result<usize>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Count memories
Source§

fn get_world<'life0, 'async_trait>( &'life0 self, world_id: UUID, ) -> Pin<Box<dyn Future<Output = Result<Option<World>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get world
Source§

fn ensure_world<'life0, 'life1, 'async_trait>( &'life0 self, world: &'life1 World, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Ensure world exists
Source§

fn get_room<'life0, 'async_trait>( &'life0 self, room_id: UUID, ) -> Pin<Box<dyn Future<Output = Result<Option<Room>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get room
Source§

fn create_room<'life0, 'life1, 'async_trait>( &'life0 self, room: &'life1 Room, ) -> Pin<Box<dyn Future<Output = Result<UUID>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Create room
Source§

fn get_rooms<'life0, 'async_trait>( &'life0 self, world_id: UUID, ) -> Pin<Box<dyn Future<Output = Result<Vec<Room>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get rooms for world
Source§

fn get_rooms_for_agent<'life0, 'async_trait>( &'life0 self, agent_id: UUID, ) -> Pin<Box<dyn Future<Output = Result<Vec<Room>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get rooms for agent
Source§

fn add_participant<'life0, 'async_trait>( &'life0 self, entity_id: UUID, room_id: UUID, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Add participant to room
Source§

fn remove_participant<'life0, 'async_trait>( &'life0 self, entity_id: UUID, room_id: UUID, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Remove participant from room
Source§

fn get_participants<'life0, 'async_trait>( &'life0 self, room_id: UUID, ) -> Pin<Box<dyn Future<Output = Result<Vec<Participant>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get participants for room
Source§

fn create_relationship<'life0, 'life1, 'async_trait>( &'life0 self, relationship: &'life1 Relationship, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Create relationship
Source§

fn get_relationship<'life0, 'async_trait>( &'life0 self, entity_id_a: UUID, entity_id_b: UUID, ) -> Pin<Box<dyn Future<Output = Result<Option<Relationship>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get relationship
Source§

fn create_task<'life0, 'life1, 'async_trait>( &'life0 self, task: &'life1 Task, ) -> Pin<Box<dyn Future<Output = Result<UUID>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Create task
Source§

fn update_task<'life0, 'life1, 'async_trait>( &'life0 self, task: &'life1 Task, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Update task
Source§

fn get_task<'life0, 'async_trait>( &'life0 self, task_id: UUID, ) -> Pin<Box<dyn Future<Output = Result<Option<Task>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get task
Source§

fn get_pending_tasks<'life0, 'async_trait>( &'life0 self, agent_id: UUID, ) -> Pin<Box<dyn Future<Output = Result<Vec<Task>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get pending tasks
Source§

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

Log entry
Source§

fn get_logs<'life0, 'async_trait>( &'life0 self, params: LogQuery, ) -> Pin<Box<dyn Future<Output = Result<Vec<Log>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get logs
Source§

fn get_agent_run_summaries<'life0, 'async_trait>( &'life0 self, params: RunSummaryQuery, ) -> Pin<Box<dyn Future<Output = Result<AgentRunSummaryResult>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get agent run summaries
Source§

fn init<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Result<(), ZoeyError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Initialize database (alias)
Source§

fn persist_llm_cost<'life0, 'async_trait>( &'life0 self, _record: LLMCostRecord, ) -> Pin<Box<dyn Future<Output = Result<(), ZoeyError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Persist an LLM cost record

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more