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

anycodejs

v0.1.0

Published

Orchestrate autonomous AI agent teams with dependency-aware task scheduling, inter-agent messaging, and provider-agnostic LLM integration.

Readme

AnyCode

Scalable Multi-Agent AI Orchestration Framework for TypeScript

Developed and maintained by Quantlix

AnyCode is a lightweight yet powerful orchestration engine written entirely in TypeScript. It enables you to compose autonomous AI agents into collaborative teams that communicate, share context, resolve task dependencies, and operate concurrently — all from a single runtime. Whether you're deploying on bare metal, inside containers, across serverless functions, or within CI/CD pipelines, AnyCode adapts to your infrastructure without friction.

Instead of managing individual agents in silos, AnyCode introduces a team-oriented paradigm: agents exchange messages through a built-in event bus, persist shared knowledge in memory stores, and execute work items according to a topologically sorted task graph. The result is a cohesive system where every agent understands its role and collaborates toward a unified objective.


Table of Contents


Key Capabilities

Traditional agent libraries focus on running a single LLM in a loop. AnyCode takes a fundamentally different approach — it gives you an entire coordinated team:

| Feature | Description | |---------|-------------| | Inter-agent communication | Agents relay information through MessageBus, share persistent state via SharedMemory, and synchronize through managed task queues | | Dependency-driven execution | Express task relationships with dependsOn and let TaskQueue resolve ordering through topological sorting — no manual sequencing needed | | Automatic goal decomposition | Provide a high-level objective and the orchestrator intelligently partitions it into targeted subtasks assigned to the right agents | | Provider-agnostic design | Seamlessly use Anthropic Claude, OpenAI GPT, or integrate any custom backend through the LLMAdapter interface | | Schema-validated tooling | Every tool is declared with a Zod schema for input validation, plus five practical tools are included out of the box | | Bounded parallelism | Independent work items execute simultaneously, governed by a configurable concurrency semaphore | | Flexible scheduling strategies | Choose between round-robin, least-busy, capability-match, or dependency-first assignment policies | | Incremental streaming | Receive real-time text deltas from any agent as an AsyncGenerator<StreamEvent> | | Full type safety | Strict TypeScript types enforced at every layer, with Zod validation at all external boundaries |


Quick Start

Install the package from npm:

npm install anycodejs

Single Agent Execution

The simplest way to get started — spin up one agent and hand it a task:

import { AnyCode } from 'anycodejs'

const engine = new AnyCode({ defaultModel: 'claude-sonnet-4-6' })

const result = await engine.runAgent(
  {
    name: 'engineer',
    model: 'claude-sonnet-4-6',
    tools: ['bash', 'file_write'],
  },
  'Create a TypeScript utility that checks whether a given string is a palindrome, save it to /tmp/palindrome.ts, and execute it.',
)

console.log(result.output)

Note: Export ANTHROPIC_API_KEY and/or OPENAI_API_KEY as environment variables before running any example.


Building Agent Teams

Real-world workflows benefit from specialization. AnyCode lets you define distinct agents — each with its own system prompt, model, and tool access — and unify them into a collaborative team:

import { AnyCode } from 'anycodejs'
import type { AgentConfig } from 'anycodejs'

const planner: AgentConfig = {
  name: 'planner',
  model: 'claude-sonnet-4-6',
  systemPrompt: 'You draft module interfaces, folder layouts, and endpoint schemas.',
  tools: ['file_write'],
}

const builder: AgentConfig = {
  name: 'builder',
  model: 'claude-sonnet-4-6',
  systemPrompt: 'You translate specifications into production-ready code.',
  tools: ['bash', 'file_read', 'file_write', 'file_edit'],
}

const auditor: AgentConfig = {
  name: 'auditor',
  model: 'claude-sonnet-4-6',
  systemPrompt: 'You inspect code for bugs, edge cases, and readability concerns.',
  tools: ['file_read', 'grep'],
}

const engine = new AnyCode({
  defaultModel: 'claude-sonnet-4-6',
  onProgress: (ev) => console.log(ev.type, ev.agent ?? ev.task ?? ''),
})

const team = engine.createTeam('backend-crew', {
  name: 'backend-crew',
  agents: [planner, builder, auditor],
  sharedMemory: true,
})

const result = await engine.runTeam(team, 'Scaffold a CRUD API for a notes app in /tmp/notes-api/')

console.log(`Completed: ${result.success}`)
console.log(`Tokens used: ${result.totalTokenUsage.output_tokens}`)

Each agent contributes its expertise while maintaining access to a shared knowledge base. The orchestrator handles assignment, sequencing, and concurrency behind the scenes.


Defining Task Pipelines

For workflows that demand precise control over the execution graph, you can manually specify tasks along with their dependencies:

const result = await engine.runTasks(team, [
  {
    title: 'Draft schema definitions',
    description: 'Produce TypeScript type declarations and save them to /tmp/types.md',
    assignee: 'planner',
  },
  {
    title: 'Implement core logic',
    description: 'Read /tmp/types.md and build the service layer in /tmp/lib/',
    assignee: 'builder',
    dependsOn: ['Draft schema definitions'],
  },
  {
    title: 'Write unit tests',
    description: 'Author Vitest test suites covering all service methods.',
    assignee: 'builder',
    dependsOn: ['Implement core logic'],
  },
  {
    title: 'Audit implementation',
    description: 'Examine /tmp/lib/ and generate a detailed review report.',
    assignee: 'auditor',
    dependsOn: ['Implement core logic'],
  },
])

The TaskQueue resolves the dependency graph using topological sorting. Tasks with no unmet dependencies are dispatched in parallel, while dependent tasks wait until their predecessors complete successfully.


Creating Custom Tools

Extend agent capabilities by registering your own tools. Each tool is defined with a Zod input schema for automatic validation:

import { z } from 'zod'
import { defineTool, Agent, ToolRegistry, ToolExecutor, registerBuiltInTools } from 'anycodejs'

const fetchArticles = defineTool({
  name: 'fetch_articles',
  description: 'Retrieves relevant articles from the knowledge base.',
  inputSchema: z.object({
    topic: z.string().describe('Subject to search for.'),
    limit: z.number().optional().describe('Maximum articles to return (default 5).'),
  }),
  execute: async ({ topic, limit = 5 }) => {
    const articles = await myKnowledgeBase(topic, limit)
    return { data: JSON.stringify(articles), isError: false }
  },
})

const registry = new ToolRegistry()
registerBuiltInTools(registry)
registry.register(fetchArticles)

const executor = new ToolExecutor(registry)
const agent = new Agent(
  { name: 'analyst', model: 'claude-sonnet-4-6', tools: ['fetch_articles'] },
  registry,
  executor,
)

const result = await agent.run('Summarize the latest changes in the ECMAScript specification.')

You can register as many custom tools as needed. Each one benefits from the same schema-validated, type-safe pipeline that the built-in tools use.


Cross-Provider Model Mixing

One of AnyCode's most practical features is the ability to combine different LLM providers within a single team. Assign a reasoning-heavy model to your strategist and a fast coding model to your implementer — the framework handles routing transparently:

const thinker: AgentConfig = {
  name: 'thinker',
  model: 'claude-opus-4-6',
  provider: 'anthropic',
  systemPrompt: 'You devise architectural blueprints and technical strategies.',
  tools: ['file_write'],
}

const implementer: AgentConfig = {
  name: 'implementer',
  model: 'gpt-5.4',
  provider: 'openai',
  systemPrompt: 'You transform plans into functional, tested code.',
  tools: ['bash', 'file_read', 'file_write'],
}

const team = engine.createTeam('cross-provider', {
  name: 'cross-provider',
  agents: [thinker, implementer],
  sharedMemory: true,
})

await engine.runTeam(team, 'Create a CLI utility that transforms YAML files into JSON format.')

This approach lets you optimize for both capability and cost — use premium models where deep reasoning matters and lighter models where speed is the priority.


Live Streaming Output

For interactive applications or real-time feedback, stream agent output token-by-token as it's generated:

import { Agent, ToolRegistry, ToolExecutor, registerBuiltInTools } from 'anycodejs'

const registry = new ToolRegistry()
registerBuiltInTools(registry)
const executor = new ToolExecutor(registry)

const narrator = new Agent(
  { name: 'narrator', model: 'claude-sonnet-4-6', maxTurns: 3 },
  registry,
  executor,
)

for await (const ev of narrator.stream('Describe the observer pattern in three sentences.')) {
  if (ev.type === 'text' && typeof ev.data === 'string') {
    process.stdout.write(ev.data)
  }
}

The streaming interface returns an AsyncGenerator<StreamEvent>, making it straightforward to pipe output into CLIs, web sockets, or server-sent event streams.


Architecture Overview

The diagram below illustrates how AnyCode's components connect from top-level orchestration down to individual LLM calls:

+--------------------------------------------------------------+
|  AnyCode  (orchestrator)                                     |
|                                                              |
|  createTeam()  ·  runTeam()  ·  runTasks()  ·  runAgent()   |
+-----------------------------+--------------------------------+
                              |
                   +----------v----------+
                   |  Team               |
                   |  AgentConfig[]      |
                   |  MessageBus         |
                   |  TaskQueue          |
                   |  SharedMemory       |
                   +----------+----------+
                              |
                +-------------+-------------+
                |                           |
       +--------v---------+    +------------v-----------+
       |  AgentPool       |    |  TaskQueue             |
       |  Semaphore       |    |  dependency graph      |
       |  runParallel()   |    |  cascade failure       |
       +--------+---------+    +------------------------+
                |
       +--------v---------+
       |  Agent           |    +------------------------+
       |  run / prompt /  |--->|  LLMAdapter            |
       |  stream          |    |  Anthropic · OpenAI    |
       +--------+---------+    +------------------------+
                |
       +--------v---------+
       |  AgentRunner     |    +------------------------+
       |  conversation    |--->|  ToolRegistry          |
       |  loop + dispatch |    |  defineTool + 5        |
       +------------------+    |  built-in tools        |
                               +------------------------+

Data flow summary:

  1. The orchestrator receives a goal or an explicit task list
  2. A Team manages the agent roster, message bus, and shared memory
  3. The AgentPool dispatches work using a bounded concurrency semaphore
  4. The TaskQueue resolves dependencies via topological sort and cascades failures
  5. Each Agent runs a conversation loop through AgentRunner, invoking tools from the ToolRegistry as needed
  6. LLM calls are routed through the LLMAdapter abstraction, supporting any provider

Built-In Tool Reference

AnyCode ships with five practical tools that cover the most common agent operations:

| Tool | What It Does | |------|-------------| | bash | Executes shell commands with stdout/stderr capture, configurable timeout, and working-directory support | | file_read | Reads file contents from an absolute path, with optional offset and line-limit for handling large files | | file_write | Creates or overwrites a file at the specified path — parent directories are generated automatically | | file_edit | Performs targeted substring replacement within a file, with an option to replace all occurrences | | grep | Runs regex-based searches across files, leveraging ripgrep when available or falling back to a pure Node.js implementation |

All tools follow the same defineTool() pattern, so extending or replacing them works identically to registering custom tools.


Core Concepts at a Glance

| Concept | Component | Responsibility | |---------|-----------|----------------| | Conversation loop | AgentRunner | Manages the model ↔ tool turn cycle until the task completes | | Typed tool declaration | defineTool() | Defines tools with Zod-validated input schemas | | Orchestration | AnyCode | Decomposes goals, assigns work, and manages concurrency | | Team coordination | Team + MessageBus | Enables inter-agent messaging and shared knowledge state | | Task scheduling | TaskQueue | Resolves execution order through topological dependency sorting |


Contributing

Contributions, suggestions, and issue reports are welcome. Please open an issue or submit a pull request on the GitHub repository.


License

Released under the MIT License — see LICENSE for details.