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

@apeira/storage

v0.0.8

Published

Persistent storage adapters for Apeira agents.

Readme

@apeira/storage

Persistent AgentStorage implementations for Apeira.

Install

pnpm add @apeira/storage

JSON

Stores the complete entry array in a JSON file. Each append rewrites the file.

import { createAgent } from '@apeira/core'
import { json } from '@apeira/storage/json'

const agent = createAgent({
  instructions: 'You are a helpful assistant.',
  runner,
  storage: json({ path: './data/agent.json' }),
})

Use JSON storage when human-readable files are useful and the history is relatively small.

JSONL

Stores one entry per line and appends new entries without rewriting existing content.

import { createAgent } from '@apeira/core'
import { jsonl } from '@apeira/storage/jsonl'

const agent = createAgent({
  instructions: 'You are a helpful assistant.',
  runner,
  storage: jsonl({ path: './data/agent.jsonl' }),
})

JSONL is the better file format for long-running, append-heavy agents.

Key-value storage

Adapts a string key-value backend such as Web Storage or an asynchronous storage API. Entries are split into segments to avoid storing the complete log under one key.

import type { StorageLike } from '@apeira/storage/kv'

import { createAgent } from '@apeira/core'
import { kv } from '@apeira/storage/kv'

declare const backend: StorageLike

const agent = createAgent({
  instructions: 'You are a helpful assistant.',
  runner,
  storage: kv({
    backend,
    prefix: 'assistant',
    segmentSize: 100,
  }),
})

The backend must implement:

import type { MaybePromise } from '@apeira/core'

interface StorageLike {
  getItem: (key: string) => MaybePromise<null | string | undefined>
  removeItem: (key: string) => MaybePromise<void>
  setItem: (key: string, value: string) => MaybePromise<void>
}

prefix defaults to apeira and segmentSize defaults to 100.

Storage lifecycle

All implementations provide the standard AgentStorage operations:

import type { MaybePromise } from '@apeira/core'

interface AgentStorage<T> {
  append: (...items: T[]) => MaybePromise<void>
  clear: () => MaybePromise<void>
  read: () => MaybePromise<Readonly<T[]>>
}

Storage only manages persisted entries. Agent initialization and reset baselines belong to core:

const agent = createAgent({
  initialInput: [user('Existing context')],
  initialState: { userId: 'user-123' },
  instructions: 'You are a helpful assistant.',
  runner,
  storage: jsonl({ path: './data/agent.jsonl' }),
})

During initialization, core writes initialInput only when storage contains no input entries. agent.reset() clears storage and restores initialInput and initialState.

Generic storage

The storage functions default to AgentEntry, but can store another JSON-serializable type:

const store = jsonl<string>({ path: './data/items.jsonl' })

await store.append('first', 'second')
const items = await store.read()

JSON and JSONL storage require Node.js. Key-value storage works in any runtime that provides a compatible backend.