Documentation Sync
This page is auto-generated from plugins/adapters/napcat/README.md. Please edit the in-package README and then run pnpm sync:adapter-docs.
@zhin.js/adapter-napcat
Zhin.js NapCatQQ adapter (Plugin Runtime, OneBot 11 + NapCat extensions). Default is forward WebSocket client (connection: ws); also supports reverse WS and HTTP POST reporting (via httpHostToken).
Features
- OneBot 11 + go-cqhttp extensions + NapCat-specific API
- Convention-based
defineAdapter/definePlugin(nousePluginneeded) - Forward WebSocket (
connection: ws): the application connects to NapCat WS access_tokenauthentication (Bearer + query)- Inbound via
messageGatewayToken(deduplication + self-message filtering); outboundsend({ target, payload }) - 41 AI tools (
agent/tools/)
Installation
bash
pnpm add @zhin.js/adapter-napcatPlugin Runtime
@zhin.js/adapter— convention-basedadapters/napcat.ts(defineAdapter)@zhin.js/core—messageGatewayTokeninbound/outbound@zhin.js/plugin-runtime—plugin.ts(definePlugin)- Configuration goes to
plugins.<instanceKey>via the plugin'sschema.json
Inbound: gateway.receive({ adapter, target: "private:uid"|"group:gid", content, sender, metadata }) Outbound: send({ target, payload }) -> WS send_private_msg / send_group_msg
Minimal Configuration
yaml
# zhin.config.yml (Plugin Runtime)
plugins:
napcat:
connection: ws
reconnect_interval: 5000
heartbeat_interval: 30000
endpoints:
- name: my-bot
url: "ws://127.0.0.1:3001"
access_token: "${NAPCAT_TOKEN}"The root plugin zhin.plugins (or project graph) must reference @zhin.js/adapter-napcat (instanceKey: napcat).
Connection Modes
| connection | Status |
|---|---|
ws | Implemented (recommended) |
wss | Implemented: reverse WS (httpHostToken) |
http | Implemented: POST inbound + http_url/{action} outbound |
Authentication
- Bearer:
Authorization: Bearer <access_token> - Forward WS attaches request headers during Upgrade and includes
access_tokenin the URL query
AI Tools
| Category | Path |
|---|---|
| Permit vocabulary | agent/PERMITS.md |
| Platform tools | agent/tools/*.ts |
| Skill documentation | agent/skills/napcat.md |
Migration Notes (Plugin Runtime)
- Notice / request side events have been removed: the old Adapter built
notice.receive/request.receiveevents (including$approve/$reject) forpost_type: notice|request; the new Plugin Runtime (messageGatewayToken) has no side-event bus yet — inbound only processespost_type: message, and notice / request events are silently discarded. Friend/group join request approval can be done viacallApi('set_friend_add_request' | 'set_group_add_request'). - Group management tools have not been migrated yet: the old Adapter registered a full set of agent tools (kick/mute/group card, etc.) via
createSceneManagementTools; after migration,agent/tools/only covers NapCat extension APIs. Other group management capabilities can be invoked viacallApi(e.g.,set_group_kick,set_group_ban) as an escape hatch. - Platform permission access control:
plugin.tssetup has registeredregisterDefaultScenePlatformPermitChecker('napcat').scene_admin/scene_ownerare determined based on the sender'srole(owner / admin) in the inbound metadata.
Documentation Links
License
MIT License