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

cogspace

v0.5.4

Published

Official Cogspace SDK — add a knowledge layer to any AI agent

Readme

cogspace

Official TypeScript SDK for Cogspace — persistent knowledge layer for AI agents.

Available on npm as cogspace — the same package name as the Python SDK.

Install

npm install cogspace
# or
pnpm add cogspace
# or
bun add cogspace

Quickstart

import { Cogspace } from "cogspace";

// Reads COGSPACE_API_KEY from environment automatically
const cog = new Cogspace();
const space = await cog.space("my-agent");

// See what exists
const files = await space.list("expertise");
console.log(`${files.file_count} files`);

// Add knowledge
await space.add(
  "expertise/retry.md",
  "# Retry Patterns\nUse exponential backoff with jitter.",
  "expertise",
  "retry-patterns",
  { confidence: 0.95 }
);

// Search (vectors + BM25 + knowledge graph, per-source limits)
const results = await space.searchHybrid("retry logic", {
  vector_limit: 10,  // max vector results
  bm25_limit: 10,    // max keyword results
  kg_limit: 5,       // max graph neighbors per result
});
for (const item of results.results) {
  console.log(`${item.file_path}: ${item.score} (${item.source})`);
}

// Retrieve a file
const file = await space.retrieve("expertise/retry.md");
console.log(file.content);

// Delete
await space.forget("expertise/retry.md");

Works everywhere

Native fetch — no dependencies. Works in Node 18+, Deno, Bun, Edge, browser.

API Reference

new Cogspace(config?)

Reads COGSPACE_API_KEY from environment if apiKey not provided.

| Option | Default | Description | |---|---|---| | apiKey | env COGSPACE_API_KEY | Your API key | | baseUrl | http://localhost:8000 | Backend URL | | timeout | 30000 | Request timeout (ms) | | maxRetries | 3 | Retries on 429/5xx |

cog.space(nameOrId)SpaceClient

| Method | Description | |---|---| | space.list(folder?) | List files in folder | | space.retrieve(path) | Get one file | | space.searchHybrid(query, options?) | Unified search: vectors + BM25 + KG | | space.add(path, content, layer, topic, options?) | Add/update knowledge | | space.forget(path) | Delete from all layers | | space.getTools() | Fetch the Platform's live MCP-compatible tool schemas |

add() parameters

space.add(
  "expertise/retry.md",           // path
  "# Retry\nUse backoff...",      // content
  "expertise",                    // layer: "expertise" | "memory" | "root"
  "retry-patterns",               // topic
  {
    confidence: 0.95,             // 0.0-1.0, default 0.9
    related: ["error.md"],        // canonical related files
    relates_to: ["error.md"],     // backward-compatible alias
  }
)

Search limits

searchHybrid() options (enforced at backend):

space.searchHybrid("query", {
  vector_limit: 100,    // max vector results (0–100, default 100)
  bm25_limit: 100,      // max keyword results (0–100, default 100)
  kg_limit: 100,        // max graph neighbors per result (0–100, default 100)
  layer?: "expertise" | "memory" | "root",  // filter by layer
  folder_path?: string, // restrict to folder
})

Examples:

// Pure vector search (skip BM25)
space.searchHybrid("query", { bm25_limit: 0 })

// Pure keyword search (skip vectors)
space.searchHybrid("query", { vector_limit: 0 })

// Skip graph enrichment
space.searchHybrid("query", { kg_limit: 0 })

// Fine-grained control
space.searchHybrid("query", { vector_limit: 5, bm25_limit: 3, kg_limit: 1 })

Errors

import { AuthError, NotFoundError, RateLimitError } from "cogspace";

try {
  await space.searchHybrid("query");
} catch (err) {
  if (err instanceof AuthError) console.error("Invalid API key");
  if (err instanceof NotFoundError) console.error("Space not found");
  if (err instanceof RateLimitError) console.error("Rate limited");
}

Local-first note

The TypeScript SDK defaults to http://localhost:8000. If backend auth is disabled locally, any non-empty COGSPACE_API_KEY works.