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

@reaatech/session-continuity-storage-memory

v0.1.0

Published

In-memory storage adapter for session-continuity-kit

Readme

@reaatech/session-continuity-storage-memory

npm version License: MIT CI

Status: Pre-1.0 — APIs may change in minor versions. Pin to a specific version in production.

In-memory storage adapter implementing IStorageAdapter from @reaatech/session-continuity. Uses Map-based storage with optional simulated TTL expiration — ideal for development, testing, and single-process prototypes.

Installation

npm install @reaatech/session-continuity-storage-memory
# or
pnpm add @reaatech/session-continuity-storage-memory

Feature Overview

  • Zero dependencies beyond core — self-contained, no external storage services
  • Implements IStorageAdapter — drop-in replacement for any storage backend
  • Simulated TTL — configurable expiration via setTimeout timers
  • Full query support — client-side filtering for roles, time ranges, pagination
  • Monotonic ordering — assigns a per-session sequence so messages return in stable insertion order, even within the same millisecond
  • Optimistic concurrencyupdateSession honors expectedVersion and throws ConcurrencyError on a stale write
  • Instant health check — always returns healthy with zero latency

Quick Start

import { MemoryAdapter } from '@reaatech/session-continuity-storage-memory';
import { SessionManager } from '@reaatech/session-continuity';

const adapter = new MemoryAdapter({ ttlMs: 3600000 }); // 1-hour TTL

const manager = new SessionManager({
  storage: adapter,
  tokenCounter: myTokenCounter,
});

const session = await manager.createSession({ userId: 'user-123' });

API Reference

MemoryAdapter

Constructor

new MemoryAdapter(config?: MemoryAdapterConfig)

MemoryAdapterConfig

| Property | Type | Default | Description | | -------- | -------- | ------- | ----------------------------------------------------------------- | | ttlMs | number | — | Simulated TTL in milliseconds. Sessions expire after this period. |

Public Methods

| Method | Signature | Notes | | -------------------- | ------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------- | | createSession | (session: Omit<Session, "id" \| "createdAt" \| "lastActivityAt">): Promise<Session> | Auto-generates ID and expiresAt from ttlMs | | getSession | (id: SessionId): Promise<Session \| null> | Lookup from internal Map | | updateSession | (id: SessionId, updates: Partial<Session>): Promise<Session> | Throws StorageError if not found; resets TTL timer | | deleteSession | (id: SessionId): Promise<void> | Removes session + messages + clears TTL timer | | listSessions | (filters?: SessionFilters): Promise<Session[]> | Client-side filtering; tags use OR semantics | | addMessage | (sessionId: SessionId, message: ...): Promise<Message> | Auto-generates ID | | getMessages | (sessionId: SessionId, options?: MessageQueryOptions): Promise<Message[]> | Sorted by createdAt; supports roles, after, before, offset, limit | | updateMessage | (sessionId: SessionId, messageId: MessageId, updates: Partial<Message>): Promise<Message> | Throws StorageError if not found | | deleteMessage | (sessionId: SessionId, messageId: MessageId): Promise<void> | — | | deleteAllMessages | (sessionId: SessionId): Promise<void> | Clears all messages for a session | | getExpiredSessions | (before: Date): Promise<SessionId[]> | Scans expiresAt fields | | health | (): Promise<HealthStatus> | Always { status: "healthy", latency: 0 } | | close | (): Promise<void> | Clears all Maps and timers |

Usage Patterns

With SessionManager (TTL + Cleanup)

import { MemoryAdapter } from '@reaatech/session-continuity-storage-memory';
import { SessionManager } from '@reaatech/session-continuity';
import { TiktokenTokenizer } from '@reaatech/session-continuity-tokenizers';

const manager = new SessionManager({
  storage: new MemoryAdapter({ ttlMs: 3600000 }),
  tokenCounter: new TiktokenTokenizer('gpt-4'),
  sessionTTL: 3600,
  cleanupInterval: 300, // every 5 minutes
});

const session = await manager.createSession({ userId: 'user-123' });
// ... session auto-expires after 1 hour ...
await manager.close(); // clean up timers

Standalone Use

import { MemoryAdapter } from '@reaatech/session-continuity-storage-memory';

const adapter = new MemoryAdapter();

const session = await adapter.createSession({
  userId: 'test-user',
  status: 'active',
  metadata: { title: 'Test Session' },
  participants: [],
  schemaVersion: 1,
});

const messages = await adapter.listSessions({ userId: 'test-user' });

await adapter.close();

Related Packages

License

MIT