Skip to main content

PostgresAdapter

Struct PostgresAdapter 

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

Postgres + pgvector storage adapter.

Implementations§

Source§

impl PostgresAdapter

Source

pub async fn connect(conn_str: &str) -> Result<Self>

Connect to Postgres, build the async pool + sync checkpoint store, and apply the schema. Uses the DeterministicEmbedder (1024-d) by default.

conn_str is a libpq URL or key=value connection string; it is read from DATABASE_URL / SMOOTH_AGENT_DATABASE_URL by Self::from_env.

§Errors

Returns an error if the connection string is invalid, either pool fails to build, or schema migration fails.

Source

pub async fn connect_with_embedder( conn_str: &str, embedder: Arc<dyn Embedder>, ) -> Result<Self>

As Self::connect but with a caller-supplied embedder. The adapter’s vector column width is taken from embedder.dim(), so a 1536-d GatewayEmbedder and the vector(1536) column always agree.

§Errors

See Self::connect.

Source

pub async fn from_env() -> Result<Self>

Connect using DATABASE_URL or SMOOTH_AGENT_DATABASE_URL (the latter wins if both are set).

§Errors

Returns an error if neither env var is set, or if Self::connect fails.

Source

pub fn embedding_dim(&self) -> usize

The embedding dimension this adapter’s knowledge_vectors column uses.

Source

pub fn connector_config_store(&self) -> PgConnectorConfigStore

A Postgres-backed ConnectorConfigStore over this adapter’s pool (the connector_configs table). Cheap to build (clones the pool handle); make as many as you like.

Source

pub fn settings_store(&self) -> PgSettingsStore

A Postgres-backed SettingsStore over this adapter’s pool (the agent_settings table).

Source

pub fn indexing_store(&self) -> PgIndexingStore

A Postgres-backed IndexingStore over this adapter’s pool (the indexing_runs table).

Source

pub fn memory( &self, organization_id: impl Into<String>, user_id: Option<String>, ) -> PgMemory

A Postgres-backed Memory over this adapter’s pool (the memories table), bound to one (organization_id, user_id) namespace — persistent, semantic, cross-thread agent memory (parity gap Phase 3 / SMOODEV-1470). Pass user_id = None for org-wide memory. Embeds with the adapter’s configured Embedder so memory and knowledge vectors share the same column width and hashing.

Cheap to build (clones pool + embedder handles); make one per (org, user) you serve.

Trait Implementations§

Source§

impl Drop for PostgresAdapter

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl StorageAdapter for PostgresAdapter

Source§

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

Create (or idempotently return) a conversation.
Source§

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

Fetch a conversation by id.
Source§

fn list_conversations_by_org<'life0, 'life1, 'async_trait>( &'life0 self, organization_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Vec<Conversation>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

List conversations owned by an organization (newest first).
Source§

fn update_conversation<'life0, 'life1, 'async_trait>( &'life0 self, id: &'life1 str, update: ConversationUpdate, ) -> Pin<Box<dyn Future<Output = Result<Conversation>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Apply a partial update to a conversation; returns the updated row.
Source§

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

Add a participant to a conversation.
Source§

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

Fetch a participant by id.
Source§

fn list_participants_by_conversation<'life0, 'life1, 'async_trait>( &'life0 self, conversation_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Vec<Participant>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

List all participants in a conversation.
Source§

fn resolve_participant_by_external_id<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, conversation_id: &'life1 str, external_id: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<Option<Participant>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Resolve a participant within a conversation by its external identity (e.g. Supabase auth user id). Used to re-attach a returning user.
Source§

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

Append a message to a conversation.
Source§

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

Fetch a message by id.
Source§

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

List messages in a conversation, paged.
Source§

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

Create a session (binds a conversation to a smooth-operator thread).
Source§

fn get_session<'life0, 'life1, 'async_trait>( &'life0 self, session_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<Session>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Fetch a session by id.
Source§

fn update_session<'life0, 'life1, 'async_trait>( &'life0 self, session_id: &'life1 str, update: SessionUpdate, ) -> Pin<Box<dyn Future<Output = Result<Session>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Apply a partial update (status / counts / activity) to a session.
Source§

fn list_sessions_by_conversation<'life0, 'life1, 'async_trait>( &'life0 self, conversation_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Vec<Session>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

List sessions attached to a conversation.
Source§

fn checkpoints(&self) -> Arc<dyn CheckpointStore>

The checkpoint store, ready to hand to a smooth-operator Agent via Agent::with_checkpoint_store. Synchronous trait — the engine calls it directly.
Source§

fn knowledge(&self) -> Arc<dyn KnowledgeBase>

The knowledge base, ready to hand to a smooth-operator AgentConfig via AgentConfig::with_knowledge. Synchronous trait. Read more
Source§

fn knowledge_for_access(&self, access: &AccessContext) -> Arc<dyn KnowledgeBase>

An ACL-enforcing knowledge handle bound to the requester’s AccessContext: its query returns only documents the requester is entitled to read (org-public docs, docs the requester’s user id is on, or docs any of the requester’s groups is on). This is the handle the chat retrieval path (auto-injected context and the knowledge_search tool) MUST read through — see docs/ACCESS-CONTROL.md. 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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FutureExt for T

Source§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
Source§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
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> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. 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: Sized + 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: Sized + 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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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