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

anchorai

v1.0.0

Published

Control what your AI agents store. Audit everything.

Readme

Anchor TypeScript SDK

Control what your AI agents store. Audit everything.

Installation

npm install anchorai

Quick Start

import { Anchor } from 'anchorai';

const anchor = new Anchor({ apiKey: 'your-api-key' });

// Create an agent
const agent = await anchor.agents.create('support-bot', { environment: 'production' });

// Configure policies
await anchor.config.update(agent.id, {
  policies: {
    block_pii: true,
    block_secrets: true,
    retention_days: 90
  }
});

// Store data (policy-checked, audit-logged)
const result = await anchor.data.write(agent.id, 'user:123:preference', 'dark_mode');
console.log(result.allowed);  // true

// PII is blocked automatically
const blocked = await anchor.data.write(agent.id, 'user:123:ssn', '123-45-6789');
console.log(blocked.allowed);     // false
console.log(blocked.blockedBy);   // "policy:block_pii"

// Verify audit chain integrity
const verification = await anchor.audit.verify(agent.id);
console.log(verification.valid);  // true

Why Anchor?

  • Policy enforcement: Block PII, secrets, and custom patterns before storage
  • Checkpoints & rollback: Snapshot state, restore if something goes wrong
  • Audit trail: Hash-chained log of every operation, queryable and verifiable
  • Retention policies: Auto-expire data after N days

SDK Structure

The SDK has 5 namespaces:

| Namespace | Purpose | |-----------|---------| | anchor.agents | Agent registry and lifecycle | | anchor.config | Agent configuration with versioning | | anchor.data | Governed key-value data storage | | anchor.checkpoints | State snapshots and rollback | | anchor.audit | Hash-chained audit trail |

Agents

// Create agent
const agent = await anchor.agents.create('my-agent', { env: 'prod' });

// Get agent
const fetched = await anchor.agents.get(agent.id);

// List agents
const agents = await anchor.agents.list({ status: 'active' });

// Update metadata
const updated = await anchor.agents.update(agent.id, { version: '2.0' });

// Suspend/Activate
await anchor.agents.suspend(agent.id);
await anchor.agents.activate(agent.id);

// Delete
await anchor.agents.delete(agent.id);

Configuration

Store any config fields you want. Anchor only enforces the policies section:

// Get current config
const config = await anchor.config.get(agent.id);

// Update config - store any fields, Anchor enforces `policies`
await anchor.config.update(agent.id, {
  instructions: 'You are a helpful assistant',  // Your field
  model: 'gpt-4',                               // Your field
  policies: {                                   // Anchor enforces this
    block_pii: true,
    block_secrets: true,
    retention_days: 90,
    retention_by_prefix: { 'temp:': 1, 'session:': 7 }
  }
});

// Config versioning
const versions = await anchor.config.versions(agent.id);
const oldConfig = await anchor.config.getVersion(agent.id, 'v1');
await anchor.config.rollback(agent.id, 'v1');

Data Storage

Policy-enforced key-value storage:

// Write data (policy-checked)
const result = await anchor.data.write(agent.id, 'user:123:preference', 'dark_mode');
if (result.allowed) {
  console.log(`Stored with audit_id: ${result.auditId}`);
} else {
  console.log(`Blocked by: ${result.blockedBy}`);
}

// Write with metadata
const result2 = await anchor.data.write(
  agent.id,
  'user:123:topic',
  'billing questions',
  { source: 'conversation', confidence: 0.9 }
);

// Batch write
const results = await anchor.data.writeBatch(agent.id, {
  'user:123:name': 'John',
  'user:123:plan': 'enterprise'
});

// Read data
const value = await anchor.data.read(agent.id, 'user:123:preference');

// Read with metadata
const entry = await anchor.data.readFull(agent.id, 'user:123:preference');
console.log(entry?.value, entry?.createdAt, entry?.metadata);

// Search (text similarity matching)
const results = await anchor.data.search(agent.id, 'user preferences', { limit: 10 });
for (const r of results) {
  console.log(`${r.key}: ${r.value} (similarity: ${r.similarity})`);
}

// List keys
const keys = await anchor.data.list(agent.id, { prefix: 'user:123:' });

// Delete
await anchor.data.delete(agent.id, 'user:123:preference');
await anchor.data.deletePrefix(agent.id, 'user:123:');

Checkpoints

Snapshot state and rollback if something goes wrong:

// Create checkpoint before risky operation
const checkpoint = await anchor.checkpoints.create(agent.id, { label: 'pre-migration' });

try {
  for (const item of largeDataset) {
    await anchor.data.write(agent.id, item.key, item.value);
  }
} catch (error) {
  // Something went wrong - restore previous state
  const result = await anchor.checkpoints.restore(agent.id, checkpoint.id);
  console.log(`Restored ${result.dataKeysRestored} keys`);
}

// List checkpoints
const checkpoints = await anchor.checkpoints.list(agent.id);

// Get/delete checkpoint
const cp = await anchor.checkpoints.get(agent.id, checkpoint.id);
await anchor.checkpoints.delete(agent.id, checkpoint.id);

Audit Trail

Hash-chained audit logging for compliance and debugging:

// Query audit events
const events = await anchor.audit.query(agent.id, {
  operations: ['data.write', 'data.delete'],
  limit: 100
});

for (const event of events) {
  console.log(`${event.timestamp}: ${event.operation} on ${event.resource}`);
  console.log(`  Result: ${event.result}`);  // "allowed" or "blocked"
  console.log(`  Hash: ${event.hash}`);
}

// Verify chain integrity (detects tampering)
const verification = await anchor.audit.verify(agent.id);
console.log(verification.valid);          // true if chain intact
console.log(verification.eventsChecked);  // Number of events verified

// Export for compliance
const exportResult = await anchor.audit.export(agent.id, { format: 'json' });
console.log(exportResult.downloadUrl);

Framework Integrations

Anchor integrates with popular AI frameworks:

// LangChain - Policy-checked memory
import { AnchorMemory } from 'anchorai';

const memory = new AnchorMemory(anchor, agent.id);
// Use with LangChain chains/agents

// CrewAI - Policy-checked shared memory
import { AnchorCrewMemory } from 'anchorai';

const memory = new AnchorCrewMemory(anchor);
// Use with CrewAI crews

// Mem0 - Policy-checked memory operations
import { AnchorMem0 } from 'anchorai';

const wrapped = new AnchorMem0(anchor, agent.id, mem0Client);
const result = await wrapped.add('User prefers dark mode', { userId: 'user_123' });
console.log(result.allowed);  // true or false based on policies

Error Handling

import {
  AnchorError,
  AuthenticationError,
  NotFoundError,
  ValidationError,
  PolicyViolationError,
  RateLimitError
} from 'anchorai';

try {
  const result = await anchor.data.write(agent.id, 'key', 'value');
} catch (error) {
  if (error instanceof PolicyViolationError) {
    console.log(`Blocked: ${error.message}`);
  } else if (error instanceof AuthenticationError) {
    console.log('Invalid API key');
  } else if (error instanceof NotFoundError) {
    console.log('Agent not found');
  } else if (error instanceof RateLimitError) {
    console.log(`Rate limited. Retry after ${error.retryAfter}s`);
  }
}

Client Configuration

import { Anchor } from 'anchorai';

// Simple
const anchor = new Anchor({ apiKey: 'your-api-key' });

// Full configuration
const anchor = new Anchor({
  apiKey: 'your-api-key',
  baseUrl: 'https://api.getanchor.dev',
  timeout: 30000,
  retryAttempts: 3
});

Requirements

  • Node.js 18+
  • TypeScript 4.5+

License

Apache 2.0