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

@agentxjs/persistence

v1.8.1

Published

Multi-backend persistence layer for AgentX - supports memory, SQLite, Redis, MongoDB, and SQL databases

Readme

@agentxjs/persistence

Storage layer for AgentX with pluggable drivers

Overview

@agentxjs/persistence provides the persistence layer for AgentX agents, including:

  • Image Repository - Store and retrieve agent snapshots
  • Container Repository - Manage container metadata
  • Session Repository - Persist conversation history

Key Features:

  • Subpath Exports - Import only the driver you need (tree-shaking friendly)
  • Multiple Backends - SQLite, Redis, MongoDB, MySQL, PostgreSQL
  • Zero Config Default - Memory driver works out of the box
  • Cross-Runtime - SQLite driver works on both Bun and Node.js 22+

Installation

bun add @agentxjs/persistence

Quick Start

Memory Driver (Default)

import { createPersistence, memoryDriver } from "@agentxjs/persistence";

const persistence = await createPersistence(memoryDriver());

SQLite Driver

import { createPersistence } from "@agentxjs/persistence";
import { sqliteDriver } from "@agentxjs/persistence/sqlite";

const persistence = await createPersistence(sqliteDriver({ path: "./data/agentx.db" }));

Redis Driver

import { createPersistence } from "@agentxjs/persistence";
import { redisDriver } from "@agentxjs/persistence/redis";

const persistence = await createPersistence(redisDriver({ url: "redis://localhost:6379" }));

Available Drivers

| Driver | Import | Peer Dependencies | | ---------- | ---------------------------------- | ----------------- | | Memory | @agentxjs/persistence | None | | Filesystem | @agentxjs/persistence/fs | None | | SQLite | @agentxjs/persistence/sqlite | db0 | | Redis | @agentxjs/persistence/redis | ioredis | | MongoDB | @agentxjs/persistence/mongodb | mongodb | | MySQL | @agentxjs/persistence/mysql | mysql2 | | PostgreSQL | @agentxjs/persistence/postgresql | pg |

Driver Options

SQLite

Automatically detects runtime:

  • Bun: uses bun:sqlite (built-in)
  • Node.js 22+: uses node:sqlite (built-in)
sqliteDriver({
  path: "./data.db", // Database file path
});

Redis

redisDriver({
  url: "redis://localhost:6379", // Redis connection URL
});

MongoDB

mongodbDriver({
  connectionString: "mongodb://localhost:27017", // MongoDB connection string
  databaseName: "agentx", // Database name (optional)
  collectionName: "storage", // Collection name (optional)
});

MySQL

mysqlDriver({
  host: "localhost",
  port: 3306,
  user: "root",
  password: "password",
  database: "agentx",
});

PostgreSQL

postgresqlDriver({
  host: "localhost",
  port: 5432,
  user: "postgres",
  password: "password",
  database: "agentx",
});

Custom Driver

Implement the PersistenceDriver interface:

import { createPersistence, type PersistenceDriver } from "@agentxjs/persistence";
import { createStorage, type Storage } from "unstorage";

const customDriver: PersistenceDriver = {
  async createStorage(): Promise<Storage> {
    return createStorage({
      driver: yourCustomUnstorageDriver(),
    });
  },
};

const persistence = await createPersistence(customDriver);

Architecture

┌────────────────────────────────────────────────────────────┐
│                     Persistence                             │
├────────────────────────────────────────────────────────────┤
│                                                             │
│   ┌─────────────────┐  ┌─────────────────────────────────┐ │
│   │  Repositories   │  │         Storage (unstorage)     │ │
│   │                 │  │                                 │ │
│   │  ImageRepo      │◄─┼─ memoryDriver()                 │ │
│   │  ContainerRepo  │  │  sqliteDriver({ path })         │ │
│   │  SessionRepo    │  │  redisDriver({ url })           │ │
│   │                 │  │  mongodbDriver({ ... })         │ │
│   └─────────────────┘  │  mysqlDriver({ ... })           │ │
│                        │  postgresqlDriver({ ... })      │ │
│                        └─────────────────────────────────┘ │
│                                                             │
└────────────────────────────────────────────────────────────┘

Why Subpath Exports?

Each driver is a separate entry point to enable tree-shaking:

// Only bundles memory driver (no external deps)
import { memoryDriver } from "@agentxjs/persistence";

// Only bundles SQLite driver (requires db0)
import { sqliteDriver } from "@agentxjs/persistence/sqlite";

// Driver dependencies are NOT bundled if not imported

This is critical for binary distribution - portagent only imports sqliteDriver, so Redis/MySQL/PostgreSQL dependencies are never bundled.

Package Exports

{
  "exports": {
    ".": "./dist/index.js",
    "./sqlite": "./dist/drivers/sqlite.js",
    "./redis": "./dist/drivers/redis.js",
    "./mongodb": "./dist/drivers/mongodb.js",
    "./mysql": "./dist/drivers/mysql.js",
    "./postgresql": "./dist/drivers/postgresql.js"
  }
}

Related Packages

License

MIT