pub struct PostgresAdapter { /* private fields */ }Expand description
Postgres + pgvector storage adapter.
Implementations§
Source§impl PostgresAdapter
impl PostgresAdapter
Sourcepub async fn connect(conn_str: &str) -> Result<Self>
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.
Sourcepub async fn connect_with_embedder(
conn_str: &str,
embedder: Arc<dyn Embedder>,
) -> Result<Self>
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.
Sourcepub async fn from_env() -> Result<Self>
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.
Sourcepub fn embedding_dim(&self) -> usize
pub fn embedding_dim(&self) -> usize
The embedding dimension this adapter’s knowledge_vectors column uses.
Sourcepub fn connector_config_store(&self) -> PgConnectorConfigStore
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.
Sourcepub fn settings_store(&self) -> PgSettingsStore
pub fn settings_store(&self) -> PgSettingsStore
A Postgres-backed SettingsStore
over this adapter’s pool (the agent_settings table).
Sourcepub fn indexing_store(&self) -> PgIndexingStore
pub fn indexing_store(&self) -> PgIndexingStore
A Postgres-backed IndexingStore
over this adapter’s pool (the indexing_runs table).
Sourcepub fn memory(
&self,
organization_id: impl Into<String>,
user_id: Option<String>,
) -> PgMemory
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
impl Drop for PostgresAdapter
Source§impl StorageAdapter for PostgresAdapter
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
Source§fn checkpoints(&self) -> Arc<dyn CheckpointStore>
fn checkpoints(&self) -> Arc<dyn CheckpointStore>
Agent
via Agent::with_checkpoint_store. Synchronous trait — the engine
calls it directly.Source§fn knowledge(&self) -> Arc<dyn KnowledgeBase>
fn knowledge(&self) -> Arc<dyn KnowledgeBase>
AgentConfig
via AgentConfig::with_knowledge. Synchronous trait. Read moreSource§fn knowledge_for_access(&self, access: &AccessContext) -> Arc<dyn KnowledgeBase>
fn knowledge_for_access(&self, access: &AccessContext) -> Arc<dyn KnowledgeBase>
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 moreAuto Trait Implementations§
impl !RefUnwindSafe for PostgresAdapter
impl !UnwindSafe for PostgresAdapter
impl Freeze for PostgresAdapter
impl Send for PostgresAdapter
impl Sync for PostgresAdapter
impl Unpin for PostgresAdapter
impl UnsafeUnpin for PostgresAdapter
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> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request