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

@baize-ai/baize-wecom

v0.2.0

Published

WeCom (企业微信) communication channel for Baize agents - WebSocket bot mode

Readme


功能特性

  • WebSocket 长连接 -- 通过企业微信智能机器人 WebSocket 协议连接
  • 无需公网 IP -- 出站 WebSocket 连接,无需回调 URL 或 SSL
  • 简单凭证 -- 仅需 Bot ID + Secret(2 个值,无需 corpSecret/token/AES key)
  • 消息类型 -- 支持文本、Markdown 发送;文本、图片、语音、视频、文件接收
  • 访问控制 -- 私聊策略(开放/白名单/仅主人)和群聊策略(按群配置)
  • 主人自动绑定 -- 第一个发送私聊消息的用户自动成为主人
  • 上下文追踪 -- 内存中的聊天记录用于上下文对话
  • 自动重连 -- 断线后指数退避 + 随机抖动重连
  • C4 桥接 -- 标准 Baize 通讯桥接集成
  • 管理 CLI -- 无需手动编辑 JSON 的配置管理
  • 热重载 -- 配置更改无需重启即可生效(大部分设置)
  • 官方办公 CLI -- 固定安装官方 wecom-cli,并内置 14 个模块化 Skill 与 Unified 聚合路由,覆盖通讯录、文档、表格、日程、会议、待办、微盘、 邮件、消息和媒体能力

环境要求

  • Node.js >= 20.0.0
  • 企业微信企业账号
  • 管理员权限(用于创建智能机器人)

快速开始

1. 安装

# 通过 Baize CLI
baize add wecom

# 或手动安装
git clone https://github.com/baize-ai/baize-wecom.git ~/baize/.claude/skills/wecom
cd ~/baize/.claude/skills/wecom
npm install
node hooks/post-install.js

2. 创建智能机器人

  1. 打开企业微信客户端 > 工作台 > 智能机器人 > 创建机器人
  2. 选择 API模式创建(需要管理员权限)
  3. 选择 使用长连接
  4. 复制 Bot ID(格式:aibXXX)和 Secret
  5. Secret 只显示一次 -- 立即保存

3. 配置凭证

添加到 ~/baize/.env:

WECOM_BOT_ID=aibxxxxxxxxxxxxxxxx
WECOM_BOT_SECRET=你的bot_secret

4. 启动服务

pm2 start ecosystem.config.cjs
pm2 logs baize-wecom

5. 测试

向企业微信机器人发送一条消息。第一个发送私聊消息的用户将成为主人。

6. 授权办公能力

通信长连接与办公 CLI 使用独立授权存储,但两者必须代表同一个已配置 Bot。 首次办公请求必须从已绑定 owner 的企业微信私聊发起。Agent 会检查当前 CLI Principal;需要授权时,执行托管的同 Bot 授权:

node scripts/wecom-cli-auth.js --check-channel-bot
node scripts/wecom-cli-auth.js --reuse-channel-bot \
  --endpoint '<原企业微信回复 endpoint>'

helper 只通过 stdin/PTY 把现有消息 Bot 凭证交给官方 CLI,不进入 argv、子进程 环境变量或日志。它会原子消费该 owner 私聊的一次性来源记录,校验 CLI Bot ID 与消息 Bot ID 完全一致,然后自动重试原办公请求一次。整个过程不扫码、不创建 额外 Bot;群聊或非 owner 请求必须转到 owner 私聊。

组件不支持直接运行 wecom-cli auth init:它可能创建独立 Bot,而强制的同 Bot 业务门禁会拒绝该 Principal。

配置

配置文件

~/baize/components/wecom/config.json

{
  "enabled": true,
  "internal_port": 4459,
  "owner": { "bound": false, "user_id": "", "name": "" },
  "dmPolicy": "owner",
  "dmAllowFrom": [],
  "groupPolicy": "allowlist",
  "groups": {},
  "message": { "context_messages": 10, "welcome_text": "" },
  "ws": {
    "url": "wss://openws.work.weixin.qq.com",
    "heartbeat_interval": 30000,
    "reconnect_initial_delay": 1000,
    "reconnect_max_delay": 30000
  }
}

管理命令

ADM="node ~/baize/.claude/skills/wecom/src/admin.js"

$ADM show                    # 显示完整配置
$ADM show-owner              # 显示主人信息
$ADM set-dm-policy owner     # 设置私聊策略
$ADM list-dm-allow           # 查看私聊白名单
$ADM add-dm-allow <user_id>  # 添加用户到白名单
$ADM help                    # 显示所有命令

访问控制

私聊策略

| 策略 | 行为 | |------|------| | owner | 仅主人可私聊(默认,最严格) | | allowlist | 仅白名单用户可私聊 | | open | 任何人可私聊 |

主人始终绕过所有访问检查。

群聊策略

| 策略 | 行为 | |------|------| | disabled | 丢弃所有群消息 | | allowlist | 仅已配置的群生效(默认) | | open | 响应所有群 |

架构设计

详见 DESIGN.md。

服务管理

pm2 status baize-wecom     # 查看状态
pm2 logs baize-wecom       # 查看日志
pm2 restart baize-wecom    # 重启服务
pm2 stop baize-wecom       # 停止服务

许可证

MIT