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

@bookingcare/db

v0.3.0

Published

Persistence layer for agent sessions with pluggable storage backends

Readme

@bookingcare/db

Persistence layer for agent sessions with pluggable storage backends.

Provides a Store interface for saving messages, todo snapshots, and session metadata. The shipped JSONStore provider writes each session to a dedicated directory on the local filesystem.

Installation

pnpm add @bookingcare/db

Quick Start

import { JSONStore } from "@bookingcare/db";

const store = await JSONStore.create({ baseDir: "./data" });

// Save a session
await store.saveMessages("session-1", messages);
await store.saveInfo("session-1", {
  sessionId: "session-1",
  model: "gpt-4",
  provider: "openai",
  systemPrompt: "You are helpful.",
  createdAt: Date.now(),
  updatedAt: Date.now(),
  messageCount: messages.length,
});

// Resume a session
const messages = await store.loadMessages("session-1");
const info = await store.loadInfo("session-1");

Store Interface

All storage backends implement Store:

interface Store {
  // Messages
  saveMessages(sessionId: string, messages: Message[]): Promise<void>;
  loadMessages(sessionId: string, opts?: LoadMessagesOptions): Promise<Message[]>;

  // Todos
  saveTodos(sessionId: string, snapshot: TodoSnapshot): Promise<void>;
  loadTodos(sessionId: string): Promise<TodoSnapshot | undefined>;

  // Metadata
  saveInfo(sessionId: string, info: AgentInfo): Promise<void>;
  loadInfo(sessionId: string): Promise<AgentInfo | undefined>;

  // Lifecycle
  exists(sessionId: string): Promise<boolean>;
  delete(sessionId: string): Promise<void>;
  list(prefix?: string): Promise<string[]>;
}

loadMessages filters

const msgs = await store.loadMessages("session-1", {
  role: "assistant", // only assistant messages
  limit: 10, // last 10 messages
  since: Date.now() - 24 * 60 * 60 * 1000, // messages from the last 24h
});

Filters can be combined. limit applies last (after role and since).

JSONStore

A filesystem-based Store implementation. Each session gets a directory containing three JSON files:

{baseDir}/{sessionId}/
  messages.json  — message transcript
  todos.json     — todo snapshot
  info.json      — session metadata
import { JSONStore } from "@bookingcare/db";

const store = await JSONStore.create({ baseDir: "./data/sessions" });

// Check if a session exists
if (await store.exists("session-1")) {
  // Delete it
  await store.delete("session-1");
}

// List all sessions
const sessionIds = await store.list();
// Filter by prefix
const agents = await store.list("agent-");

Error Types

| Error | When | | ------------------ | ------------------------------- | | StoreError | Base class for all store errors | | NotFoundError | Session does not exist | | CorruptDataError | Stored JSON is malformed |

JSONStore treats missing session files as normal: loadMessages returns an empty array, loadInfo and loadTodos return undefined.

Serialization Utilities

Helpers for converting agent runtime state into storable snapshots:

import { serializeAgentState, createTodoSnapshot } from "@bookingcare/db";

const { messages, info } = serializeAgentState(agentState);
const todoSnapshot = createTodoSnapshot(todoItems, renderedText);

serializeAgentState intentionally excludes transient fields (streamingMessage, pendingToolCalls, isStreaming, errorMessage) and tools (which are runtime function references). Callers must re-register tools after resuming a session.