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

@animus-labs/cortex

v0.7.0

Published

Production-grade agent framework with structured context management, compaction, tools, and MCP support

Readme

@animus-labs/cortex

Production-grade agent framework with structured context management. Built on @earendil-works/pi-agent-core.

Cortex treats the context window as a managed surface, not a flat chat log. Named slots, stability-ordered layout, and observational memory give you fine-grained control over what the model sees while maximizing prompt cache hit rates.

Install

npm install @animus-labs/cortex

Requires Node.js 24+.

Quick Start

import { AgentLoop, ProviderManager } from '@animus-labs/cortex';

const providers = new ProviderManager();
const model = await providers.resolveModel('anthropic', 'claude-sonnet-4-6');

const agent = await AgentLoop.create({
  model,
  workingDirectory: process.cwd(),
  initialBasePrompt: 'You are a helpful assistant.',
  // Optional. If omitted, pi-ai falls back to provider environment variables.
  getApiKey: async (provider) => {
    if (provider === 'anthropic' && process.env.ANTHROPIC_API_KEY) {
      return process.env.ANTHROPIC_API_KEY;
    }
    throw new Error(`No API key configured for ${provider}`);
  },
});

agent.onTurnComplete((output) => {
  if (output.userFacing) console.log(output.userFacing);
});

await agent.prompt('What files are in this directory?');
await agent.destroy();

Built-in sandboxing

Use CortexAgent.create({ ...config, sandbox: true }) for managed workspace containment. Cortex selects the backend, applies default protections, shares it with its loops, and cleans up on destroy(). Omit the setting to opt out, or supply an object for writable roots, protected paths, domain rules, and status callbacks. Setup refuses unavailable enforcement by default.

See the sandbox consumer guide for settings and platform limits. No separate sandbox package is required.

Key Features

  • Context Slots: Named, stability-ordered content blocks for prompt cache optimization. Ephemeral context provides fresh per-loop state without accumulating in persistent history.
  • Compaction: Observational memory with a verbatim recent tail, cache-aware tool result trimming, and a failsafe that never drops a message silently; compactNow() when you choose the moment
  • Built-in Tools: Bash, TaskOutput, Read, Write, Edit, UndoEdit, Glob, Grep, WebFetch, SubAgent
  • MCP Support: Integrate external tool servers via the Model Context Protocol
  • Skills: Progressive disclosure system for dynamically loading capabilities
  • Tool Permissions: Consumer-provided resolver hook for allow, block, or approval-required decisions
  • Budget Guards: Token and cost limits to prevent runaway execution
  • Provider Management: Multi-provider support with OAuth flows and model resolution
  • Event Bridge: Normalized event stream for logging and observability

Main Exports

  • CortexAgent - Composite agent with managed sandbox setup and session lifecycle
  • AgentLoop - Core agentic loop with context management
  • ProviderManager - Provider discovery, OAuth, and model resolution

Design Principles

  1. Context is a managed surface. Structure it, order it for caching, update it granularly.
  2. Mechanism, not policy. Cortex provides hooks and callbacks. Consumers implement domain logic.
  3. No persistence opinions. The consumer owns storage. Cortex owns the in-memory context surface.

Documentation

Start with the consumer guide. The docs directory also contains architecture notes, API details, and tool references.

License

MIT