npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@ziro-agent/checkpoint-postgres

v0.3.15

Published

Production Postgres Checkpointer adapter for ZiroAgent SDK — durable agent state with row-locked snapshot persistence (RFC 0006).

Readme

@ziro-agent/checkpoint-postgres

Production-grade Postgres Checkpointer for ZiroAgent SDK. Persists AgentSnapshot payloads with row-locked atomicity and UUID v7 lexicographically-sortable ids. Pair with agent.resumeFromCheckpoint to survive crashes, deploys, and HITL pauses across processes.

Per RFC 0006 §adapters; ships in v0.2.

Install

npm install @ziro-agent/checkpoint-postgres pg
# Peer dep is `pg >= 8.10`. Bring your own driver — we never pin a
# major version your deploy is trying to upgrade past.

Quick start

import { Pool } from 'pg';
import { createAgent } from '@ziro-agent/agent';
import {
  PostgresCheckpointer,
  ensureCheckpointsSchema,
} from '@ziro-agent/checkpoint-postgres';

const pool = new Pool({ connectionString: process.env.DATABASE_URL });

// Run ONCE at boot (or copy the SQL into your migration tool):
await ensureCheckpointsSchema(pool);

const agent = createAgent({
  model,
  tools,
  checkpointer: new PostgresCheckpointer({ pool }),
  defaultThreadId: 'support-conversation-42',
});

try {
  await agent.run({ prompt: '...' });
} catch (err) {
  // Snapshot was already auto-persisted on suspension. After a
  // restart, just resume from the thread id:
  await agent.resumeFromCheckpoint('support-conversation-42', { approver });
}

Schema

ensureCheckpointsSchema(pool, { schema?, table? }) runs:

CREATE TABLE IF NOT EXISTS public.ziro_checkpoints (
  thread_id     TEXT NOT NULL,
  checkpoint_id TEXT NOT NULL,
  snapshot      JSONB NOT NULL,
  version       INTEGER NOT NULL,
  size_bytes    INTEGER NOT NULL,
  created_at    TIMESTAMPTZ NOT NULL DEFAULT NOW(),
  PRIMARY KEY (thread_id, checkpoint_id)
);
CREATE INDEX IF NOT EXISTS ziro_checkpoints_thread_idx
  ON public.ziro_checkpoints (thread_id, checkpoint_id DESC);

It's safe to call repeatedly (idempotent), but prefer copying this SQL into your migration tool (Flyway, Atlas, drizzle-kit, Prisma migrate). Implicit DDL on a hot path is a multi-process footgun.

Options

new PostgresCheckpointer({
  pool,
  schema: 'public',           // identifier — only [a-zA-Z_][a-zA-Z0-9_]*
  table:  'ziro_checkpoints',
  maxCheckpointsPerThread: 100, // trim oldest in same INSERT; Infinity disables
  now: () => Date.now(),        // override for tests / determinism
});

Concurrency

  • put is atomic per (thread_id, checkpoint_id) via the PRIMARY KEY. UUID v7 ids are generated client-side so two concurrent writes to the same thread can never collide.
  • The trim-on-cap pass runs inside the same statement as the insert (a CTE), so a crash mid-trim leaves a consistent state, never a torn cap.
  • All other methods (get, list, delete) are simple single-statement reads / writes — your pool's normal connection semantics apply.

Testability

Tests don't need a real Postgres. The pool parameter is structurally typed (PgQueryable) — pass any { query(sql, params) } shape:

import { PostgresCheckpointer } from '@ziro-agent/checkpoint-postgres';

const stub = { async query() { return { rows: [] }; } };
const cp = new PostgresCheckpointer({ pool: stub });

This is the same hatch we use in our own test suite — see src/postgres-checkpointer.test.ts for an in-memory implementation that emulates the four statement shapes the adapter actually emits.

See also