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

@houchenyang/nexus-gateway

v1.0.6

Published

AI Bot Gateway - Connect web users to AI assistants

Readme

Nexus Gateway

AI Bot Gateway - 连接 Web 用户与 AI 助手的网关服务。

这是 OpenClaw Nexus 项目的网关服务端组件。

特性

  • 用户登录认证
  • 多 Bot 连接管理
  • Bot 连接令牌校验
  • 实时消息转发(支持流式输出)
  • 简洁的 Web API
  • 内置 Web 聊天界面

安装

# 创建工作目录
mkdir nexus-gateway && cd nexus-gateway

# 安装
npm install -g @houchenyang/nexus-gateway

# 启动(会在当前目录生成 config.json 和 index.html)
nexus-gateway

配置

编辑 config.json(首次启动会自动创建):

{
  "port": 17392,
  "botToken": "your-secret-token",
  "users": {
    "admin": {
      "password": "your-password",
      "displayName": "管理员"
    }
  }
}
  • port: 服务端口
  • botToken: Bot 连接认证令牌,留空则不校验
  • users: Web 用户账号配置

后台运行

# 安装 pm2
npm install -g pm2

# 在工作目录下启动(重要:必须在 config.json 所在目录执行)
cd /your/nexus-gateway
pm2 start $(which nexus-gateway) --name nexus

# 查看状态
pm2 status

# 查看日志
pm2 logs nexus

# 停止/重启
pm2 stop nexus
pm2 restart nexus

# 开机自启
pm2 save
pm2 startup

源码运行

git clone https://github.com/hcy050617/openclaw-nexus.git
cd openclaw-nexus/nexus-gateway
pnpm install
pnpm build

# 启动
pnpm start

# 后台启动
nohup pnpm start > nexus.log 2>&1 &

# 查看日志
tail -f nexus.log

# 停止
pkill -f "node dist/index.js"

# 重启
pkill -f "node dist/index.js" && nohup pnpm start > nexus.log 2>&1 &

Web 界面

启动后访问 http://localhost:17392 即可使用内置的 Web 聊天界面,支持:

  • 用户登录认证
  • 在线 Bot 列表
  • Markdown 渲染
  • 代码高亮
  • 流式输出

部署

创建服务文件 /etc/systemd/system/nexus.service

[Unit]
Description=Nexus Gateway
After=network.target

[Service]
Type=simple
User=nobody
WorkingDirectory=/opt/nexus
ExecStart=/usr/bin/node dist/index.js
Restart=on-failure
RestartSec=5

[Install]
WantedBy=multi-user.target

启用服务:

sudo systemctl daemon-reload
sudo systemctl enable nexus

管理服务:

# 启动
sudo systemctl start nexus

# 停止
sudo systemctl stop nexus

# 重启
sudo systemctl restart nexus

# 查看状态
sudo systemctl status nexus

# 查看日志
sudo journalctl -u nexus -f

API

认证

# 登录
POST /api/login
{"username": "admin", "password": "xxx"}

# 返回
{"token": "xxx", "user": {...}, "expiresAt": ...}

聊天

# 发送消息 (需要 Bearer token)
POST /api/chat
Authorization: Bearer <token>
{"message": "你好"}

# 流式聊天 (SSE)
POST /api/chat/stream
Authorization: Bearer <token>
{"message": "你好"}

# 查看在线 Bot
GET /api/bots
Authorization: Bearer <token>

健康检查

GET /health

Bot 连接协议

Bot 通过 WebSocket 连接 /bot-ws

// 注册
{"type": "register", "botId": "my-bot", "botName": "My Bot", "token": ""}

// 收到消息
{"type": "chat", "id": "xxx", "content": "你好", "from": "用户名", "timestamp": ...}

// 回复
{"type": "reply", "id": "xxx", "replyTo": "xxx", "content": "回复内容", "done": true, "timestamp": ...}

// 心跳
{"type": "ping"} / {"type": "pong"}

架构

用户 (Web/App)
      │
      ▼
┌─────────────┐
│   Nexus     │ ◄── HTTP API (登录/聊天)
│   Gateway   │
└──────┬──────┘
       │ WebSocket
       ▼
┌─────────────┐
│   AI Bot    │ ◄── 运行 AI 助手
└─────────────┘

Nginx 反向代理

location /bot-ws {
    proxy_pass http://127.0.0.1:17392;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    proxy_read_timeout 86400;
}

location /api/ {
    proxy_pass http://127.0.0.1:17392;
}

License

MIT