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

@oribos/observational-memory

v0.9.0

Published

Oribos observational-memory capability package — compaction over message history: wrap a MemoryStore so older messages that left the recall window are condensed inline, within the request that read them, into observation notes and reflections by your own

Downloads

38

Readme

@oribos/observational-memory

Compaction over message history that stays inside the request that read it — the observational memory capability package. It wraps a MemoryStore so that older messages which have left the recall window are condensed into observation notes by your model, and accumulated observations are merged into a reflection, all inline in the memory.recall that triggered it. One seam, no core changes:

import { Memory } from '@oribos/core/memory';
import { createObservationalMemoryStore } from '@oribos/observational-memory';
import { openai } from '@ai-sdk/openai';

const memory = new Memory({
  storage: createObservationalMemoryStore({
    observer: openai('gpt-4o-mini'),
    reflector: openai('gpt-4o-mini'),
  }),
  lastMessages: 10,
});

How it works

  • Over the threshold observes. A cursorless window read computes the backlog behind the window (messages older than it that no observation covers yet). When its estimated volume exceeds the observation threshold, one Observer pass runs inside that read: the oldest segment (≈ the threshold in volume) is condensed into an observation note. The next read observes the next segment — the cursor advances step by step, oldest first.
  • Over the reflection threshold reflects. Accumulated unreflected observations that outgrow the reflection threshold are merged — with the current reflection — into one updated reflection by the reflector model. Without a reflector, observations simply accumulate.
  • Reads render the derived blocks. A cursorless read returns one derived system message ahead of the window: the reflection, then the unreflected observations, then the window untouched. Paging with before is the raw read-back path: exact cursor semantics, no compaction, no injection, zero model calls.
  • Request-inline, zero-cost when unwrapped. No post-response write, no drain, zero timers — compaction happens only inside a cursorless read the application itself made. Without this wrapper the core's memory path is untouched.
  • Pins kept. Messages are immutable (observations and reflections are additive derived records), recall stays the single query entry, same-thread concurrent reads share one in-flight pass (in-process dedup), deleteThread cascades to the records, and the wrapped store's working-memory capability passes through.

The observation store

Observation records are the package's own port — ObservationStore: list(threadId), save(record), deleteByThread(threadId) — with { id, threadId, resourceId, createdAt, kind: 'observation' | 'reflection', sourceIds, text } records. createInMemoryObservationStore() ships as the zero-dependency default; persistence (a database, a file) is your implementation of the port. Losing records across restarts never costs correctness — the next recall re-observes what it can no longer see as observed (a re-paid model call, not a lost fact). Composes with @oribos/rag on the same seam: RAG inner, observational memory outer.

Thresholds and models

thresholds: { observation, reflection } are estimated-token volumes, defaulting to 1000 and 2000. Volume is estimated by countTokens(texts) => counts when provided (one count per text, in order); otherwise a characters/4 heuristic applies. Both models follow the framework's model contract — pass the language model from any AI SDK provider package, no adapter, no registry. A model error (or empty output) rejects the read explicitly; the known limitation is that the read path carries no abort signal, so a compaction call is not cancelled with the run.

See docs/architecture/memory.md (「观察记忆」) and examples/observational-memory.