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

agent-chat-backend

v1.0.15

Published

Agent chat backend (Express + Socket.IO + AI SDK)

Readme

agent-chat-backend

基于 ExpressSocket.IOVercel AI SDK 的会话式 Agent 后端:管理模型配置与会话、流式对话、文件上传,并支持通过 MCP 调用外部工具。

功能概览

  • HTTP API:配置读写、会话 CRUD、文件上传、模型列表探测、内置文档等(详见 docs/API.md)。
  • Socket.IO(路径 /socket.io):前端实时收发聊天流、中止生成等。
  • MCP:可按配置连接 Streamable HTTP、SSE、Stdio 等传输方式的 MCP 服务。
  • 静态资源:若存在 public/ 目录(通常为前端构建产物),会一并托管并支持 SPA 回退到 index.html

环境要求

  • Node.js 18+(推荐 20+;开发与 CI 中常用 22)。

本地运行

cd node/backend
npm install
npm start

默认监听 http://127.0.0.1:3333。修改端口:

# Linux / macOS
PORT=8080 npm start

# Windows PowerShell
$env:PORT=8080; npm start

指定数据目录(会话、上传、配置):

# Linux / macOS
npm start -- --data-dir /data/agent-chat

# Windows PowerShell
npm start -- --data-dir D:\agent-chat-data

启动后控制台会打印 Socket.IO 与 HTTP 地址。

使用 npx(发布后)

npx -y -p agent-chat-backend agent-chat-backend

同样可通过 PORT 指定端口。 也支持通过程序参数传入数据目录:

npx -y -p agent-chat-backend agent-chat-backend --data-dir /data/agent-chat

仅在本地目录调试、不发布到 npm 时,可在本仓库内执行:

cd node/backend
npx .

数据与配置目录

运行时默认会在包根目录下维护 data/(与 src/ 同级);可通过 --data-dir(优先)或 AGENT_CHAT_DATA_DIR 改为外部目录:

| 路径 | 说明 | |------|------| | data/config.json | 模型、MCP、快捷指令等配置(首次访问会自动写入默认模板) | | data/sessions/ | 当前会话 JSON | | data/sessions-archived/ | 已归档会话 | | data/uploads/ | 上传附件 |

通过 npm 全局或 npx 安装 时,若未指定 --data-dir,上述目录位于安装包目录内(例如 node_modules/agent-chat-backend/data)。

环境变量

| 变量 | 说明 | |------|------| | PORT | HTTP 端口,默认 3333。 | | AGENT_CHAT_DATA_DIR | 数据目录(会话/上传/配置)路径。优先级低于 --data-dir。 | | resource_api | 若本地尚无 data/config.json,启动时会尝试从 {resource_api}/config.json 拉取并写入(便于容器/编排注入)。 |

内置文档

服务运行时可访问(返回 Markdown 正文):

  • GET /api/docsdocs/API.md
  • GET /api/docs/changelogdocs/CHANGELOG.md

前端构建产物

将前端构建输出放到本目录的 public/ 下(含 index.html),后端会自动启用静态托管与前端路由回退。无 public/ 时仍可单独作为 API + Socket 服务使用。

npm 发布说明

发布前可用 npm pack --dry-run 检查打进包的文件;package.jsonfiles 字段已限制为运行所需内容(srcpublicdocs)。更详细的登录与发布步骤可参考同目录下的 npmjs.md

许可证

ISC(见 package.json)。