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

@kybernesis/brain-core

v0.20.0

Published

Kernel brain methods — timeline, entity-graph, facts, vectors, retrieval, sleep

Readme

@kybernesis/brain-core

npm

The kernel of the Cortex brain library — timeline, entity-graph, facts, vectors, retrieval, and sleep. This is the package you call; the others are the swappable backends it runs on.

brain-core is programmed against the interfaces in @kybernesis/brain-contracts and has no built-in backend. Wire the provider seams once at startup, then call the kernel methods.

Install

pnpm add @kybernesis/brain-core @kybernesis/brain-storage-sqlite @kybernesis/brain-storage-vec

Usage

import { createSqliteStorageProvider } from '@kybernesis/brain-storage-sqlite';
import { createOpenAIEmbedder }        from '@kybernesis/brain-embed-openai';
import {
  setStorageProvider, setEmbeddingProvider,
  addConversationToTimeline, hybridSearch, getEntityContext,
} from '@kybernesis/brain-core';

setStorageProvider(createSqliteStorageProvider());  // required — persistence
setEmbeddingProvider(createOpenAIEmbedder());        // optional — semantic recall

await addConversationToTimeline(tenant, 'c-1', 'chat.md',
  '2026-06-06T09:00:00Z', undefined, 'Q3 roadmap', /* …turns… */);

await hybridSearch(tenant, 'what did we decide about Q3?');
await getEntityContext(tenant, 'Ada');

Prefer one object per brain? Wrap a tenant once with createLocalBrainProvider — a bound-tenant facade over the same operations, so you don't thread tenant through every call:

import { createLocalBrainProvider } from '@kybernesis/brain-core';

const brain = createLocalBrainProvider(tenant);
await brain.remember({ prompt, response, channel: 'chat' });
await brain.query('what did we decide about Q3?');
await brain.graph();
await brain.stats();

The three seams

The kernel is wired through three module-level setters. Each degrades gracefully when unset.

| Seam | Setter | Provider | Powers | |---|---|---|---| | Storage | setStorageProvider() | brain-storage-sqlite | All persistence (required) | | Embedding | setEmbeddingProvider() | brain-embed-openai | Vector indexing + semantic recall | | LLM | setLLMProvider() | brain-llm-claude | Extraction, contradiction detection, profiles, sleep reasoning |

→ See Architecture — the provider seams.

What it exposes

A flat set of async functions over a TenantContext, grouped by subsystem:

  • TimelineaddToTimeline, addConversationToTimeline, queryTimeline, searchTimeline, getRecentActivity, …
  • Entity graphfindOrCreateEntity, linkEntities, getEntityContext, mergeEntities, getTypedRelationships, …
  • FactsstoreFact, retractFact, reinforceFact, searchFactsFts, factFirstSearch, …
  • VectorsindexChunk, semanticSearch, vectorStats (need the embedding seam).
  • RetrievalhybridSearch, factFirstSearch, formatRecall.
  • SleeprunSleepCycleNow, recoverStaleSleepRuns (background consolidation/reasoning).
  • BrainProvider facadecreateLocalBrainProvider(t) returns a bound-tenant BrainProvider (Layer-2, ADR-0016): the same operations as one async object, with no TenantContext threaded per call. The high-level seam a future remote provider also implements.

All schemas, field shapes, and constants come from @kybernesis/brain-contracts.

Notes

  • ESM-only, TypeScript strict. TenantContext describes where one brain's files live — build it with pathsFor(slug, homeDir) from brain-contracts.
  • brain-storage-vec is a peer dependency: the SQLite provider lazy-loads it for the vector store, so install it alongside if you index vectors.
  • Part of Cortex@kybernesis/brain-*.