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

@liguoshuai/pi-chat-server

v2.20.7

Published

Pi Agent Gateway server for VPS hosting, bridging Web, Android, and HarmonyOS native apps to pi coding agent subprocesses

Readme

@liguoshuai/pi-chat-server — Pi Agent Gateway

@liguoshuai/pi-chat-server 是运行在 VPS 上的 Pi Agent 桥接网关服务,负责协调管理底层 pi --mode rpc 子进程,为 Web 前端、Android 原生端以及鸿蒙原生端提供统一的 WebSocket、SSE、RESTful API 与 Token 鉴权。


核心特性

  • 多端全双工网关:原生支持 Web、Android (OkHttp Flow) 与 HarmonyOS (@ohos.net.webSocket)。
  • 统一 Token 鉴权:支持 AUTH_TOKEN 环境变量,拦截未授权 HTTP/SSE/WebSocket 连接。
  • 打字机流式推送:双通道(WebSocket 实时帧 / SSE 增量事件)低延迟文本增量同步。
  • 断线无损回填 (Replay Buffer):客户端断网重连或切回前台时,自动回填断开期间生成的完整消息流。
  • 会话持久化与后台常驻:客户端断开后后台任务继续执行,空闲指定时间后自动回收内存。
  • CSWSH 跨域防护与心跳保活:自带 30s 协议层 + 应用层心跳检测,自动清理失效连接。

环境变量配置

| 变量名 | 默认值 | 描述 | | :--- | :--- | :--- | | PORT | 3000 | 服务监听端口 | | HOST | 0.0.0.0 | 绑定网卡地址 | | AUTH_TOKEN | "" (留空不鉴权) | 统一访问 Token(Bearer Token / ?token=) | | PI_BIN | 自动检测 | pi 可执行文件绝对路径 | | PI_SESSIONS_DIR| ~/.pi/agent/sessions | 会话 JSONL 存储目录 | | IDLE_TIMEOUT_MS| 1800000 (30分钟) | 无客户端连接且空闲时自动回收进程的超时时间 (0 为不回收) | | MAX_CONCURRENT_AGENTS | 0 (无限制) | 允许并发运行的最大 Pi Agent 子进程数量 | | ALLOWED_ORIGINS| "" | 允许的外部跨域 Origin(逗号分隔) |


快速启动

# 启动网关服务
pnpm --filter @liguoshuai/pi-chat-server start

# 开发模式(监听热重载)
pnpm --filter @liguoshuai/pi-chat-server dev