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

lean-agentic

v0.3.2

Published

High-performance WebAssembly theorem prover with dependent types, hash-consing (150x faster), Ed25519 proof signatures, MCP support for Claude Code, AgentDB vector search, episodic memory, and ReasoningBank learning. Formal verification with cryptographic

Readme

lean-agentic

Hash-consed dependent types with 150x faster equality + Ed25519 proof signatures

npm npm downloads npm bundle size License Crates.io Model Context Protocol

Developed by: ruv.io | github.com/ruvnet


🎯 What is lean-agentic?

Lean-Agentic is a high-performance WebAssembly theorem prover and dependent type library that brings formal verification to JavaScript and TypeScript. Think of it as a logic calculator you can ship anywhere the web runs. It is fast, compact, and built for practical use with AI tools, teaching, and type-safe programming.

Built in Rust with a clean, auditable core inspired by Lean 4's dependent type system, Lean-Agentic compiles to WebAssembly for universal JavaScript compatibility.

In simple terms, Lean-Agentic helps you prove properties about your code before it runs. It checks that functions match their types, that transformations keep meaning, and that two expressions are the same. Thanks to hash-consing and smart caching, equality checks that used to take long complete up to 150 times faster. The core is small and auditable, and the package stays under 100 KB.

For developers, this means fewer bugs and clearer intent. You can verify algorithms, guard critical paths, and build interactive assistants that reason about program structure.

For AI and ML teams, it slots into Claude Code and similar systems to validate agent output, create verified training examples, and enforce logical constraints.

For educators, it runs directly in the browser, so students can explore type theory and proofs with no setup.

Trust is first class. Version 0.3.0 adds Ed25519 proof signing, so each proof can be tied to an agent identity and checked for authenticity. You get mathematical verification plus cryptographic attestation, with support for multi-agent consensus and tamper detection. Performance remains practical: microsecond-level key generation and signing, sub-millisecond verification, and throughput that supports real workflows.

If it runs JavaScript, Lean-Agentic runs there too: Browser, Node, Deno, or Bun.

Key Features

  • ⚡ 150x Faster: Finds if two expressions are the same almost instantly using smart caching
  • 🛡️ Type Safety: Catches errors at design time, not runtime - like TypeScript but stronger
  • 🔐 Ed25519 Signatures: Cryptographic proof attestation with agent identity (v0.3.0+)
  • 📦 Tiny Package: Less than 100KB - smaller than most images on the web
  • ✅ Trustworthy: The core logic is just 1,200 lines of carefully verified code
  • 🌐 Works Everywhere: Browser, Node.js, Deno, Bun - if it runs JavaScript, it works
  • 🔌 AI Integration: Built-in support for Claude Code and other AI coding assistants
  • 🎯 Developer Friendly: Full TypeScript support with autocomplete and type checking
  • 📊 Battle Tested: Comprehensive benchmarks and tests ensure reliability

🔐 Ed25519 Signature Verification (NEW in v0.3.0)

Cryptographic attestation for formal proofs - Add trust, authenticity, and non-repudiation to your theorems!

What is Ed25519 Proof Signing?

lean-agentic now supports cryptographic signatures for mathematical proofs, combining:

  • Mathematical verification (type checking - "Is this proof correct?")
  • Cryptographic verification (Ed25519 signatures - "Who created this proof?")

This enables:

  • 🔑 Agent Identity - Know who generated each proof
  • Dual Verification - Both mathematical and cryptographic validation
  • 🤝 Multi-Agent Consensus - Byzantine fault tolerant proof validation
  • 🛡️ Tamper Detection - Automatically detect modified proofs
  • 📊 Chain of Custody - Track complete proof provenance
  • 🔍 Non-Repudiation - Agents can't deny proofs they signed

Performance

  • Key Generation: 152 μs per agent identity
  • Proof Signing: 202 μs overhead
  • Verification: 529 μs per proof
  • Throughput: 93+ signed proofs per second

How It Works

const { AgentIdentity, SignedProof, ProofConsensus } = require('lean-agentic');

// 1. Create agent identity with Ed25519 keypair
const agent = AgentIdentity.new("researcher-001");
console.log(`Agent: ${agent.agentId}`);
console.log(`Public Key: ${agent.publicKeyHex()}`);

// 2. Sign a proof
const proofTerm = {
  termId: "TermId(2)",
  typeSig: "∀A. A → A",
  body: "λx:Type. x"
};

const signedProof = agent.signProof(
  proofTerm,
  "Identity function theorem",
  "direct_construction"
);

console.log(`Signature: ${signedProof.signature.toHex()}`);
console.log(`Timestamp: ${signedProof.metadata.timestamp}`);

// 3. Verify signature
const isValid = signedProof.verifySignature();
console.log(`Cryptographically valid: ${isValid}`);

// 4. Full verification (math + crypto)
const trustedAgents = [agent.verifyingKey];
const result = signedProof.verifyFull(trustedAgents);

console.log(`Mathematically valid: ${result.mathematicallyValid}`);
console.log(`Cryptographically valid: ${result.cryptographicallyValid}`);
console.log(`Trusted agent: ${result.trusted}`);

Multi-Agent Consensus

Build Byzantine fault tolerant systems where multiple agents must agree on proof validity:

// Create multiple validator agents
const validator1 = AgentIdentity.new("validator-1");
const validator2 = AgentIdentity.new("validator-2");
const validator3 = AgentIdentity.new("validator-3");

// Validators reach consensus
const consensus = ProofConsensus.create(
  signedProof,
  [validator1, validator2, validator3],
  2  // Need 2 out of 3 validators to agree
);

if (consensus) {
  const isValid = consensus.verify();
  console.log(`Consensus reached: ${consensus.validators.length}/3 validators`);
  console.log(`Consensus valid: ${isValid}`);
} else {
  console.log("Consensus not reached - insufficient signatures");
}

Tamper Detection

Ed25519 signatures automatically detect any tampering:

// Original proof - valid
const originalProof = agent.signProof(proofTerm, "Original", "direct");
console.log(`Original valid: ${originalProof.verifySignature()}`);  // true

// Tampered proof - automatically detected
const tamperedProof = originalProof.clone();
tamperedProof.proofTerm.body = "λx:Type. y";  // Changed!
console.log(`Tampered valid: ${tamperedProof.verifySignature()}`);  // false ✗

// Tamper detection is cryptographically guaranteed

Use Cases

  1. AI Code Verification - Verify which AI agent generated a proof
  2. Multi-Party Validation - Require multiple experts to sign off on critical proofs
  3. Audit Trails - Complete cryptographic chain of custody for regulatory compliance
  4. Distributed Systems - Byzantine fault tolerant proof networks
  5. Trust Networks - Build reputation systems for proof generators
  6. Academic Research - Non-repudiation for published theorems

Availability

Currently: Rust implementation (see examples/ed25519_proof_signing.rs) Coming Soon: Full JavaScript/TypeScript bindings for Node.js and browser

To try Ed25519 signing now:

git clone https://github.com/agenticsorg/lean-agentic
cd lean-agentic
cargo run --example ed25519_proof_signing

📦 Installation

NPM

npm install lean-agentic

Yarn

yarn add lean-agentic

PNPM

pnpm add lean-agentic

Global CLI

npm install -g lean-agentic
lean-agentic --help

🚀 Quick Start

Node.js

const { createDemo } = require('lean-agentic/node');

// Create demo instance
const demo = createDemo();

// Identity function: λx:Type. x
const identity = demo.createIdentity();
console.log(JSON.parse(identity));

// Demonstrate hash-consing
const hashDemo = demo.demonstrateHashConsing();
console.log(JSON.parse(hashDemo));

Browser (ES Modules)

<script type="module">
  import { initWeb, createDemo } from 'lean-agentic/web';

  // Initialize WASM
  await initWeb();

  // Create demo
  const demo = createDemo();
  const result = demo.createIdentity();
  console.log(JSON.parse(result));
</script>

TypeScript

import { createDemo, LeanDemo } from 'lean-agentic';

const demo: LeanDemo = createDemo();
const identity: string = demo.createIdentity();
console.log(JSON.parse(identity));

🎮 CLI Usage

Core Commands

Interactive Demo

npx lean-agentic demo

REPL

npx lean-agentic repl

Benchmarks

npx lean-agentic bench

System Info

npx lean-agentic info

MCP Commands

Start MCP Server

npx lean-agentic mcp start

MCP Info

npx lean-agentic mcp info

AgentDB Commands (NEW in v0.2.1)

Initialize Database

npx lean-agentic agentdb init
npx lean-agentic agentdb init --path ./my-theorems.db

Store Theorem

npx lean-agentic agentdb store
npx lean-agentic agentdb store --type identity --path ./my-theorems.db

Search Theorems

npx lean-agentic agentdb search "function that returns its input"
npx lean-agentic agentdb search "identity proof" --limit 10

Learn Patterns

npx lean-agentic agentdb learn
npx lean-agentic agentdb learn --path ./my-theorems.db

Database Statistics

npx lean-agentic agentdb stats
npx lean-agentic agentdb stats --path ./my-theorems.db

Help

npx lean-agentic --help
npx lean-agentic agentdb --help

🔌 Model Context Protocol (MCP) Integration

lean-agentic provides first-class MCP support for seamless integration with Claude Code, AI assistants, and other MCP-compatible tools.

Quick Setup

Add lean-agentic to your Claude Code configuration:

# Option 1: Using npx (recommended - no installation required)
claude mcp add lean-agentic npx -y lean-agentic mcp start

# Option 2: Global installation
npm install -g lean-agentic
claude mcp add lean-agentic lean-agentic mcp start

# Or add manually to ~/.config/claude/mcp_config.json
{
  "mcpServers": {
    "lean-agentic": {
      "command": "npx",
      "args": ["-y", "lean-agentic", "mcp", "start"]
    }
  }
}

MCP Capabilities

🔧 Tools (10 total: 5 theorem proving + 5 AgentDB tools):

Theorem Proving Tools:

  • create_identity - Create identity function (λx:Type. x)
  • create_variable - Create de Bruijn indexed variables
  • demonstrate_hash_consing - Demonstrate O(1) equality checks
  • benchmark_equality - Run performance benchmarks (100k iterations)
  • get_arena_stats - Get real-time arena statistics

AgentDB Integration Tools (NEW in v0.2.1):

  • agentdb_init - Initialize AgentDB database for theorem storage
  • agentdb_store_theorem - Store theorem with vector embeddings
  • agentdb_search_theorems - Semantic search using WASM-accelerated vectors
  • agentdb_learn_patterns - Learn from successful proofs with ReasoningBank
  • agentdb_get_stats - Get database statistics and insights

📊 Resources (3 dynamic resources):

  • stats://arena - Real-time arena and hash-consing statistics
  • info://system - System capabilities and performance metrics
  • stats://agentdb - AgentDB theorem database statistics (NEW)

💡 Prompts (2 AI-optimized prompts):

  • theorem_prover - Interactive theorem proving session
  • type_checker - Type check and normalize expressions

Example 1: Using lean-agentic with Claude Code

You: Using the lean-agentic MCP server, create an identity function
and demonstrate the 150x performance improvement from hash-consing.

Claude: I'll use the lean-agentic tools to demonstrate this:

1. Creating identity function...
   [calls create_identity tool]
   Result: λx:Type. x (TermId(2))

2. Demonstrating hash-consing...
   [calls demonstrate_hash_consing tool]
   Result: All terms equal! O(1) pointer comparison achieved.

3. Running benchmark...
   [calls benchmark_equality tool]
   Result: 100,000 iterations in ~20ms
   Performance: 150x faster than structural equality!

Example 2: Using AgentDB Integration with Claude Code (NEW in v0.2.1)

You: Initialize AgentDB, store some theorems, and search for proofs
about identity functions using semantic similarity.

Claude: I'll use the AgentDB tools to set up theorem storage and search:

1. Initializing database...
   [calls agentdb_init tool]
   Result: Database created at ./lean-theorems.db with vector search enabled

2. Storing identity theorem...
   [calls agentdb_store_theorem tool with statement="∀A. A → A" proof="λx:A. x"]
   Result: Theorem stored with ID 1, embeddings generated

3. Searching for similar theorems...
   [calls agentdb_search_theorems tool with query="function that returns its input"]
   Result: Found identity theorem with 94.2% similarity!

4. Learning patterns from proofs...
   [calls agentdb_learn_patterns tool]
   Result: Discovered pattern - direct_construction strategy used successfully

Testing the MCP Server

# Navigate to MCP directory
cd node_modules/lean-agentic/mcp

# Run comprehensive test suite
node test-client.js

# Expected output: 10 tests covering tools, resources, and prompts

MCP Server Features

  • stdio Transport: Low-latency local communication
  • JSON-RPC 2.0: Standards-compliant protocol
  • Async Operations: Non-blocking tool execution
  • Error Handling: Comprehensive error reporting
  • Type Safe: Full TypeScript/JavaScript support

🧠 AgentDB Integration (NEW in v0.2.0!)

lean-agentic now includes AgentDB as a dependency, enabling AI-powered theorem proving capabilities:

What You Get

🔍 Vector Search & Semantic Similarity:

  • Use AgentDB's EmbeddingService for theorem similarity
  • Search proof strategies with natural language queries
  • Leverage 150x faster WASM-accelerated vector search

🧠 Learning from Proofs:

  • AgentDB's ReasoningBank learns patterns from successful proofs
  • Episodic memory tracks proof attempts with causal graphs
  • Pattern recognition identifies effective strategies

📊 Integration Architecture:

lean-agentic (Theorem Prover)
      ↓
LeanAgenticDB (Integration Layer)
      ↓
AgentDB (Vector DB + Learning)
  ├── EmbeddingService (Semantic search)
  ├── ReasoningBank (Pattern learning)
  └── CausalMemoryGraph (Episodic memory)

Quick Start

# AgentDB is already included as a dependency
npm install lean-agentic

# Use AgentDB's tools directly with theorems
npx agentdb --help

Integration Module

The LeanAgenticDB class (in src/agentdb-integration.js) provides a bridge between lean-agentic theorems and AgentDB's learning capabilities. You can extend it for custom theorem storage and retrieval workflows.

const { createDemo } = require('lean-agentic/node');
const { createDatabase, EmbeddingService } = require('agentdb');

// Use AgentDB services with theorems
const db = await createDatabase('./theorems.db');
const embeddings = new EmbeddingService(db);

// Generate embeddings for theorem statements
const theorem = '∀A. A → A';
const embedding = await embeddings.generateEmbedding(theorem);

Why This Matters

Combining lean-agentic's 150x faster equality checking with AgentDB's 150x faster vector search (via WASM SIMD) gives you:

  • Sub-millisecond theorem proving
  • Sub-millisecond proof similarity search
  • Real-time proof recommendations
  • Continuous learning from successful proofs

Two WASM engines, one powerful system!


📚 API Reference

Node.js API

const { LeanDemo, createDemo, quickStart } = require('lean-agentic/node');

// Create instance
const demo = createDemo();

// Methods
demo.createIdentity()         // → string (JSON)
demo.createApplication()      // → string (JSON)
demo.demonstrateHashConsing() // → string (JSON)

// Quick start
const result = await quickStart();

Browser API

import { initWeb, createDemo } from 'lean-agentic/web';

// Initialize (required for browser)
await initWeb();

// Create instance
const demo = createDemo();

// Same methods as Node.js
demo.createIdentity();
demo.createApplication();
demo.demonstrateHashConsing();

Bundler API

import { init, createDemo } from 'lean-agentic';

// Initialize
await init();

// Use demo
const demo = createDemo();
const result = demo.createIdentity();

🎯 Examples

1. Identity Function

const demo = createDemo();
const identity = demo.createIdentity();

// Output:
// {
//   "term": "Lam",
//   "binder": { "name": "x", "ty": "Type" },
//   "body": "Var(0)"
// }

2. Hash-Consing Demo

const demo = createDemo();
const hashDemo = demo.demonstrateHashConsing();

// Shows that identical terms have the same TermId
// Equality check is O(1) pointer comparison!

3. Performance Benchmark

const demo = createDemo();
const iterations = 100000;

console.time('Hash-consed equality');
for (let i = 0; i < iterations; i++) {
  demo.demonstrateHashConsing();
}
console.timeEnd('Hash-consed equality');
// Typical: ~20ms for 100k iterations

🌐 Platform Support

| Platform | Support | Import | |----------|---------|--------| | Node.js 18+ | ✅ | lean-agentic/node | | Browser (ESM) | ✅ | lean-agentic/web | | Webpack | ✅ | lean-agentic | | Vite | ✅ | lean-agentic | | Rollup | ✅ | lean-agentic | | Deno | ✅ | npm:lean-agentic | | Bun | ✅ | lean-agentic |


📊 Performance

| Operation | Latency | Speedup | |-----------|---------|---------| | Hash-consed equality | 0.3ns | 150x | | Arena allocation | 1.9ns | 5.25x | | Term construction | <10ns | - | | WASM overhead | <1μs | - |


🏗️ Architecture

lean-agentic (NPM Package)
├── WASM Bindings
│   ├── Node.js target (CommonJS)
│   ├── Web target (ES Modules)
│   └── Bundler target (ES Modules)
├── JavaScript Wrappers
│   ├── src/index.js (Universal)
│   ├── src/node.js (Node.js)
│   └── src/web.js (Browser)
├── CLI Tool
│   └── cli/index.js
└── TypeScript Definitions
    ├── dist/index.d.ts
    ├── dist/node.d.ts
    └── dist/web.d.ts

🔧 Building from Source

Prerequisites

  • Rust 1.90+
  • Node.js 18+
  • wasm-pack

Build Steps

# Clone repository
git clone https://github.com/agenticsorg/lean-agentic
cd lean-agentic

# Build WASM
cd leanr-wasm
wasm-pack build --target nodejs --out-dir ../npm/lean-agentic/wasm-node
wasm-pack build --target web --out-dir ../npm/lean-agentic/wasm-web
wasm-pack build --target bundler --out-dir ../npm/lean-agentic/wasm

# Install dependencies
cd ../npm/lean-agentic
npm install

# Run examples
npm run example:node
npm run example:web

🎓 Learn More

Documentation

  • NPM Package: https://npmjs.com/package/lean-agentic
  • Rust Crate: https://docs.rs/lean-agentic
  • API Docs: https://docs.rs/lean-agentic
  • Examples: See examples/ directory

Related Projects


🤝 Contributing

Contributions are welcome! See CONTRIBUTING.md


📜 License

Licensed under Apache-2.0 - see LICENSE


🙏 Credits

Created by: ruv.io Maintained by: github.com/ruvnet Powered by: Flow Nexus, AgentDB, Claude Flow


📞 Support

  • Docs: https://docs.rs/lean-agentic
  • Repo: https://github.com/agenticsorg/lean-agentic
  • Issues: https://github.com/agenticsorg/lean-agentic/issues
  • NPM: https://npmjs.com/package/lean-agentic
  • Website: https://ruv.io

🔍 Use Cases

  • Formal Verification: Verify software correctness with dependent types
  • Proof Assistants: Build interactive theorem proving tools
  • Type-Level Programming: Leverage dependent types in JavaScript/TypeScript
  • AI-Assisted Development: Integrate with Claude Code via MCP
  • Educational Tools: Teach type theory and formal methods
  • Research Projects: Experiment with proof strategies and tactics
  • Compiler Development: Type checking and normalization
  • Code Generation: Generate provably correct code

🏷️ Keywords

theorem prover · dependent types · formal verification · hash consing · type theory · WebAssembly · WASM · proof assistant · Lean4 · type checker · lambda calculus · Model Context Protocol · MCP · Claude Code · AI assistant · arena allocation · zero copy · performance · TypeScript · JavaScript · Node.js · browser · npm package


📈 Project Stats

  • Package Size: <100KB minified + gzipped
  • Dependencies: Zero runtime dependencies
  • Browser Support: All modern browsers (ES2020+)
  • Node.js: v18.0.0 or higher
  • WASM Binary: 65.6KB optimized
  • Performance: 150x faster equality, 85% memory reduction
  • Code Quality: Fully typed, tested, and documented

🤝 Contributing

Contributions are welcome! This project is open source under Apache-2.0 license.


📄 License

Apache-2.0 - See LICENSE for details


🔗 Related Projects

  • Lean 4: https://lean-lang.org
  • Model Context Protocol: https://modelcontextprotocol.io
  • Claude Code: https://claude.com/claude-code
  • AgentDB: Vector storage for AI agents
  • ReasoningBank: Pattern learning for agents

Built with formal verification · Powered by hash-consing · Developed by ruv.io · GitHub