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

@sschepis/tinyagent

v0.1.0

Published

A minimal, pluggable autonomous agent library with built-in VFS, memory, and AST mutation

Downloads

110

Readme

tinyagent

A minimal, pluggable autonomous agent library for TypeScript/JavaScript. Ships with a built-in virtual filesystem, dual memory system, AST mutation engine, lifecycle hooks, and a reflection-driven agent loop. Every component is replaceable.

Install

npm install tinyagent

Quick Start

import { TinyAgent, type LLMProvider } from 'tinyagent';

// 1. Implement the LLMProvider interface for your model
const provider: LLMProvider = {
  async generate(history, systemPrompt) {
    const res = await fetch('https://api.example.com/chat', {
      method: 'POST',
      headers: { 'Content-Type': 'application/json' },
      body: JSON.stringify({ messages: history, system: systemPrompt }),
    });
    return res.json(); // must return { reflection, reasoning, commands }
  },
};

// 2. Create an agent
const agent = new TinyAgent({ provider });

// 3. Run it
const history = await agent.run('Create a file called hello.txt with "Hello World" inside it.');
console.log(history);

Execution Modes

// Run to completion
const history = await agent.run('do something');

// Step through one turn at a time
const turn1 = await agent.step('my task');
const turn2 = await agent.step(); // continues same task

// Stream turns as an async iterator
for await (const turn of agent.stream('my task')) {
  console.log(`Turn ${turn.turn}: ${turn.agent.reasoning}`);
  if (turn.finished) break;
}

Key Concepts

  • LLMProvider — Bring your own model. Implement one method: generate(history, systemPrompt) → { reflection, reasoning, commands }.
  • Commands — CLI-style tools the agent can invoke (ls, read, write, rm, mv, append, mutate, etc.). Register your own or replace the built-ins entirely. eval/spawn are opt-in via createUnsafeCommands().
  • VFS — An in-memory virtual filesystem with configurable root path.
  • Dual Memory — Voluntary (agent-controlled) and involuntary (automatic context capture) memory stores with optional semantic search, configurable capacity, and similarity threshold.
  • Hooks — Lifecycle hooks (beforeLLMCall, afterLLMCall, beforeCommand, afterCommand, onError, onTurnStart, onTurnEnd) for intercepting and modifying agent behavior.
  • Symbolic Continuity — On task completion, the agent emits context-sensitive symbols encoding its internal state. A configurable-depth stack of these states is injected into the next run's prompt, giving the agent a warm cognitive start.
  • Prompts — Default persona and system prompt are exported and fully customizable.
  • Error Classes — Typed errors (AgentRunningError, MaxTurnsExceededError, ProviderError, CommandError) for structured error handling.

Documentation

Architecture

TinyAgent
├── LLMProvider (pluggable)    — Any LLM backend
├── VirtualFileSystem          — In-memory file operations (ls, read, write, rm, mv, append)
├── AssociativeMemory x2       — Voluntary + Involuntary stores (lexical + semantic)
├── Command Registry           — Built-in + custom commands, runtime register/unregister
├── PipelineEngine             — AST-based code mutations with rollback
├── Hooks                      — Lifecycle interception points
├── Continuity Stack           — Symbolic state persistence across runs
└── Prompt Builder (pluggable) — System prompt generation

Testing

npm test          # run tests once
npm run test:watch  # watch mode

93 tests covering VFS, memory, pipeline, commands, and the full agent lifecycle.

License

MIT