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

contextos-typescript

v0.1.0

Published

TypeScript SDK for Context OS — Memory, Search, Crawl, Knowledge

Readme

Context AI — TypeScript SDK

A TypeScript client library for the Context OS API. Provides memory, search, crawl, and knowledge graph operations for AI agents.

Installation

npm install context-ai
# or
yarn add context-ai
# or
pnpm add context-ai

Quick Start

import { ContextAI } from "context-ai";

const client = new ContextAI({
  baseUrl: "http://localhost:8000",
  apiKey: "your-api-key", // or set CONTEXT_API_KEY env var
});

// Check health
const health = await client.health();
console.log(health);

Memory Operations

import { MemoryType, ImportanceLevel } from "context-ai";

// Add a memory
const memory = await client.memory.add({
  content: "User prefers dark mode and compact layouts",
  memory_type: MemoryType.SEMANTIC,
  importance: ImportanceLevel.HIGH,
  tags: ["preferences", "ui"],
});
console.log(`Created memory: ${memory.id}`);

// Search memories
const results = await client.memory.search({
  query: "dark mode preferences",
});
results.forEach((r) => {
  console.log(`Score: ${r.score.toFixed(2)} - ${r.memory.content}`);
});

// Get context window
const context = await client.memory.context(
  "What UI settings does the user prefer?",
  2000,
);
console.log(`Context has ${context.memories.length} memories`);

// List memories
const memories = await client.memory.list({
  memory_type: "semantic",
  limit: 10,
});

// Get related memories
const related = await client.memory.related(memory.id, 5);

Web Search

// Web search
const results = await client.search.web({
  query: "latest AI agent frameworks 2025",
  max_results: 5,
});
results.forEach((r) => {
  console.log(`${r.title}: ${r.url}`);
});

// Internal hybrid search
const internal = await client.search.internal("user preferences", 10);

Web Crawl

// Scrape a single page
const page = await client.crawl.scrape("https://docs.example.com/api");
console.log(`Title: ${page.title}`);
console.log(`Content length: ${page.content.length} chars`);

// Crawl a website
const results = await client.crawl.crawl({
  url: "https://docs.example.com",
  max_pages: 20,
  extract_content: true,
});
console.log(`Crawled ${results.length} pages`);

// Map a website
const urls = await client.crawl.map("https://example.com", 100);
console.log(`Found ${urls.length} URLs`);

Knowledge Graph

// Create entities
const entity = await client.knowledge.createEntity({
  name: "GPT-4",
  entity_type: "model",
  description: "OpenAI's large language model",
  properties: { provider: "OpenAI", parameters: "1.7T" },
});

// Create relationships
await client.knowledge.createRelationship({
  source_id: entity.id,
  target_id: "other-entity-id",
  relationship_type: "related_to",
  weight: 0.9,
});

// Get entity graph
const graph = await client.knowledge.getGraph(entity.id, 2);
console.log(`Graph has ${graph.nodes.length} nodes`);

// Search entities
const entities = await client.knowledge.search("language models", {
  entity_type: "model",
});

Configuration

Environment Variables

| Variable | Description | Default | |----------|-------------|---------| | CONTEXT_API_KEY | API key for authentication | undefined | | CONTEXT_API_URL | API server URL | http://localhost:8000 | | CONTEXT_OS_URL | Alias for CONTEXT_API_URL | http://localhost:8000 | | CONTEXT_OS_API_KEY | Alias for CONTEXT_API_KEY | undefined |

Constructor Parameters

const client = new ContextAI({
  baseUrl: "http://localhost:8000", // API server URL
  apiKey: "your-key",              // API key
  timeout: 30000,                   // Request timeout (ms)
});

Error Handling

try {
  const memory = await client.memory.get("nonexistent-id");
} catch (error) {
  if (error instanceof Error) {
    console.error(`Request failed: ${error.message}`);
  }
}

License

MIT License — see LICENSE for details.