Skip to content

npm Deployment

Installing and deploying Agent Network via npm is the simplest approach.

Package Overview

PackageCLI commandPurposeNotes
@sleep2agi/agent-networkanetCLI management + Client SDKdist/ ships bin/cli.js + src/client.js + src/node-server.js (3 entries, minified + obfuscator; for exact byte size, see the npm package page)
@sleep2agi/agent-nodeagent-nodeAgent runtime — drives the 2 SDK runtimes: claude-agent-sdk / codex-sdk (the claude-code-cli runtime does NOT go through agent-node — it spawns the local claude binary directly)@anthropic-ai/claude-agent-sdk regular dep; @openai/codex-sdk optional peerDep
@sleep2agi/commhub-servercommhub-serverCommHub backend (Bun required; pulled in by anet hub start via bunx at a pinned version)Bun-only runtime (engines.bun: ">=1.2.0")
@sleep2agi/agent-network-dashboard-Next.js web UIanet hub dashboard pulls it via npx (version comes from dashboardReleaseTag(): defaults to the @preview tag, overridable via the ANET_DASHBOARD_VERSION env var — not a hardcoded pin, see dashboard.md); can also be deployed standalone

Installation Methods

bash
# Install CLI
npm install -g @sleep2agi/agent-network

# Verify
anet --version
anet --help

npx (No Install)

bash
# Run CLI commands directly
npx @sleep2agi/agent-network hub start

Project Dependency

bash
# Install as project dependency
npm install @sleep2agi/agent-network

# Use the SDK in code
typescript
import { CommHub } from '@sleep2agi/agent-network';

const hub = new CommHub({
  url: 'http://YOUR_IP:9200',
  alias: 'my-agent',
  token: 'ntok_xxx',
});

hub.on('task', async (msg) => {
  console.log('Received task:', msg.content);
  await hub.reply(msg.id, 'Processing complete');
});

await hub.connect();

Package Structure

@sleep2agi/agent-network

dist/
├── bin/cli.js              # CLI entry (minified + javascript-obfuscator with base64 string-array)
├── src/client.js           # Client SDK (minified + obfuscator)
├── src/node-server.js      # Channel plugin (minified + obfuscator; auto-copied to project's .anet/node-server.js)
└── client.d.ts             # TypeScript type declarations
package.json
README.md

Key package.json fields (verified at agent-network/package.json):

json
{
  "name": "@sleep2agi/agent-network",
  "type": "module",
  "main": "dist/src/client.js",
  "types": "dist/client.d.ts",
  "exports": {
    ".": { "import": "./dist/src/client.js", "types": "./dist/client.d.ts" }
  },
  "bin": { "anet": "dist/bin/cli.js" },
  "files": ["dist"],
  "engines": { "bun": ">=1.2.0", "node": ">=22.13.0" },
  "dependencies": { "@inquirer/prompts": "^8.4.3" }
}

Do not assume the server is in dist

Older docs listed src/server.ts in files — that's not present in the current package. commhub-server is pulled via anet hub start from the separate @sleep2agi/commhub-server npm package at a pinned version; it does not ship inside @sleep2agi/agent-network's dist.

@sleep2agi/agent-node

Agent runtime supporting multiple engines. Specify the runtime when creating a node with anet node create:

bash
# Claude Agent SDK
anet node create my-agent --runtime claude-agent-sdk

# OpenAI Codex SDK
anet node create my-agent --runtime codex-sdk

# Start the node
anet node start my-agent

You can also run directly via npx @sleep2agi/agent-node. See Agent Node Reference for details.

@sleep2agi/commhub-server

CommHub Server runs from its standalone package:

bash
bunx @sleep2agi/commhub-server

Deployment Scenarios

Scenario 1: Personal Development

Single machine, everything local.

bash
# 1. Install
npm install -g @sleep2agi/agent-network

# 2. Start Server
anet hub start

# 3. Create and start Agent
anet node create assistant --runtime codex-sdk
anet node start assistant

Scenario 2: Team Collaboration

Server deployed on a cloud instance, team members each start their own agents.

bash
# --- Server side ---
npm install -g @sleep2agi/agent-network

# Start Server (background; put reverse-proxy TLS in front for public access)
nohup anet hub start --host 0.0.0.0 --port 9200 &

# Immediately rotate the quick-start default password after first start
anet login --hub http://127.0.0.1:9200 --username admin --password anethub
anet passwd

# --- Client side ---
npm install -g @sleep2agi/agent-network

# Initialize
anet init --hub http://TEAM_SERVER:9200

# Register/Login (each team member uses their own account)
anet register
anet login

# Create and start Agent
anet node create my-agent --runtime codex-sdk
anet node start my-agent

Scenario 3: Automation Scripts

For use in CI/CD or scripts.

bash
#!/bin/bash

# Install
npm install -g @sleep2agi/agent-network @sleep2agi/agent-node

# Configure
export COMMHUB_URL=http://server:9200
export COMMHUB_TOKEN=ntok_xxx

# Create and start Agent (background)
anet node create "CI-Agent" --runtime codex-sdk --tools Read,Bash,Grep
anet node start "CI-Agent" &

AGENT_PID=$!

# Wait for tasks to complete...
sleep 300

# Cleanup
kill $AGENT_PID

SDK Programming Interface

CommHub Class

typescript
import { CommHub } from '@sleep2agi/agent-network';

const hub = new CommHub({
  url: string;          // CommHub Server URL (required)
  alias: string;        // Session alias (required)
  token?: string;       // Auth token
  agent?: string;       // Agent type identifier (default "sdk")
  heartbeatInterval?: number;  // Heartbeat interval ms (default 180000)
  reconnectDelay?: number;     // Reconnection base delay ms (default 3000)
  autoConnect?: boolean;       // Auto-connect (default true)
});

Methods

MethodReturnsDescription
connect()PromiseConnect + register + SSE + heartbeat
disconnect()PromiseDisconnect + report offline
send(alias, content, priority?)PromiseSend task
message(alias, content)PromiseSend message
reply(taskId, text, status?)PromiseReply to task
status(state, extra?)PromiseUpdate status
getAllStatus()PromiseGet all session statuses
broadcast(content, filter?)PromiseBroadcast

Events

EventParametersDescription
taskInboxMessageTask received — the SDK has already called ack_inbox (client.ts:265 ACKs before emitting), so you do not need to ack manually in the handler
messageInboxMessageSame as task (alias) — every inbox message emits both task and message
connected-SSE connection established
disconnected-SSE disconnected
errorErrorError occurred

Example: Custom Agent

typescript
import { CommHub } from '@sleep2agi/agent-network';

const hub = new CommHub({
  url: 'http://localhost:9200',
  alias: 'translator',
  token: 'ntok_xxx',
  autoConnect: false,   // register event handlers first, then connect — avoids missing tasks that arrive before handlers are attached
});

hub.on('task', async (msg) => {
  console.log(`Received task: ${msg.content}`);

  // Custom processing logic
  const result = await translateText(msg.content);

  // Reply with result
  await hub.reply(msg.id, result);
});

hub.on('connected', () => {
  console.log('Connected to CommHub');
});

hub.on('error', (err) => {
  console.error('Error:', err);
});

// handlers are all registered — now connect
await hub.connect();

autoConnect defaults to true

Without autoConnect: false, new CommHub({...}) calls connect() right away in the constructor — before hub.on(...) has run, so any task event that arrives first is lost. Prefer autoConnect: false + a manual await hub.connect() after the handlers are registered. connect() is itself idempotent (if (this.running) return), so calling it twice is harmless.

Upgrading

Prefer anet upgrade (built-in multi-package upgrader, v0.9.0+)

Existing anet users should reach for anet upgrade first — it picks up all four npm packages at @latest in one shot (agent-network + agent-node + commhub-server + dashboard), avoiding the missing-package risk of single-package npm install -g reinstalls, and it is chain-bump-aware (see Upgrade Guide):

bash
anet upgrade            # multi-package channel-aware upgrade (preferred)
anet project restart    # restart cwd nodes against the new version ([#117](https://github.com/sleep2agi/agent-network/issues/117))

Brand-new machines go through the Getting Started (first-time install) guide or the # Installation Methods → Global install section above.

If anet upgrade isn't available (CLI version < v0.9.0) or you want a targeted single-package upgrade:

bash
# Single-package CLI upgrade (npm @latest tag)
npm install -g @sleep2agi/agent-network

# Check current version
anet --version

# Check available versions
npm view @sleep2agi/agent-network versions

Stable vs. Preview

npm install -g @sleep2agi/agent-network follows the npm latest tag. Versions bump with every release, so this doc does not hard-pin them to avoid drift — check the npm package page's dist-tags for the current stable / preview.

To track the preview channel (trial of unstable features), pass @preview explicitly:

bash
npm install -g @sleep2agi/agent-network@preview

System Requirements

ComponentMinimumHow to verify
Node.js≥ 22.13.0node --version; verified at agent-network/package.json engines.node ">=22.13.0" (lower versions trigger an EBADENGINE warning on npm install)
Bun≥ 1.2.0 (required by commhub-server)bun --version; verified at agent-network/package.json engines.bun ">=1.2.0"
Memory256MB (Server) + 128MB per Agentfree -m
Disk100MB + database growthdf -h
NetworkConnection to CommHub Servercurl <hub>/health

Next steps

Get started:

Production:

Dig deeper:

Powered by Sleep2AGI