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

@premex/memoria

v0.2.0

Published

Official TypeScript client for Memoria — bi-temporal knowledge-graph memory for AI agents.

Downloads

602

Readme

@premex/memoria

npm version CI License: MIT

The official TypeScript client for Memoria — bi-temporal knowledge-graph memory for AI agents.

npm install @premex/memoria

Quick start

import { MemoriaClient } from '@premex/memoria';

const memoria = new MemoriaClient({ apiKey: 'mem_live_...' });

// Write a memory
await memoria.remember({
  content: 'Pricing for Enterprise is $499/seat/month, effective 2026-Q3.',
  source: 'agent',
});

// Recall it later
const { results } = await memoria.recall({
  query: 'What is enterprise pricing?',
  k: 5,
});

for (const r of results) {
  console.log(r.edge.factText, '— score:', r.score);
}

Get an API key at memoria.premex.se.

Bi-temporal recall

Memoria tracks two clocks for every fact: when it was true in the world (tValid/tInvalid) and when Memoria learned it (tIngested/tExpired). Pass asOf to recall what your agent knew at a point in time:

await memoria.recall({
  query: 'enterprise pricing',
  asOf: '2026-03-01T00:00:00Z',
});

This is the headline feature — most memory products only track ingestion time, so they can't answer "what did the agent believe last Tuesday?" correctly after a fact is updated.

API

Episodes | Method | Endpoint | |---|---| | remember(params) | POST /v1/episodes — runs the 7-stage extraction pipeline | | getEpisode(id) | GET /v1/episodes/:id | | getExtractionStatus(id) | GET /v1/episodes/:id/extraction-status — poll after async ingest |

Recall | Method | Endpoint | |---|---| | recall(params) | POST /v1/recall — hybrid dense + sparse + graph retrieval |

Entities | Method | Endpoint | |---|---| | createEntity(params) | POST /v1/entities — pre-seed before writing episodes | | getEntity(id) | GET /v1/entities/:id | | getEntityHistory(id, opts?) | GET /v1/entities/:id/history — bi-temporal timeline |

Edges | Method | Endpoint | |---|---| | relate(params) | POST /v1/edges — create a bi-temporal fact between entities | | getEdge(id) | GET /v1/edges/:id | | getRelatedEdges(id, opts?) | GET /v1/edges/:id/related — neighbors of a seed edge | | forget(id, params) | PATCH /v1/edges/:id/invalidate — mark an edge invalid at event time |

Playbooks | Method | Endpoint | |---|---| | listPlaybooks() | GET /v1/playbooks | | getPlaybook(id) | GET /v1/playbooks/:id | | regeneratePlaybook(scope) | POST /v1/playbooks/regenerate |

Examples — the 0.2.0 additions

// Pre-seed an entity, then create an explicit edge between two known ids.
const repo = await memoria.createEntity({ name: 'acme-web', type: 'repo' });
const tool = await memoria.createEntity({ name: 'vite', type: 'build_tool' });
const edge = await memoria.relate({
  fromEntityId: repo.id,
  toEntityId: tool.id,
  factText: 'acme-web uses vite',
  relationType: 'uses_build_tool',
  tValid: '2026-05-25T00:00:00Z',
});

// Time travel: timeline of edges that ever touched the entity
const { edges } = await memoria.getEntityHistory(repo.id, {
  asOf: '2026-05-01T00:00:00Z',
  limit: 20,
});

// Mark an edge as no longer valid as of an event time
await memoria.forget(edge.id, { tInvalid: '2026-06-15T00:00:00Z' });

// Trigger a playbook regenerate for a scope (branch, file, or sessionId)
await memoria.regeneratePlaybook({ branch: 'main' });

Errors

Errors throw typed subclasses you can catch and branch on:

| Class | When | |---|---| | MemoriaAuthError | 401 / 403 — invalid or missing API key | | MemoriaNotFoundError | 404 — entity / edge / episode / playbook doesn't exist | | MemoriaQuotaError | 429 — rate limited (read .retryAfter for the suggested backoff in seconds) | | MemoriaError | Everything else (.status + .code on the instance) |

import { MemoriaQuotaError } from '@premex/memoria';

try {
  await memoria.remember({ content: '...' });
} catch (err) {
  if (err instanceof MemoriaQuotaError) {
    await sleep((err.retryAfter ?? 1) * 1000);
    // retry
  } else {
    throw err;
  }
}

Configuration

new MemoriaClient({
  apiKey: 'mem_live_...',
  baseURL: 'https://api.memoria.premex.se', // override for self-hosted / staging
});

The baseURL defaults to Memoria's hosted API. Override for local dev (http://localhost:8787) or self-hosted deployments.

Versioning

This SDK follows SemVer. The 0.x series is API-stable for the methods listed above but may add new methods as the Memoria API expands. 1.0 ships when the surface is feature-complete.

Contributing

Issues and PRs welcome — see CONTRIBUTING.md once it lands. For now, the issue tracker is the right place to report bugs or request methods.

The Memoria server lives in a separate (currently private) monorepo. This SDK is a thin REST client and has no runtime dependencies.

License

MIT — see LICENSE.