Skip to main content
Glama

notifs

English · 简体中文

面向人、程序与 AI Agent 的可组合异步通信总线 —— 用订阅规则自由拼装任意协作拓扑。

OpenCode 2.x · Codex App Server · MCP

CI License npm version npm downloads Version Node


别再为每个脚本、AI Agent 和聊天软件写胶水代码了。

notifs 不预设团队角色、任务状态机或会话锁,而是将人(飞书 / 企微 / 移动端)、脚本程序与 **AI Agent(OpenCode / Codex)**拉平为完全对等的通信节点。任何参与者只需持有身份凭据(Token)即可单向发布 { type, content };中心基于 SQLite WAL 持久化、按订阅规则路由、按目标独立攒批限频,并主动推送到对应适配器。

所有协作关系都由 身份(Identity)+ 接收目标(Endpoint)+ 订阅(Subscription) 三种原语自由拼装而成 —— 你可以像插拔网线一样,零编排代码组合出任意人机与多 Agent 拓扑,甚至允许主 Agent 在运行时通过 MCP 动态改写拓扑本身。

它不是什么?(为什么选 notifs)

名字虽然叫 notifs,但通知推送只是它的一个出口:

  • 不是单纯的推送转发器(如 ntfy / Apprise):推送工具只管“单向发给人”,notifs 管的是人、程序、Agent 之间的双向、多跳、条件路由与会话续接。

  • 不是重型多 Agent 编排框架(如 LangGraph / CrewAI):不锁死你的模型、语言或执行循环;任何能发 HTTP、Unix Socket 或调用 MCP 的进程都能即插即用。

  • 不是分布式重型 MQ(如 Kafka / NATS):单机 Node.js + SQLite WAL 零依赖部署,开箱自带飞书长连接、NAT 反向穿透、攒批省 Token、Agent 非用户通道边界。

Related MCP server: agent-center

无限拓扑:一套原语拼出 6 种典型玩法

把节点类型(人 / 程序 / Agent)、内容条件过滤(all[])、时间攒批(max_wait_ms / min_interval_ms / paused)、会话分流(fixed / thread / chat / batch / key)与 MCP 动态编排正交组合,可以零代码拼出各种实用甚至反直觉的协作网络:

所有上图拓扑均已提供开箱即用的蓝图配方,详见 examples/topologies/:

拓扑配方

一句话玩法

蓝图文件

飞书双向对话本地 Agent

飞书长连接入站 + 反向 WebSocket 穿透 NAT,按回复树续接 OpenCode / Codex 会话

01-feishu-coding-agent.json

零代码红蓝对抗审查环

approved=false 自动回流给编码 Agent 重写,approved=true 熔断环路并通知人类

02-red-blue-review-loop.json

时间折叠 & 夜间批处理

高频报错攒批降噪省 Token;或白天 paused: true 积压、半夜 resume 批量跑完出日报

03-time-folded-night-batch.json

影子旁路审计 / 记忆提炼

将主链路的人机对话静默抄送给旁路 Agent,主链路零感知,后台异步提炼记忆或风控

04-shadow-memory-tap.json

多 Agent 赛马 & 裁判汇流

同一提问同时扇出给 OpenCode 与 Codex 并发求解,汇入裁判 Agent 评优后推手机

05-multi-agent-race.json

NAT 穿透 + MCP 动态编排

中心配 stream 接内网 notifs bridge,并给主 Agent --manager 权限按需现场连线

06-nat-bridge-and-mcp-manager.json

快速开始

安装与启动

npm install -g notifs
notifs init
notifs start

或从源码构建运行:

pnpm install && pnpm build
node dist/cli.mjs init
node dist/cli.mjs start

支持生成 systemd 用户级服务实现常驻运行:

notifs service install
systemctl --user daemon-reload
systemctl --user enable --now notifs

30 秒拼装一条“事件驱动 → Agent 排查 → 通知人”链路

notifs init 会生成根控制者凭据(默认身份 owner)。下面用 4 条命令拼出一条“只有失败数大于 0 才唤醒 Agent,并将排查报告推给本地桌面”的链路:

# 1. 创建监控脚本身份、Agent 身份,以及可动态改拓扑的管理身份
notifs identity add monitor
notifs identity add ops-agent
notifs identity add coordinator --manager

# 2. 分别为 Agent 与人类配置出站目标(Agent 独立攒批 5 秒防频繁唤醒)
notifs endpoint put --config '{
  "name": "agent/ops",
  "owner": "ops-agent",
  "max_wait_ms": 5000,
  "delivery": {
    "kind": "opencode",
    "config": { "url": "http://127.0.0.1:4096", "session_mode": "batch" }
  }
}'
notifs endpoint put --config '{
  "name": "human/desktop",
  "owner": "owner",
  "delivery": { "kind": "local", "config": {} }
}'

# 3. 用订阅规则把节点连起来(带 JSON 内容谓词过滤)
notifs subscription put --config '{
  "name": "wake-ops-on-failure",
  "endpoint": "agent/ops",
  "source": "owner",
  "type": "metrics.*",
  "all": [{ "field": "stats.failed", "op": "gt", "value": 0 }]
}'
notifs subscription put --config '{
  "name": "ops-report-to-human",
  "endpoint": "human/desktop",
  "source": "ops-agent",
  "type": "report.*"
}'

# 4. 单向发信:命中 stats.failed > 0 自动触发 Agent,否则静默忽略
notifs message send --type metrics.build --content '{"repo":"notifs","stats":{"failed":2}}'

也可以直接用蓝图文件一键预演并应用整套拓扑:

notifs topology apply examples/topologies/02-red-blue-review-loop.json --vars-file vars.yaml --dry-run
notifs topology apply examples/topologies/02-red-blue-review-loop.json --vars-file vars.yaml --tokens-file tokens.json

核心设计特性

  • 纯单向通信(Fire-and-Forget):全员发完即结束当前轮次,无同步阻塞等待,彻底解耦生产者与消费者。

  • AI Native 安全边界:

    • 中心 → Agent:默认经宿主非用户输入通道投递,并以 <agent-messages> 标记不可信数据,防止提示词注入;仅对可信入口显式开启 user_prompt: true。

    • Agent → 中心:Agent 通过 MCP send 或 HTTP/IPC 显式发信,中心不解析模型最终文本或思维链。

  • 内核保真与边缘渲染:内核全程保留原始 JSON 结构,按目标独立控制攒批窗口(max_wait_ms、max_messages、max_bytes)与触发间隔(min_interval_ms)。程序收到结构化批次,Agent 收到合并后的单次上下文注入,人类渠道在适配器边缘渲染为卡片或文本。

  • 动态拓扑与蓝图迁移:管理身份(--manager)可通过 CLI、HTTP 或 MCP 工具动态增删身份、目标与订阅,并支持导出蓝图、预演(--dry-run)与原子应用。

  • 单机持久化与可靠交付:基于 SQLite WAL 原子落盘消息与各目标投递责任,内置租约续期、指数退避重试、挂起(Held)/ 恢复(Resume)、在线热备份与过期清理。

接入矩阵

入站(发布与管理)

所有入站方式共用同一套身份认证、幂等键(Idempotency-Key)与订阅路由语义;可选参数 to 用于在订阅命中范围内进一步缩窄目标。

  • HTTP API:POST /api/messages,携带 Authorization: Bearer <token>。

  • Unix Socket IPC:同机低延迟通道(默认 notifs.sock),CLI 与 MCP 均可通过 --socket 直连。

  • MCP Server:运行 notifs mcp。所有身份可用 send、inspect;管理身份额外解锁 create_identity、set_endpoint、set_subscription、export_topology、apply_topology 等全套编排工具。

  • 平台入站 Bridge:独立进程 notifs-feishu-inbound,支持飞书长连接(无需公网 IP)与 HTTP 回调,自动过滤无关群聊并签发防伪回复句柄。

出站(Delivery Adapters)

同一个身份可绑定多个接收目标,各目标独立配置攒批、限频与暂停策略:

  • AI Agent 宿主:opencode 与 codex 支持 fixed、thread、chat、batch、key 五种会话分流模式。

  • 程序与跨网桥接:webhook 通过 HTTP POST 交付完整批次;stream 通过接收端主动发起的反向 WebSocket 穿透 NAT(配合 notifs bridge 在本地交付给任意适配器)。

  • 即时通讯与推送:feishu(飞书群机器人)、feishu-app(飞书企业应用,支持单聊/群聊/富文本/2.0 卡片与动态回复)、wecom(企业微信机器人)、bark(iOS 推送)、ntfy(自建/移动端推送)、local(Linux notify-send 桌面通知与日志回退)。

文档导航

License

MIT

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      Not graded
      quality
      C
      maintenance
      Enables agents to send structured notifications to recipients via configurable channels (initial SMTP provider) without exposing delivery addresses or credentials, with tools for listing recipients, listing channels, and sending notifications.
      -
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables AI agents to send notifications to a unified feed, report activity, request input from humans, and manage notification state through MCP tools.
      4
      MIT