@musistudio/bot-gateway
v1.0.0
Published
A pluggable cross-IM bot gateway built with Fastify.
Maintainers
Readme
Bot Gateway
Bot Gateway 是一个基于 Fastify 的可插拔跨 IM Bot 网关。它把不同 IM 平台的入站消息归一化为 GatewayEvent,让外部 Agent 通过 HTTP、WebSocket 或 stdio 消费事件,再把统一的 OutboundIntent 渲染回对应平台。
网关不内置业务 Agent。你的 Agent 运行在网关外部,负责产品逻辑、LLM 调用、工作流执行和事件确认。
架构
ChannelAdapter负责平台差异、入站归一化和出站渲染。Transport负责 IM 平台侧连接方式:webhook、long polling、websocket 或 outgoing webhook。AgentProtocol负责外部 Agent 接入方式:HTTP、WebSocket 或 stdio。Runtime负责平台无关可靠性:去重、队列、会话映射、限流、重试、审计和用量计量。
快速开始
npm install
npm run devHTTP 服务默认监听 0.0.0.0:3000。
不启动 HTTP 服务时使用 stdio 模式:
npm run dev:stdio构建和验证:
npm test
npm run build安装已发布包:
npm install @musistudio/bot-gateway
npx @musistudio/bot-gateway
npx -p @musistudio/bot-gateway bot-gateway-stdio本地运行状态默认存储在 .bot-gateway-state/。可以通过环境变量覆盖:
BOT_GATEWAY_STATE_DIR=/secure/path/bot-gateway-state npm run dev生产环境建议替换为数据库和加密凭证存储。
文档
支持的平台
Bot Gateway 已包含或预留 Weixin iLink、Telegram、Slack、Discord、LINE、飞书、钉钉、WeCom 和 iMessage 的 adapter。各平台能力取决于具体 adapter 实现,当前状态和示例见使用指南与 Agent 接入指南。
License
MIT. See LICENSE.
