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

@gustycube/membrane

v0.1.4

Published

TypeScript client for the Membrane memory substrate

Downloads

59

Readme

Membrane TypeScript Client

TypeScript/Node SDK for the Membrane memory substrate.

Communicates with the Membrane daemon over gRPC using the protobuf service contract.

Installation

npm install @gustycube/membrane

Quick Start

import { MembraneClient, Sensitivity } from "@gustycube/membrane";

const client = new MembraneClient("localhost:9090", {
  apiKey: "your-api-key"
});

const record = await client.ingestEvent("file_edit", "src/main.ts", {
  summary: "Refactored auth middleware",
  sensitivity: Sensitivity.LOW,
  tags: ["auth", "typescript"]
});

const records = await client.retrieve("debug auth", {
  trust: {
    max_sensitivity: Sensitivity.MEDIUM,
    authenticated: true,
    actor_id: "agent-1",
    scopes: []
  },
  limit: 10
});

console.log(record.id, records.length);
client.close();

API Surface

The SDK mirrors the Python client behavior and defaults.

Ingestion

  • ingestEvent(...) / ingest_event(...)
  • ingestToolOutput(...) / ingest_tool_output(...)
  • ingestObservation(...) / ingest_observation(...)
  • ingestOutcome(...) / ingest_outcome(...)
  • ingestWorkingState(...) / ingest_working_state(...)

Retrieval

  • retrieve(...)
  • retrieveById(...) / retrieve_by_id(...)

Revision

  • supersede(...)
  • fork(...)
  • retract(...)
  • merge(...)
  • contest(...)

Reinforcement

  • reinforce(...)
  • penalize(...)

Metrics

  • getMetrics() / get_metrics()

TLS and Authentication

const client = new MembraneClient("membrane.example.com:443", {
  tls: true,
  tlsCaCertPath: "/path/to/ca.pem",
  apiKey: "your-api-key",
  timeoutMs: 10_000
});

LLM Integration Pattern

The common runtime pattern is: ingest execution traces, retrieve relevant memory, then pass that context into your model call.

import OpenAI from "openai";
import { MembraneClient, Sensitivity } from "@gustycube/membrane";

const memory = new MembraneClient("localhost:9090", {
  apiKey: process.env.MEMBRANE_API_KEY
});

const llm = new OpenAI({
  apiKey: process.env.LLM_API_KEY,
  // For OpenRouter or other OpenAI-compatible providers:
  // baseURL: "https://openrouter.ai/api/v1",
});

const records = await memory.retrieve("how should I handle this incident?", {
  trust: {
    max_sensitivity: Sensitivity.MEDIUM,
    authenticated: true,
    actor_id: "incident-agent",
    scopes: ["prod"],
  },
  memoryTypes: ["semantic", "competence", "working"],
  limit: 10,
});

const memoryContext = records.map((r) => JSON.stringify(r)).join("\n");

const completion = await llm.chat.completions.create({
  model: "gpt-5.2",
  messages: [
    { role: "system", content: "Use the memory context as evidence. Cite record ids." },
    { role: "user", content: `Incident task:\n...\n\nMemory:\n${memoryContext}` },
  ],
});

console.log(completion.choices[0]?.message?.content);
memory.close();

Development

cd clients/typescript
npm install
npm run check:proto-sync
npm run typecheck
npm test
npm run build

Proto Sync

The SDK keeps a local proto copy in clients/typescript/proto/.

npm run sync:proto
npm run check:proto-sync

Requirements

  • Node.js 20+
  • A running Membrane daemon (default: localhost:9090)