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

@hivemagnus/hivemem-sdk

v1.0.3

Published

TypeScript client for HiveMem, the shared long-term memory service for AI agents

Readme

@hivemagnus/hivemem-sdk

TypeScript client for HiveMem, the shared long-term memory service for AI agents. It wraps the HiveMem REST API with typed helpers for memories, search, sessions, prompt context, peer cards, conclusions, queue operations, and webhooks.

  • Zero runtime dependencies; uses the platform fetch (Node.js 18.17+, Deno, Bun, browsers, edge runtimes).
  • ESM-only, with bundled type declarations.
  • Retries 5xx responses, supports request timeouts, request IDs, and token refresh hooks.

Install

npm install @hivemagnus/hivemem-sdk

You need a running HiveMem server and an agent token. See the HiveMem README for how to run the server and register an agent.

Quick start

import { HiveMem } from "@hivemagnus/hivemem-sdk";

const hivemem = new HiveMem({
  baseUrl: "https://memory.example.com", // or set HIVEMEM_API_URL
  token: process.env.HIVEMEM_TOKEN,
  workspaceId: "default",
});

// Store a memory. HiveMem embeds the text server-side.
await hivemem.createMemory({
  content: "The user prefers direct status summaries.",
  type: "semantic",
  scope: "private",
  tags: ["preference"],
});

// Search with score explanations.
const results = await hivemem.searchMemories("status summary preferences", { limit: 5 }, { explain: true });

// Build a token-budgeted, source-cited prompt context and hand it to your model.
const context = await hivemem.context({ tokens: 2000, search_query: "current project" });
const messages = context.toOpenAI(); // or context.toAnthropic()

Configuration

| Option | Environment fallback | Default | | --- | --- | --- | | baseUrl | HIVEMEM_API_URL | http://localhost:18790 | | token | HIVEMEM_TOKEN, then HIVEMEM_MCP_TOKEN | none | | workspaceId | HIVEMEM_WORKSPACE_ID | default | | timeoutMs | | 30000 | | maxRetries | | 2 (5xx responses only) | | fetchImpl | | global fetch | | requestIdProvider | | sends X-Request-ID when set | | authRefresh | | called before each attempt; a returned token replaces the current one | | onRequest / onResponse | | observability hooks |

Explicit constructor options win over environment variables. Environment variables are only read where process.env exists.

Common operations

// Memories
const memory = await hivemem.getMemory(id);
const original = await hivemem.getMemory(oldId, { includeHistory: true }); // superseded/retired versions
await hivemem.browseMemories({ limit: 20 });

// Sessions and session-scoped context
const session = await hivemem.createSession({ session_id: "chat-42" });
const sessionContext = await hivemem.sessionContext("chat-42", { search_query: "open questions" });

// Peer cards and conclusions
const card = await hivemem.getPeerCard("user");
const page = await hivemem.listConclusionsPage("user", { limit: 50 });
const next = page.next_cursor ? await hivemem.listConclusionsPage("user", { limit: 50, cursor: page.next_cursor }) : null;
const conclusion = await hivemem.getConclusion(conclusionId, { includeHistory: true });

// Idempotent background operations
const job = await hivemem.getQueueOperation("nightly-2026-01-01", "consolidation");

// Knowledge sources
await hivemem.syncKnowledgeSource({ mode: "preview", project_id: "docs", source_id: "repo:docs", source_uri: "repo://docs", revision: "abc123", observed_at: new Date().toISOString(), chunks: [] });

Errors

Non-2xx responses throw HiveMemHTTPError with statusCode, the server's detail as message, and the parsed body as details. All SDK errors extend HiveMemError.

import { HiveMemHTTPError } from "@hivemagnus/hivemem-sdk";

try {
  await hivemem.getMemory("missing");
} catch (error) {
  if (error instanceof HiveMemHTTPError && error.statusCode === 404) {
    // not found or not visible to this agent
  }
}

Verifying webhooks

HiveMem signs webhook deliveries with HMAC-SHA256. Verify them before trusting the payload:

import { verifyHiveMemWebhook } from "@hivemagnus/hivemem-sdk";

const ok = await verifyHiveMemWebhook({
  secret: process.env.HIVEMEM_WEBHOOK_SECRET!,
  body: rawBody, // the exact bytes received
  signature: headers["x-hivemem-signature"],
  timestamp: headers["x-hivemem-timestamp"],
  nonce: headers["x-hivemem-nonce"],
  seenNonces, // optional Set<string> for replay protection
});

License

Apache-2.0. See LICENSE.