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

@basekick-labs/memtrace-sdk

v0.2.0

Published

TypeScript SDK for Memtrace — LLM-agnostic memory layer for AI agents

Readme

Memtrace TypeScript SDK

TypeScript/Node.js client for Memtrace — LLM-agnostic memory layer for AI agents.

Installation

npm install @basekick-labs/memtrace-sdk

Quick Start

import { Memtrace } from '@basekick-labs/memtrace-sdk'

const client = new Memtrace('http://localhost:9100', 'mtk_your_api_key')

// Store a memory
await client.remember('agent_1', 'User prefers dark mode')

// Recall recent memories
const memories = await client.recall('agent_1', '24h')
for (const m of memories.memories) {
  console.log(`[${m.time}] ${m.content}`)
}

// Log a decision
await client.decide('agent_1', 'Use PostgreSQL', 'Better JSON support for metadata')

Full API

Memory Operations

import { Memtrace } from '@basekick-labs/memtrace-sdk'

const client = new Memtrace('http://localhost:9100', 'mtk_...')

// Add a single memory with full control
const mem = await client.addMemory({
  agent_id: 'agent_1',
  session_id: 'sess_1',
  memory_type: 'episodic',
  event_type: 'observation',
  content: 'User clicked the settings button',
  tags: ['ui', 'navigation'],
  importance: 0.7,
})

// Add multiple memories in a batch
const memories = await client.addMemories([
  { agent_id: 'agent_1', memory_type: 'episodic', event_type: 'general', content: 'First' },
  { agent_id: 'agent_1', memory_type: 'episodic', event_type: 'general', content: 'Second' },
])

// List with filters
const result = await client.listMemories({
  agent_id: 'agent_1',
  memory_type: 'decision',
  since: '7d',
  limit: 50,
  order: 'desc',
})

// Search with structured query
const searchResult = await client.searchMemories({
  agent_id: 'agent_1',
  memory_types: ['episodic', 'decision'],
  content_contains: 'dark mode',
  min_importance: 0.5,
})

Agent Management

import { Memtrace } from '@basekick-labs/memtrace-sdk'

const client = new Memtrace('http://localhost:9100', 'mtk_...')

// Register an agent
const agent = await client.registerAgent({
  name: 'my-agent',
  description: 'Handles customer support',
  config: { model: 'gpt-4' },
})

// Get agent details
const fetched = await client.getAgent('agent_1')

// Get agent memory stats
const stats = await client.getAgentStats('agent_1')
console.log(`Total memories: ${stats.memory_count}`)
console.log(`Active sessions: ${stats.active_sessions}`)

Session Management

import { Memtrace } from '@basekick-labs/memtrace-sdk'

const client = new Memtrace('http://localhost:9100', 'mtk_...')

// Create a session
const session = await client.createSession({
  agent_id: 'agent_1',
  metadata: { task: 'onboarding' },
})

// Get LLM-formatted context
const ctx = await client.getSessionContext(session.id, {
  since: '2h',
  include_types: ['episodic', 'decision'],
  max_tokens: 4000,
})
console.log(ctx.context) // Markdown-formatted for LLM consumption

// List sessions (optionally filtered by agent)
const all = await client.listSessions()
const forAgent = await client.listSessions('agent_1')

// Close the session
await client.closeSession(session.id)

Multi-tenant Deployments

A Memtrace deployment can serve multiple organizations, each routed to its own Arc instance. The SDK is unchanged — you still pass (baseURL, apiKey). Memtrace looks up the organization that owns your API key and forwards reads and writes to that org's Arc instance automatically.

To work against a different org, ask an administrator to run memtrace org create and memtrace key create --org <org_id>, then use that key with the same SDK call.

If a key is bound to an org that has no Arc instance configured yet, requests reject with NoArcInstanceError (see Error Handling below).

Error Handling

import {
  Memtrace,
  MemtraceError,
  AuthenticationError,
  NotFoundError,
  ConflictError,
  NoArcInstanceError,
} from '@basekick-labs/memtrace-sdk'

const client = new Memtrace('http://localhost:9100', 'mtk_...')

try {
  const agent = await client.getAgent('nonexistent')
} catch (e) {
  if (e instanceof NotFoundError) {
    console.log('Agent not found')
  } else if (e instanceof AuthenticationError) {
    console.log('Invalid API key')
  } else if (e instanceof ConflictError) {
    console.log('Duplicate resource')
  } else if (e instanceof NoArcInstanceError) {
    // Caller's org has no Arc instance configured. An admin must run
    // `memtrace org add-arc <org_id>`. Until then every read/write is 503.
    console.log('Memtrace is not provisioned for this org yet')
  } else if (e instanceof MemtraceError) {
    console.log(`API error (${e.statusCode}): ${e.message}`)
  }
}

Configuration

const client = new Memtrace('http://localhost:9100', 'mtk_...', {
  timeout: 10_000, // Request timeout in ms (default: 30000)
})

Requirements

  • Node.js >= 18 (uses native fetch)
  • Zero runtime dependencies

Development

cd sdks/typescript
npm install
npm run build
npm test

License

MIT