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

@zhin.js/adapter-satori

v5.0.2

Published

Zhin.js Satori adapter for Plugin Runtime (WebSocket client)

Readme

@zhin.js/adapter-satori

Zhin.js Satori 聊天协议适配器(Plugin Runtime)。支持 WebSocket 正向客户端connection: ws)与 Webhook 入站connection: webhook,经 httpHostToken POST 路由)。

勿与本仓库的 @zhin.js/satori 混淆:后者是 Vercel satoriSVG 图片渲染工具包(packages/toolkit/satori),用于把 HTML/React 画成 SVG,不是聊天协议。参见 @zhin.js/satori README

功能特性

  • 🔌 Satori 协议 兼容
  • 🌐 WebSocket 正向connection: ws,默认):应用连 SDK ws(s)://baseUrl,IDENTIFY + 心跳
  • 🔐 Bearer Token 鉴权(API 与 WS IDENTIFY)
  • 📨 频道 / 私聊消息收发,消息 id 格式为 channelId:messageId
  • 约定式 defineAdapter / definePlugin(无需 usePlugin
  • Webhookconnection: webhook):SDK POST Satori-Opcode: 0 事件到 path

安装

pnpm add @zhin.js/adapter-satori

Plugin Runtime

  • @zhin.js/adapter — 约定式 adapters/satori.tsdefineAdapter
  • @zhin.js/coremessageGatewayToken 入站/出站
  • @zhin.js/plugin-runtimeplugin.tsdefinePlugin
  • @zhin.js/host-http — Webhook 模式需 httpHostToken 注册 POST 路由
  • 配置经插件 schema.json 落到 plugins.<instanceKey>baseUrl / token / …)

入站:gateway.receive({ conversation, message, content, sender, metadata })conversation 为 ConversationRef:DIRECT 频道 → kind private,其余 → kind group、所属 guild 进 parent
出站:send({ conversation, payload }) → Satori message.createchannel_id = conversation.id;payload 已由 gateway/core 渲染;无 segment-mapper)

入站 metadata.mentioned:消息 content 中 <at id="…"/> 元素的 id 等于登录 selfId(READY/事件 login.user.id)时置 true

最小配置

# zhin.config.yml(Plugin Runtime)
plugins:
  satori:
    connection: ws
    heartbeat_interval: 10000
    endpoints:
      - name: satori-bot
        baseUrl: "http://127.0.0.1:5140"
        token: "${SATORI_TOKEN}"

根插件 zhin.plugins(或项目图)需引用 @zhin.js/adapter-satoriinstanceKey: satori)。

可选字段

| 字段 | 说明 | |------|------| | heartbeat_interval | WS PING 间隔(毫秒),默认 10000 | | token | Bearer;也可设环境变量 SATORI_TOKEN |

Webhook

plugins:
  satori:
    connection: webhook
    endpoints:
      - name: satori-bot
        baseUrl: "http://127.0.0.1:5140"
        path: "/satori/webhook"
        token: "${SATORI_TOKEN}"

SDK 会向 path 发送 POST,请求头 Satori-Opcode: 0 表示事件;适配器从首个事件的 login 取得 platform / userId 用于后续 API 调用。

鉴权

  • API:请求头 Authorization: Bearer {token}
  • WebSocket:IDENTIFY 时 body 中传 token

消息 id 与撤回

  • 消息 id 格式为 channelId:messageId,便于发消息 / 撤回时解析。
  • 撤回时需 channel_id + message_id,适配器已按上述格式解析。

AI 工具

技能说明见 agent/skills/satori.md

协议文档