@operad/adapter-postgres
v0.1.0
Published
Postgres storage adapter for Operad — production-ready with recursive CTE tracing and JSONB queries
Maintainers
Readme
@operad/adapter-postgres
Production-ready PostgreSQL storage adapter for Operad — the event-sourced graph runtime for AI agents.
Features recursive CTE-based causal chain tracing, JSONB queries for flexible data filtering, and full transactional integrity.
Install
npm install @operad/core @operad/adapter-postgresUsage
import { createRuntime } from '@operad/core'
import { PostgresAdapter } from '@operad/adapter-postgres'
const runtime = createRuntime({
storage: new PostgresAdapter({
connectionString: process.env.DATABASE_URL!,
}),
})
const graph = await runtime.createGraph('production-agent')Features
- Causal chain queries — Recursive CTEs trace
causedBylinks through the full event history - JSONB filtering — Query objects and events by nested data fields
- Transactional integrity — All mutations are atomic
- Production-ready — Connection pooling, prepared statements, graceful shutdown
Schema
The adapter auto-creates tables on first use. Tables: operad_objects, operad_relations, operad_events, operad_decisions, operad_health.
When to use
| Adapter | Use case |
|---------|----------|
| adapter-memory | Development, testing, demos |
| adapter-postgres | Production, multi-session agents, audit trails, regulated industries |
Links
License
MIT
