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

@khareindustries/synapse-sdk

v0.1.3

Published

JavaScript SDK for Synapse memory infrastructure

Downloads

485

Readme

README.md



Synapse currently focuses on self-hosted and developer-operated memory infrastructure for AI applications.


Why Synapse?

Most AI applications still forget users between conversations.

Developers often need to manually build:

  • embedding pipelines
  • vector databases
  • semantic retrieval systems
  • reranking
  • memory persistence
  • context injection
  • long-term memory orchestration

Synapse provides a unified memory infrastructure layer for AI systems.

The goal is to make persistent AI memory:

  • scalable
  • developer-friendly
  • composable
  • production-ready
  • low-latency

Automatic Memory Injection

const openai = synapse.wrap(
  new OpenAI({
    apiKey: process.env.OPENAI_API_KEY,
  }),
  {
    namespace: "medical-app",
    userId: "user-123",
  }
);

await openai.chat.completions.create({
  model: "gpt-4o",
  messages: [
    {
      role: "user",
      content: "my stomach hurts",
    },
  ],
});

Synapse automatically:

  • retrieves relevant memories
  • formats memory context
  • injects context into prompts
  • ingests assistant responses
  • persists long-term memory

No manual prompt engineering required.


Demo

🎥 Full introduction video coming soon.


Features

| Feature | Status | | ----------------------------- | ------ | | Semantic memory retrieval | ✅ | | Long-term memory storage | ✅ | | Redis working memory | ✅ | | Vector retrieval | ✅ | | Reranking pipelines | ✅ | | Prompt-ready context building | ✅ | | Automatic message injection | ✅ | | AI client wrapping | ✅ | | Memory update APIs | ✅ | | Memory deletion APIs | ✅ | | TypeScript SDK | ✅ | | API authentication | ✅ | | Self-hosted architecture | ✅ | | Hosted Synapse Cloud | 🚧 | | LangChain integration | 🚧 | | OpenAI Agents SDK integration | 🚧 | | Vercel AI SDK integration | 🚧 | | Dashboard & analytics | 🚧 |


Architecture

Synapse combines:

  • semantic embeddings
  • vector search
  • reranking pipelines
  • Redis working memory
  • long-term vector storage
  • retrieval optimization
  • memory orchestration

to provide persistent contextual memory for AI systems.


Memory Pipeline

retrieve()
  ↓
buildContext()
  ↓
inject()
  ↓
wrap()

Synapse is designed around composable memory primitives.

Developers can:

  • use low-level retrieval APIs
  • inject memory manually
  • or fully automate memory workflows using wrap()

Installation

npm install @khareindustries/synapse-sdk

Quick Start

import {
  createSynapseClient,
} from "@khareindustries/synapse-sdk";

const synapse = createSynapseClient({
  apiUrl: "http://localhost:3000/api/developer",
  apiKey: process.env.SYNAPSE_API_KEY,
});

async function main() {
  await synapse.ingest({
    namespace: "career-coach-app",
    userId: "user-123",
    source: "chat",
    content:
      "I am preparing for React Native interviews and targeting Bangalore startups.",
    metadata: {
      app: "career-coach",
      sessionId: "sess_abc123",
    },
  });

  const memory =
    await synapse.retrieve({
      namespace: "career-coach-app",
      userId: "user-123",
      query: "Help optimize my resume",
    });

  console.log(memory.summary);
  console.log(memory.memories);
}

main();

More local examples live in sdk/examples/:

  • basic.ts for direct ingest/retrieve usage
  • openai-wrap.ts for automatic OpenAI chat memory injection
  • claude-wrap.ts for Anthropic Claude message wrapping
  • gemini-wrap.ts for Google Gemini content generation wrapping

Core APIs

createSynapseClient()

Creates a Synapse SDK client.

const synapse = createSynapseClient({
  apiUrl: string,
  apiKey?: string,
  timeout?: number,
});

| Option | Type | Required | Description | | ------- | ------ | -------- | ------------------------------- | | apiUrl | string | Yes | Synapse server URL | | apiKey | string | No | API authentication key | | timeout | number | No | Request timeout in milliseconds |


synapse.ingest()

Stores memories into Synapse.

await synapse.ingest({
  namespace: "app-name",
  userId: "user-123",
  content: "User likes React Native",
});

synapse.retrieve()

Retrieves relevant memories semantically.

const result =
  await synapse.retrieve({
    namespace: "app-name",
    userId: "user-123",
    query: "What technologies does user like?",
  });

synapse.buildContext()

Formats retrieved memories into a prompt-ready string.

const context =
  await synapse.buildContext({
    namespace: "medical-app",
    userId: "user-123",
    query: "my stomach hurts",
    maxTokens: 120,
  });

synapse.inject()

Injects memory context into an OpenAI-style messages array.

const messages =
  await synapse.inject({
    namespace: "medical-app",
    userId: "user-123",
    messages: [
      {
        role: "user",
        content: "my stomach hurts",
      },
    ],
  });

synapse.wrap()

Wraps OpenAI and Anthropic clients with automatic memory orchestration.

const openai = synapse.wrap(
  new OpenAI({
    apiKey: process.env.OPENAI_API_KEY,
  }),
  {
    namespace: "medical-app",
    userId: "user-123",
  }
);

await openai.chat.completions.create({
  model: "gpt-4o",
  messages: [
    {
      role: "user",
      content: "my stomach hurts",
    },
  ],
});

Supported wrapped methods:

  • openai.chat.completions.create(...)
  • anthropic.messages.create(...)

After responses return, Synapse automatically ingests assistant messages into long-term memory.


Provider Helpers

For explicit provider integrations, Synapse also exposes dedicated wrappers:

const openai = synapse.wrapOpenAI(client, options);
const claude = synapse.wrapClaude(client, options);
const anthropic = synapse.wrapAnthropic(client, options);
const gemini = synapse.wrapGemini(client, options);

Current provider method support:

  • wrapOpenAI() wraps chat.completions.create(...)
  • wrapClaude() and wrapAnthropic() wrap messages.create(...)
  • wrapGemini() wraps models.generateContent(...)

synapse.updateMemory()

Updates an existing memory.

await synapse.updateMemory({
  namespace: "app-name",
  userId: "user-123",
  memoryId: "mem_123",
  text: "User prefers React Native with Expo",
});

synapse.deleteMemory()

Deletes an outdated or incorrect memory.

await synapse.deleteMemory({
  namespace: "app-name",
  userId: "user-123",
  memoryId: "mem_123",
});

Example Response

{
  "success": true,
  "summary": "User is preparing for React Native interviews.",
  "memories": [
    {
      "id": "mem_123",
      "text": "User is preparing for React Native interviews.",
      "category": "career",
      "importance": 0.92
    }
  ]
}

Error Handling

try {
  await synapse.retrieve({
    namespace: "app",
    userId: "123",
    query: "React Native",
  });
} catch (error) {
  console.error(error);
}

Requirements

  • Node.js 18+
  • Running Synapse backend server

Roadmap

  • [x] Semantic retrieval
  • [x] TypeScript SDK
  • [x] Local infrastructure
  • [x] Prompt-ready context building
  • [x] Automatic memory injection
  • [x] AI client wrapping
  • [x] Memory update APIs
  • [x] Memory deletion APIs
  • [ ] Hosted Synapse Cloud
  • [ ] Streaming retrieval
  • [ ] LangChain integration
  • [ ] Vercel AI SDK integration
  • [ ] Memory importance scoring
  • [ ] Structured memory extraction
  • [ ] Memory observability & debugging
  • [ ] Dashboard & analytics
  • [ ] Multi-agent memory systems
  • [ ] Agent memory graphs
  • [ ] Memory visualization tools

Community


License

MIT License