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

@threadbase/js

v0.0.2

Published

Official Threadbase SDK for TypeScript/JavaScript

Downloads

19

Readme

@threadbase/JS

Official TypeScript/JavaScript SDK for Threadbase

Threadbase is a developer-first memory intelligence tracing layer for LLM-powered applications.

This SDK lets you Track, debug, and version what your AI Agent remembers, and detect whether memory was actually used—without modifying your LLM runtime.

Use it to gain full visibility into how your agents think, recall, and behave across sessions.


📦 Features

  • 📊 Trace logging for every user-agent interaction
  • 🧠 Memory tracking across sessions and versions
  • 🔍 Insightful diffs between memory states
  • 📚 Session-based trace retrieval
  • 🔧 Metadata and tool usage annotation
  • ⚡ Simple, fast, and fully typed API

🚀 Installation

Install via your preferred package manager:

npm install @threadbase/js
# or
yarn add @threadbase/js

🛠️ Quick Start

import { ThreadbaseClient } from '@threadbase/js';

// Initialize the Threadbase client
const client = new ThreadbaseClient({
  apiKey: 'your-api-key', // required
  baseUrl: 'https://api.threadbase.dev' // optional
});

// Example 1: Create a trace with implicit memory usage
const trace1 = await client.trace({
  user_id: '555',
  agent_id: '8a219d38-3d88-48b3-969e-adf8ede035e1',
  session_id: '99949',
  user_prompt: 'Where should I go next weekend?',
  agent_response: 'Since you like hiking, you might enjoy Banff National Park.',
  memory: null
});

// Example 2: Create a trace with explicit memory injection
const trace2 = await client.trace({
  user_id: 'user_555',
  agent_id: '8a219d38-3d88-48b3-969e-adf8ede035e1',
  session_id: 'session_99949',
  user_prompt: 'I changed my mind — I prefer beach vacations now.',
  agent_response: 'Got it. I'll update your preferences to beach destinations like Maldives.',
  memory: {
    preference: 'beach vacations'
  }
});

📘 API Reference

new ThreadbaseClient(config)

new ThreadbaseClient({
  apiKey: string;       // required
  baseUrl?: string;     // optional
});

| Option | Type | Required | Description | |------------|----------|----------|---------------------------------| | apiKey | string | ✅ | Your Threadbase API key | | baseUrl | string | ❌ | Override the API base URL |


trace(options): Promise<TraceResponse>

Create a new trace.

Required fields:

  • agent_id (string)
  • user_id (string)
  • session_id (string)
  • user_prompt (string)
  • agent_response (string)

Optional fields:

  • trace_type (string)
  • tools_used (string[])
  • metadata (Record<string, any>)
  • memory (Record<string, any> | null)

getTraceById(id: string): Promise<TraceResponse>

Fetch a trace by its unique ID.


getTracesBySession(sessionId: string, page?: number, limit?: number): Promise<TraceResponse>

Get all traces for a session, with optional pagination.


getMemoryDiff(sessionId: string, fromVersion: number, toVersion: number): Promise<TraceResponse>

Get the difference between two memory versions in a session.

Example:

// Get memory changes between versions 10 and 11
const diff = await client.getMemoryDiff('99949', 10, 11);

Response:

{
    "meta": {
        "statusCode": 200,
        "message": "Success"
    },
    "data": {
        "added": {},
        "removed": {},
        "changed": {
            "implicit": {
                "from": {
                    "user_interest": "hiking"
                },
                "to": {}
            },
            "injected": {
                "from": {},
                "to": {
                    "preference": "beach vacations"
                }
            }
        },
        "final": {
            "implicit": {},
            "injected": {
                "preference": "beach vacations"
            }
        }
    }
}

The response shows:

  • added: New memory entries added
  • removed: Memory entries removed
  • changed: Memory entries that were modified, showing both the old (from) and new (to) values
  • final: The final state of the memory after all changes

getMemoriesBySession(sessionId: string): Promise<TraceResponse>

Retrieve all memory payloads associated with a session.


🧠 Example Responses

Example 1: Implicit Memory Usage

{
  "meta": {
    "statusCode": 201,
    "message": "Success"
  },
  "data": {
    "trace": {
      "id": "b47748bf-5b61-47fb-9b9b-c9d22578afbe",
      "llm_summary": "The user asked for a recommendation for next weekend, and the agent suggested Banff National Park based on the user's interest in hiking.",
      "possible_issue": null,
      "memory_injected_used": false,
      "memory_implicit_used": true,
      "memory": [
        {
          "payload": {
            "implicit": {
              "user_interest": "hiking"
            },
            "injected": {}
          },
          "version": 10
        }
      ],
      "agent": {
        "id": "8a219d38-3d88-48b3-969e-adf8ede035e1",
        "name": "chatgpt",
        "model": "4o"
      }
    }
  }
}

Example 2: Explicit Memory Injection

{
  "meta": {
    "statusCode": 201,
    "message": "Success"
  },
  "data": {
    "trace": {
      "id": "ee448b99-55ce-4745-91fb-b5c21e2e0b4d",
      "llm_summary": "The user updated their vacation preference from hiking to beach vacations, which the agent acknowledged and adjusted accordingly.",
      "possible_issue": "The previous memory indicating a user interest in hiking was not addressed or acknowledged, which may lead to confusion if the user has not completely abandoned that interest.",
      "error": null,
      "memory_injected_used": true,
      "memory_implicit_used": false,
      "memory": [
        {
          "payload": {
            "implicit": {},
            "injected": {
              "preference": "beach vacations"
            }
          },
          "version": 11
        }
      ],
      "agent": {
        "id": "8a219d38-3d88-48b3-969e-adf8ede035e1",
        "name": "chatgpt",
        "model": "4o"
      }
    }
  }
}

📄 License

MIT — feel free to use, modify, and contribute!


🤝 Contributing

We welcome issues, feature requests, and pull requests. If you have feedback or ideas, please open an issue or submit a PR.


📫 Support

Need help? Join our community or contact us at [email protected]