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/agent-memory-events

v0.1.0

Published

Event bus and event types for agent-memory lifecycle hooks

Readme

@reaatech/agent-memory-events

npm version License: MIT CI

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

Event bus and event types for agent-memory lifecycle hooks. Publish and subscribe to memory creation, retrieval, contradiction, decay, and forgetting events — enabling audit logging, metrics collection, and custom side-effects without modifying core code.

Installation

npm install @reaatech/agent-memory-events
# or
pnpm add @reaatech/agent-memory-events

Feature Overview

  • 9 lifecycle event types — extracted, stored, retrieved, contradiction detected/resolved/pending, decayed, forgotten, consolidated
  • In-memory event bus — zero-dependency implementation suitable for single-process use
  • Typed payloads — each event carries its tenantId, timestamp, and structured payload
  • Pluggable interface — swap in Redis, Kafka, or any pub/sub by implementing MemoryEventBus

Quick Start

import { InMemoryEventBus } from '@reaatech/agent-memory-events';

const events = new InMemoryEventBus();

// Subscribe to memory storage events
events.on('memory:stored', (event) => {
  console.log(`Memory ${event.payload.memory.id} stored`);
  // Forward to audit log, increment Prometheus counter, etc.
});

// Subscribe to contradiction resolutions
events.on('memory:contradiction:resolved', async (event) => {
  await auditLog.record({
    tenantId: event.tenantId,
    decision: event.payload.decision.action,
    reason: event.payload.decision.reason,
  });
});

// Emit an event
await events.emit({
  type: 'memory:stored',
  timestamp: new Date(),
  tenantId: 'default',
  payload: { memory: { id: 'abc-123', content: 'User prefers dark mode' } },
});

API Reference

Event Types

| Event Type | Emitted When | |------------|--------------| | memory:extracted | Memories are extracted from a conversation | | memory:stored | A single memory is persisted to storage | | memory:retrieved | Memories are retrieved for a query | | memory:contradiction:detected | A contradiction is identified | | memory:contradiction:resolved | A contradiction is resolved per policy | | memory:contradiction:pending_review | A contradiction is flagged for manual review | | memory:decayed | Decay scores are recalculated | | memory:forgotten | A memory is archived or deleted | | memory:consolidated | Multiple memories are merged |

MemoryEvent

interface MemoryEvent {
  type: MemoryEventType;
  timestamp: Date;
  tenantId: string;
  payload: unknown;
}

MemoryEventBus Interface

The contract all implementations must satisfy:

interface MemoryEventBus {
  on(event: MemoryEventType, handler: MemoryEventHandler): void;
  off(event: MemoryEventType, handler: MemoryEventHandler): void;
  once(event: MemoryEventType, handler: MemoryEventHandler): void;
  emit(event: MemoryEvent): Promise<void>;
}

InMemoryEventBus (class)

A synchronous, in-process event bus backed by a Map<string, Set<MemoryEventHandler>>.

| Method | Description | |--------|-------------| | on(event, handler) | Register a handler for an event type | | off(event, handler) | Remove a specific handler | | once(event, handler) | Register a handler that fires at most once | | emit(event) | Synchronously invoke all handlers for the event type | | clear() | Remove all handlers for all event types | | removeAllListeners(event) | Remove all handlers for a specific event type |

MemoryEventHandler

type MemoryEventHandler = (event: MemoryEvent) => Promise<void> | void;

Usage Patterns

Audit Logging

events.on('memory:forgotten', async (event) => {
  await db.insert('audit_log', {
    action: 'forgotten',
    memoryId: event.payload.memoryId,
    tenantId: event.tenantId,
    reason: event.payload.reason,
    timestamp: event.timestamp,
  });
});

Metrics Collection

import { Counter } from 'prom-client';

const storedCounter = new Counter({
  name: 'agent_memory_stored_total',
  help: 'Total number of memories stored',
  labelNames: ['tenant', 'type'],
});

events.on('memory:stored', (event) => {
  storedCounter.inc({
    tenant: event.tenantId,
    type: event.payload.memory.type,
  });
});

Related Packages

License

MIT