Registry / database / agentledger-postgres

agentledger-postgres

JSON →
library1.2.4jsnpmunverified

PostgreSQL adapter for AgentLedger Runtime, enabling ledger persistence and migration management. Version 1.2.4 is current stable; released as needed. Differentiators: minimal API surface (applyMigrations), works with any pg-compatible client (exec/query/execute), and full TypeScript support. It requires agentledger-runtime as a peer dependency.

npm install agentledger-postgres
INSTALL
IMPORT
SIG · AGENTLEDGER-POSTGR
A
agentledger-postgres
databasejavascriptv1.2.4
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

PostgresAdapter
import { PostgresAdapter } from 'agentledger-postgres'
import PostgresAdapter from 'agentledger-postgres'
Named export only. No default export.
PostgresAdapter
const { PostgresAdapter } = require('agentledger-postgres')
const PostgresAdapter = require('agentledger-postgres')
CommonJS users must destructure the named export.
type PostgresAdapterConfig
import type { PostgresAdapterConfig } from 'agentledger-postgres'
import { PostgresAdapterConfig } from 'agentledger-postgres'
Type-only import avoids bundle bloat. Config type available since v1.2.0.

Initializes a PostgresAdapter with a pg Client and applies ledger migrations.

import { PostgresAdapter } from 'agentledger-postgres'; import { Client } from 'pg'; const pgClient = new Client({ connectionString: process.env.DATABASE_URL ?? 'postgres://localhost:5432/mydb' }); await pgClient.connect(); const adapter = new PostgresAdapter(pgClient); await adapter.applyMigrations(); console.log('Migrations applied successfully'); await pgClient.end();
Debug
Known issues
breakingIn v1.0.0 the constructor accepted (client, options), but since v1.1.0 it only accepts a single client argument.
fix
Remove second argument or merge into client config.
affects: >=1.0.0 <1.1.0
deprecatedThe method `runMigrations` is deprecated in v1.2.0. Use `applyMigrations` instead.
fix
Replace adapter.runMigrations() with adapter.applyMigrations().
affects: >=1.2.0
gotchaThe pg client must be connected before instantiating the adapter. Unconnected clients throw a runtime error.
fix
Call await client.connect() before new PostgresAdapter(client).
affects: >=1.0.0
breakingType 'PostgresAdapterConfig' was removed in v1.2.0; constructor now accepts a client duck-typed with exec, query, or execute methods.
fix
Pass any pg-compatible client instead of a config object.
affects: >=1.2.0
gotchaPool usage: If using pg.Pool, you must pass pool.query.bind(pool) or a wrapper. The adapter expects a client-like object.
fix
Use pool.connect() to get a client, then pass that client to the adapter.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: client.exec is not a function
The client object does not have an exec, query, or execute method.
fix
Ensure you pass a pg.Client instance (or similar) that has a query method.
Error: Migration directory not found at ./migrations
The adapter expects a migrations folder relative to the project root.
fix
Create a ./migrations folder or set the path via options (if available).
Cannot find module 'agentledger-runtime'
Missing peer dependency agentledger-runtime.
fix
Run npm install agentledger-runtime
Upgrade
Version history
1.2.4latest on npm
Audit
Dependencies
agentledger-runtimerequiredPeer dependency for runtime core types and interfaces.
Agent activity
23 hits · last 30 days
node
18
OpenAI (training)
2
Resources
agentledger-postgres — npm install agentledger-postgres · libregistry