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

@maximem/synap-js-sdk

v0.4.8

Published

Native TypeScript SDK for Synap context and memory management

Readme

@maximem/synap-js-sdk

Native TypeScript SDK for Synap context and memory management.

No Python required. 0.4 replaced the Python-subprocess bridge with a native client. Upgrading from 0.3.x? See MIGRATING.md.

Install

npm install @maximem/synap-js-sdk

Requires Node.js 20+. That is the whole installation. There is no setup command, and TypeScript needs no extra step: types ship in the package.

Verified against TypeScript 5.7 and 7.0 with moduleResolution set to node, node16, nodenext and bundler.

Quick start

import { SynapClient } from '@maximem/synap-js-sdk';

const client = new SynapClient({ apiKey: process.env.SYNAP_API_KEY });

// Store
await client.memories.create({
  document: 'The user prefers aisle seats on long-haul flights.',
  user_id: 'user-123',
  // Optional. Defaults to 'ai-chat-conversation'. It selects the extraction
  // path, so setting it wrongly stores less from the same text.
  document_type: 'ai-chat-conversation',
});

// Retrieve
const context = await client.user.context.fetch({
  user_id: 'user-123',
  search_query: ['seat preference'],
});

await client.shutdown();

Scopes

Scopes are client > customer > user. A narrower request also matches broader-scope memories.

await client.user.context.fetch({ user_id, customer_id });
await client.customer.context.fetch({ customer_id });
await client.client.context.fetch({});

conversation_id is not a scope tier. It groups turns within a scope, and narrows a fetch rather than selecting a different one.

Errors

Every error carries a stable .code. Branch on that rather than on the class, because a dual ESM/CJS dependency graph can hand you two copies of the same class:

import { isSynapError } from '@maximem/synap-js-sdk';

try {
  await client.memories.create({ document, user_id });
} catch (e) {
  if (!isSynapError(e)) throw e;
  switch (e.code) {
    case 'insufficient_credits': /* top up */ break;
    case 'rate_limit':           /* e.retryAfterSeconds */ break;
    case 'authentication':       /* bad key */ break;
    default: throw e;
  }
}

Transient errors are retried automatically. Ingestion is deliberately not retried when a failure leaves the outcome unknown, because a retry would store and bill twice.

Runtime support

| Runtime | HTTP context + memories | gRPC anticipation stream | |---|---|---| | Node.js 20+ | Yes | Yes (opt-in) | | Bun | Yes | Unverified | | Deno 2 | Yes | Unverified | | Vercel Edge | Yes | No | | Cloudflare Workers | Yes | No | | Browser | Yes (do not ship an API key) | No |

Edge and Workers cannot run gRPC at all: it needs raw TCP and node:http2, which they do not provide. Bun and Deno have both, so gRPC is plausible on each, but bidirectional streaming has not been tested there, so those cells stay unverified rather than claimed either way.

Importing the SDK on Edge is safe: gRPC lives behind the @maximem/synap-js-sdk/grpc subpath and is only ever loaded lazily.

Configuration

| Option | Default | Notes | |---|---|---| | apiKey | SYNAP_API_KEY | Required. | | clientId | SYNAP_CLIENT_ID | Skips a whoami round trip. | | baseUrl | prod | | | heartbeat | false | Keeps the connection warm. Worth it for a long-lived process, pointless in serverless. | | timeouts | 5s connect / 30s read | | | retryPolicy | 3 attempts | |

Environment flags are read at call time, so you can toggle them at runtime: SYNAP_SDK_CACHE_RECALL_BYPASS, SYNAP_SDK_CACHE_HONOR_TTL_HINT, SYNAP_SDK_CACHE_INVALIDATE_ON_WRITE, SYNAP_SDK_CACHE_COVERAGE_MIN, SYNAP_SDK_CACHE_MAX_ENTRY_AGE.

Development

npm install
npm test
npm run build
npm run typecheck
npm run sync-behavior   # after changing synap/sdk/CONTRACT/**

Retrieval behavior (recall-bypass patterns, BM25 thresholds, the stemmer) is not defined in this package. It lives in synap/sdk/CONTRACT/, shared byte-identically with the Python SDK, and both SDKs run the same conformance corpus. Never edit the vendored copy in src/behavior/.