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

cortexdbai

v0.2.0

Published

TypeScript SDK for CortexDB — The Long-Term Memory Layer for AI Systems

Downloads

62

Readme

@cortexdb/client

TypeScript SDK for CortexDB — The Long-Term Memory Layer for AI Systems.

Zero dependencies. Uses native fetch. Ships ESM + CJS with full TypeScript types.

Installation

npm install @cortexdb/client

Requires Node.js 18+ (native fetch support).

Quick Start

import { CortexDB } from "@cortexdb/client";

const cortex = new CortexDB({ baseUrl: "http://localhost:3141" });

// Store a memory
await cortex.remember("The deploy succeeded at 14:32 UTC.");

// Recall memories
const results = await cortex.recall("What happened with the deploy?");
console.log(results.matches);

Configuration

const cortex = new CortexDB({
  baseUrl: "http://localhost:3141", // default
  apiKey: "your-api-key",          // or set CORTEXDB_API_KEY env var
  timeout: 30000,                  // 30s default (milliseconds)
  maxRetries: 3,                   // retries on 429, 502, 503, 504
});

API Reference

Core Methods

remember(content, tenantId?, scope?, metadata?)

Store a piece of information.

const resp = await cortex.remember("Deploy v2.1 went live", "my-tenant", "deploys", {
  environment: "production",
});
// { id: "...", status: "stored" }

recall(query, tenantId?, maxTokens?, minConfidence?)

Retrieve relevant memories matching a query.

const results = await cortex.recall("latest deploy status", "my-tenant", 4096, 0.5);
for (const match of results.matches) {
  console.log(`[${match.confidence}] ${match.content}`);
}

forget(query?, reason?, tenantId?)

Delete memories matching a query.

const resp = await cortex.forget("old deploy logs", "Data retention policy", "my-tenant");
// { deleted: 12, status: "completed" }

ingestEpisode(episode)

Ingest a structured episode.

import { EpisodeType } from "@cortexdb/client";

const resp = await cortex.ingestEpisode({
  content: "PR #142 merged by alice",
  tenantId: "my-tenant",
  type: EpisodeType.EVENT,
  actor: { id: "alice", name: "Alice", type: "human" },
  source: { system: "github" },
  metadata: { pr: 142 },
});

listEpisodes(tenantId?, offset?, limit?)

List episodes with pagination.

const page = await cortex.listEpisodes("my-tenant", 0, 25);
console.log(`${page.total} episodes total`);

health()

Check server health.

const h = await cortex.health();
// { status: "healthy", version: "0.1.0", uptimeSeconds: 3600 }

metrics()

Retrieve server metrics.

const m = await cortex.metrics();
console.log(`${m.episodeCount} episodes, ${m.storageBytes} bytes`);

Knowledge Graph Methods

entity(entityId, tenantId?)

Get detailed information about an entity.

const e = await cortex.entity("user:alice", "my-tenant");
console.log(e.relationships);

link(sourceEntityId, targetEntityId, relationship, fact?, confidence?, tenantId?)

Create a relationship between entities.

const resp = await cortex.link(
  "service:payments",
  "service:auth",
  "DEPENDS_ON",
  "Payments calls auth for token validation",
  0.95,
  "my-tenant",
);

search(query, filters?, limit?, offset?, tenantId?)

Search with filters.

const results = await cortex.search(
  "payment failures",
  { source: "slack", timeRange: "24h" },
  20,
  0,
  "my-tenant",
);

Convenience Methods

memory(query) — alias for recall

const results = await cortex.memory("why did checkout fail yesterday");

store(data) — smart dispatch

// String -> remember()
await cortex.store("The deploy succeeded.");

// Object -> ingestEpisode()
await cortex.store({
  content: "Deploy OK",
  type: "event",
  source: "ci",
  actor: "deploy-bot",
});

context(query, agentId?, tenantId?, maxTokens?) — recall with higher budget

const ctx = await cortex.context("current status of payments", "incident-bot");
// Uses 8192 max tokens by default

Cancellation

All methods accept an optional AbortSignal as the last parameter:

const controller = new AbortController();
setTimeout(() => controller.abort(), 5000);

const results = await cortex.recall("query", "default", 4096, 0.0, controller.signal);

Error Handling

import {
  CortexAPIError,
  CortexAuthError,
  CortexConnectionError,
  CortexRateLimitError,
  CortexTimeoutError,
} from "@cortexdb/client";

try {
  await cortex.recall("test");
} catch (err) {
  if (err instanceof CortexRateLimitError) {
    console.log(`Rate limited. Retry after ${err.retryAfter}s`);
  } else if (err instanceof CortexAuthError) {
    console.log(`Auth failed: ${err.message}`);
  } else if (err instanceof CortexTimeoutError) {
    console.log(`Request timed out`);
  } else if (err instanceof CortexConnectionError) {
    console.log(`Cannot connect to server`);
  } else if (err instanceof CortexAPIError) {
    console.log(`API error ${err.statusCode}: ${err.message}`);
  }
}

License

MIT