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

node-swarmjs

v0.0.1

Published

A framework for building AI Agents

Downloads

3

Readme

Swarm.js (Node.js Implementation of OpenAI Swarm)

Swarm.js is a Node.js implementation of OpenAI's experimental Swarm framework[https://github.com/openai/swarm]. Also following this cookbook from OpenAI[https://cookbook.openai.com/examples/orchestrating_agents]. I took some inspiration from both the repo and the cookbook to create my own Node.js implementation of Swarm. This library also supports anthropic sdk, so you are not limited to just using openai.

Install

You can install the Swarm.js library via npm:

npm install node-swarmjs

What is Swarm.js?

Swarm.js focuses on multi-agent coordination and execution by defining lightweight agents that can carry out tasks and hand off conversations when necessary. Heavily inspired by OpenAI's Python Swarm framework, this Node.js implementation allows developers to build multi-agent systems that are highly customizable, scalable, and easy to use.

Warning

This is currently in the early stages of development and is not yet ready for production use. There are no tests and some of the core functionality is missing(e.g. this doesn't yet support streaming responses from agents).

Usage

Swarm.js makes it easy to define agents, assign them tasks, and manage interactions between them. Below is a simple example demonstrating how to create and orchestrate two agents.

const { Swarm, Agent } from 'node-swarmjs';

 const client = new Swarm({
    apiKey: process.env.OPENAI_API_KEY,
    clientType: 'openai'// can also be anthropic,
  });

// define the agents
  function transferToAgentB()  {
    return agentB;
  }

  const agentA = new Agent({
    name: 'Agent A',
    instructions: 'You are a helpful agent',
    functions: [transferToAgentB],
  });

  const agentB = new Agent({
    name: 'Agent B',
    instructions: 'Only speak in Haiku.',
  });

  // run the conversation with agentA
  (async () => {
  try {
    const response = await client.run({
      agent: agentA,
      messages: [{ role: "user", content: "I want to talk to agent B." }]
    });

    console.log(response.messages[response.messages.length - 1].content);
  } catch (error) {
    console.error('An error occurred:', error);
  }
})();

Example with Anthropic

const { Swarm, Agent } = require('node-swarmjs');

const client = new Swarm({
  apiKey: process.env.ANTHROPIC_API_KEY,
  clientType: 'anthropic',
});

function transferToAgentB() {
  return agentB;
}

const agentA = new Agent({
  name: 'Agent A',
  instructions: 'You are a helpful agent',
  functions: [transferToAgentB],
});

const agentB = new Agent({
  name: 'Agent B',
  instructions: 'Only speak in Haiku.',
});

(async () => {
  try {
    const response = await client.run({
      agent: agentA,
      messages: [{ role: 'user', content: 'I want to talk to agent B.' }],
    });

    console.log(response.messages[response.messages.length - 1].content);
  } catch (error) {
    console.error('An error occurred:', error);
  }
})();

License

This project is licensed under the MIT License. See the LICENSE file for more details.

Roadmap

Core Functionality

  • [ ] Expand LLM Support
    • [ ] Integrate with Hugging Face models
    • [x] Add support for Anthropic
    • [ ] Implement Azure OpenAI Service integration
  • [ ] Enhance Agent Capabilities
    • [ ] Implement streaming responses from agents
    • [ ] Develop context passing mechanism between agents
    • [ ] Create advanced conversation routing logic
    • [ ] Add support for concurrent agent execution

Integration and Tools

  • [ ] LangChain Integration
    • [ ] Implement support for LangChain tools
    • [ ] Create adapters for LangChain agents
  • [ ] UI Components
    • [ ] Develop drop-in React components for easy UI integration
  • [ ] Database Connectors
    • [ ] Add support for vector databases (e.g., Pinecone, Weaviate)
    • [ ] Implement connectors for relational databases
  • [ ] CLI
    • [ ] Add a CLI for easy setup of agents(ideally use be able to bootstrap your agents from a CLI inside your NextJS app, or express server)

Reliability and Performance

  • [ ] Implement Retry Mechanism
    • [ ] Add exponential backoff for failed requests
  • [ ] Optimize Performance
    • [ ] Implement caching layer for frequent requests
    • [ ] Add support for batch processing of tasks

Developer Experience

  • [ ] Expand Documentation
    • [ ] Create comprehensive API reference
    • [ ] Write step-by-step tutorials for common use cases
  • [ ] Improve Testing
    • [ ] Increase unit test coverage to 80%(currently there are no tests)
    • [ ] Add performance benchmarks

Examples and Use Cases

  • [ ] Develop Example Projects
    • [ ] Create a customer support chatbot example
    • [ ] Build a multi-agent collaborative task solver
    • [ ] Implement a document analysis and summarization system

Community and Ecosystem

  • [ ] Improve Contribution Process
    • [ ] Develop contributor guidelines
    • [ ] Set up automated code quality checks for pull requests