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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@agentswarmprotocol/agentsdk

v1.0.2

Published

SDK for building agents compatible with Agent Swarm Protocol

Downloads

9

Readme

SwarmAgentSDK

The SwarmAgentSDK provides a simple way for agents to connect to and interact with the Agent Swarm Protocol orchestrator.

Installation

npm install @agent-swarm/agent-sdk

Basic Usage

const { SwarmAgentSDK } = require('@agent-swarm/agent-sdk');

// Create a new agent
const agent = new SwarmAgentSDK({
  name: 'MyAgent',
  description: 'A simple agent built with SwarmAgentSDK',
  capabilities: ['text-processing']
});

// Connect to the orchestrator
agent.connect()
  .then(() => {
    console.log('Connected to orchestrator');
  })
  .catch(error => {
    console.error('Error:', error.message);
  });

// Register a task handler
agent.onMessage('text-processing', async (taskData, metadata) => {
  console.log('Received text processing task:', taskData);
  
  // Process the text
  const processedText = taskData.text.toUpperCase();
  
  // Send task notifications to update the client on progress
  await agent.sendTaskNotification({
    taskId: metadata.taskId,
    notificationType: 'progress',
    message: 'Starting text processing...',
    data: { progress: 0 }
  });
  
  // Simulate some processing time
  await new Promise(resolve => setTimeout(resolve, 1000));
  
  await agent.sendTaskNotification({
    taskId: metadata.taskId,
    notificationType: 'progress',
    message: 'Processing text...',
    data: { progress: 50 }
  });
  
  await new Promise(resolve => setTimeout(resolve, 1000));
  
  await agent.sendTaskNotification({
    taskId: metadata.taskId,
    notificationType: 'progress',
    message: 'Finalizing results...',
    data: { progress: 90 }
  });
  
  // Return the result
  return {
    processedText
  };
});

// Listen for events
agent.on('error', (error) => {
  console.error('Agent error:', error.message);
});

Configuration Options

The SwarmAgentSDK constructor accepts a configuration object with the following properties:

| Property | Type | Description | Default | |----------|------|-------------|---------| | name | string | Name of the agent | Required | | description | string | Agent description | '' | | orchestratorUrl | string | WebSocket URL of the orchestrator | 'ws://localhost:3000' | | capabilities | Array | Agent capabilities | [] | | autoReconnect | boolean | Whether to auto-reconnect | true | | reconnectInterval | number | Reconnect interval in ms | 5000 |

Key Features

Task Handling

  • onMessage(taskType, handler): Register a handler for a specific task type
  • onMessage('*', handler): Register a default handler for all task types
  • sendTaskResult(taskId, result): Send a task result back to the client

Task Notifications

  • sendTaskNotification(notification): Send a notification to inform clients about task progress
  • onNotification(handler): Register a handler for receiving notifications from the orchestrator

Agent Communication

  • getAgentList(filters): Get a list of all available agents
  • executeAgentTask(targetAgentName, taskType, taskData): Ask another agent to execute a task

MCP Integration

  • getMCPServers(filters): Get a list of available MCP servers
  • getMCPTools(serverId): Get a list of tools available on an MCP server
  • executeMCPTool(serverId, toolName, parameters): Execute an MCP tool
  • executeTool(toolName, parameters): Simplified method to execute an MCP tool

Connection Management

  • connect(): Connect to the orchestrator
  • disconnect(): Disconnect from the orchestrator

Service Communication

  • executeServiceTask(serviceId, functionName, params, options): Execute a task on a service
    • Allows agents to call functions provided by services with real-time notification updates
    • The options.onNotification callback receives progress updates during execution
  • getServiceList(filters): Get a list of available services

Events

The SDK emits the following events:

  • connected: Emitted when connected to the orchestrator
  • registered: Emitted when the agent is registered with the orchestrator
  • disconnected: Emitted when disconnected from the orchestrator
  • error: Emitted when an error occurs
  • message: Emitted for all received messages
  • task: Emitted when a task is received

License

MIT