@zhin.js/adapter-napcat 1.0.1 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +757 -0
- package/{skills/napcat/PERMITS.md → PERMITS.md} +3 -3
- package/README.md +63 -95
- package/adapters/napcat/index.js +47 -0
- package/adapters/napcat/index.ts +64 -0
- package/agents/napcat/agent.json +20 -0
- package/agents/napcat/boundaries.md +3 -0
- package/agents/napcat/conventions.md +3 -0
- package/agents/napcat/skills/napcat-account/SKILL.md +25 -0
- package/agents/napcat/skills/napcat-account/tools/delete_friend/index.js +18 -0
- package/agents/napcat/skills/napcat-account/tools/delete_friend/index.ts +18 -0
- package/agents/napcat/skills/napcat-account/tools/get_user_status/index.js +16 -0
- package/agents/napcat/skills/napcat-account/tools/get_user_status/index.ts +16 -0
- package/agents/napcat/skills/napcat-account/tools/send_like/index.js +18 -0
- package/agents/napcat/skills/napcat-account/tools/send_like/index.ts +18 -0
- package/agents/napcat/skills/napcat-account/tools/set_avatar/index.js +17 -0
- package/agents/napcat/skills/napcat-account/tools/set_avatar/index.ts +17 -0
- package/agents/napcat/skills/napcat-account/tools/set_online_status/index.js +18 -0
- package/agents/napcat/skills/napcat-account/tools/set_online_status/index.ts +18 -0
- package/agents/napcat/skills/napcat-account/tools/set_profile/index.js +21 -0
- package/agents/napcat/skills/napcat-account/tools/set_profile/index.ts +21 -0
- package/agents/napcat/skills/napcat-account/tools/set_signature/index.js +17 -0
- package/agents/napcat/skills/napcat-account/tools/set_signature/index.ts +17 -0
- package/agents/napcat/skills/napcat-files-history/SKILL.md +22 -0
- package/agents/napcat/skills/napcat-files-history/tools/download_file/index.js +17 -0
- package/agents/napcat/skills/napcat-files-history/tools/download_file/index.ts +17 -0
- package/agents/napcat/skills/napcat-files-history/tools/get_friend_msg_history/index.js +18 -0
- package/agents/napcat/skills/napcat-files-history/tools/get_friend_msg_history/index.ts +18 -0
- package/agents/napcat/skills/napcat-files-history/tools/get_group_file_url/index.js +19 -0
- package/agents/napcat/skills/napcat-files-history/tools/get_group_file_url/index.ts +19 -0
- package/agents/napcat/skills/napcat-files-history/tools/get_group_msg_history/index.js +19 -0
- package/agents/napcat/skills/napcat-files-history/tools/get_group_msg_history/index.ts +19 -0
- package/agents/napcat/skills/napcat-files-history/tools/get_group_root_files/index.js +17 -0
- package/agents/napcat/skills/napcat-files-history/tools/get_group_root_files/index.ts +17 -0
- package/agents/napcat/skills/napcat-files-history/tools/upload_group_file/index.js +21 -0
- package/agents/napcat/skills/napcat-files-history/tools/upload_group_file/index.ts +21 -0
- package/agents/napcat/skills/napcat-group-content/SKILL.md +21 -0
- package/agents/napcat/skills/napcat-group-content/tools/del_group_notice/index.js +20 -0
- package/agents/napcat/skills/napcat-group-content/tools/del_group_notice/index.ts +20 -0
- package/agents/napcat/skills/napcat-group-content/tools/delete_essence_msg/index.js +19 -0
- package/agents/napcat/skills/napcat-group-content/tools/delete_essence_msg/index.ts +19 -0
- package/agents/napcat/skills/napcat-group-content/tools/get_essence_list/index.js +17 -0
- package/agents/napcat/skills/napcat-group-content/tools/get_essence_list/index.ts +17 -0
- package/agents/napcat/skills/napcat-group-content/tools/get_group_notice/index.js +17 -0
- package/agents/napcat/skills/napcat-group-content/tools/get_group_notice/index.ts +17 -0
- package/agents/napcat/skills/napcat-group-content/tools/send_group_notice/index.js +21 -0
- package/agents/napcat/skills/napcat-group-content/tools/send_group_notice/index.ts +21 -0
- package/agents/napcat/skills/napcat-group-content/tools/set_essence_msg/index.js +19 -0
- package/agents/napcat/skills/napcat-group-content/tools/set_essence_msg/index.ts +19 -0
- package/agents/napcat/skills/napcat-group-settings/SKILL.md +23 -0
- package/agents/napcat/skills/napcat-group-settings/tools/get_group_info_ex/index.js +17 -0
- package/agents/napcat/skills/napcat-group-settings/tools/get_group_info_ex/index.ts +17 -0
- package/agents/napcat/skills/napcat-group-settings/tools/get_group_shut_list/index.js +17 -0
- package/agents/napcat/skills/napcat-group-settings/tools/get_group_shut_list/index.ts +17 -0
- package/agents/napcat/skills/napcat-group-settings/tools/group_sign/index.js +18 -0
- package/agents/napcat/skills/napcat-group-settings/tools/group_sign/index.ts +18 -0
- package/agents/napcat/skills/napcat-group-settings/tools/set_group_portrait/index.js +20 -0
- package/agents/napcat/skills/napcat-group-settings/tools/set_group_portrait/index.ts +20 -0
- package/agents/napcat/skills/napcat-group-settings/tools/set_title/index.js +21 -0
- package/agents/napcat/skills/napcat-group-settings/tools/set_title/index.ts +21 -0
- package/agents/napcat/skills/napcat-media/SKILL.md +23 -0
- package/agents/napcat/skills/napcat-media/tools/ai_tts/index.js +19 -0
- package/agents/napcat/skills/napcat-media/tools/ai_tts/index.ts +19 -0
- package/agents/napcat/skills/napcat-media/tools/get_ai_characters/index.js +17 -0
- package/agents/napcat/skills/napcat-media/tools/get_ai_characters/index.ts +17 -0
- package/agents/napcat/skills/napcat-media/tools/get_mini_app_ark/index.js +20 -0
- package/agents/napcat/skills/napcat-media/tools/get_mini_app_ark/index.ts +20 -0
- package/agents/napcat/skills/napcat-media/tools/ocr_image/index.js +16 -0
- package/agents/napcat/skills/napcat-media/tools/ocr_image/index.ts +16 -0
- package/agents/napcat/skills/napcat-media/tools/translate/index.js +16 -0
- package/agents/napcat/skills/napcat-media/tools/translate/index.ts +16 -0
- package/agents/napcat/skills/napcat-messaging/SKILL.md +22 -0
- package/agents/napcat/skills/napcat-messaging/tools/forward_single_msg/index.js +22 -0
- package/agents/napcat/skills/napcat-messaging/tools/forward_single_msg/index.ts +28 -0
- package/agents/napcat/skills/napcat-messaging/tools/mark_msg_as_read/index.js +17 -0
- package/agents/napcat/skills/napcat-messaging/tools/mark_msg_as_read/index.ts +17 -0
- package/agents/napcat/skills/napcat-messaging/tools/send_forward_msg/index.js +19 -0
- package/agents/napcat/skills/napcat-messaging/tools/send_forward_msg/index.ts +27 -0
- package/agents/napcat/skills/napcat-messaging/tools/send_poke/index.js +18 -0
- package/agents/napcat/skills/napcat-messaging/tools/send_poke/index.ts +18 -0
- package/agents/napcat/skills/napcat-messaging/tools/set_emoji_reaction/index.js +18 -0
- package/agents/napcat/skills/napcat-messaging/tools/set_emoji_reaction/index.ts +18 -0
- package/agents/napcat/system.md +3 -0
- package/commands/napcat/endpoint/add/[id]/index.js +3 -0
- package/commands/napcat/endpoint/add/[id]/index.ts +3 -0
- package/commands/napcat/endpoint/definition.js +29 -0
- package/commands/napcat/endpoint/definition.ts +26 -0
- package/commands/napcat/endpoint/list/index.js +3 -0
- package/commands/napcat/endpoint/list/index.ts +3 -0
- package/commands/napcat/endpoint/remove/[id]/index.js +3 -0
- package/commands/napcat/endpoint/remove/[id]/index.ts +3 -0
- package/lib/client.d.ts +52 -0
- package/lib/client.js +62 -0
- package/lib/endpoint-management.d.ts +15 -0
- package/lib/endpoint-management.js +47 -0
- package/lib/http-endpoint.d.ts +27 -0
- package/lib/http-endpoint.js +177 -0
- package/lib/index.d.ts +11 -22
- package/lib/index.js +10 -59
- package/lib/napcat-inbound.d.ts +12 -5
- package/lib/napcat-inbound.js +28 -13
- package/lib/napcat-runtime-state.d.ts +1 -0
- package/lib/napcat-runtime-state.js +6 -0
- package/lib/onebot-get-msg.d.ts +16 -3
- package/lib/onebot-get-msg.js +53 -1
- package/lib/protocol.d.ts +147 -0
- package/lib/protocol.js +318 -0
- package/lib/side-event-dispatch.d.ts +7 -0
- package/lib/side-event-dispatch.js +36 -0
- package/lib/webhook.d.ts +2 -0
- package/lib/webhook.js +14 -0
- package/lib/ws-endpoint.d.ts +27 -0
- package/lib/ws-endpoint.js +241 -0
- package/lib/ws-transport.d.ts +13 -0
- package/lib/ws-transport.js +75 -0
- package/lib/ws-types.d.ts +17 -0
- package/lib/ws-types.js +1 -0
- package/lib/wss-auth.d.ts +2 -0
- package/lib/wss-auth.js +16 -0
- package/lib/wss-endpoint.d.ts +29 -0
- package/lib/wss-endpoint.js +196 -0
- package/package.json +76 -34
- package/plugin.js +18 -0
- package/schema.json +131 -0
- package/src/client.ts +79 -0
- package/src/endpoint-management.ts +72 -0
- package/src/http-endpoint.ts +234 -0
- package/src/index.ts +62 -87
- package/src/napcat-inbound.ts +34 -10
- package/src/napcat-runtime-state.ts +7 -0
- package/src/onebot-get-msg.ts +69 -5
- package/src/protocol.ts +465 -0
- package/src/side-event-dispatch.ts +48 -0
- package/src/webhook.ts +16 -0
- package/src/ws-endpoint.ts +301 -0
- package/src/ws-transport.ts +105 -0
- package/src/ws-types.ts +20 -0
- package/src/wss-auth.ts +17 -0
- package/src/wss-endpoint.ts +247 -0
- package/client/NapCatManagement.tsx +0 -113
- package/client/index.tsx +0 -11
- package/client/tsconfig.json +0 -7
- package/client/utils/api.ts +0 -30
- package/dist/index.js +0 -27
- package/lib/adapter.d.ts +0 -28
- package/lib/adapter.d.ts.map +0 -1
- package/lib/adapter.js +0 -94
- package/lib/adapter.js.map +0 -1
- package/lib/agent-prompt.d.ts +0 -3
- package/lib/agent-prompt.d.ts.map +0 -1
- package/lib/agent-prompt.js +0 -105
- package/lib/agent-prompt.js.map +0 -1
- package/lib/endpoint-base.d.ts +0 -143
- package/lib/endpoint-base.d.ts.map +0 -1
- package/lib/endpoint-base.js +0 -334
- package/lib/endpoint-base.js.map +0 -1
- package/lib/endpoint-http.d.ts +0 -18
- package/lib/endpoint-http.d.ts.map +0 -1
- package/lib/endpoint-http.js +0 -119
- package/lib/endpoint-http.js.map +0 -1
- package/lib/endpoint-ws-client.d.ts +0 -21
- package/lib/endpoint-ws-client.d.ts.map +0 -1
- package/lib/endpoint-ws-client.js +0 -165
- package/lib/endpoint-ws-client.js.map +0 -1
- package/lib/endpoint-ws-server.d.ts +0 -21
- package/lib/endpoint-ws-server.d.ts.map +0 -1
- package/lib/endpoint-ws-server.js +0 -150
- package/lib/endpoint-ws-server.js.map +0 -1
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/napcat-inbound.d.ts.map +0 -1
- package/lib/napcat-inbound.js.map +0 -1
- package/lib/onebot-get-msg.d.ts.map +0 -1
- package/lib/onebot-get-msg.js.map +0 -1
- package/lib/routes.d.ts +0 -4
- package/lib/routes.d.ts.map +0 -1
- package/lib/routes.js +0 -61
- package/lib/routes.js.map +0 -1
- package/lib/tools.d.ts +0 -8
- package/lib/tools.d.ts.map +0 -1
- package/lib/tools.js +0 -605
- package/lib/tools.js.map +0 -1
- package/lib/types.d.ts +0 -293
- package/lib/types.d.ts.map +0 -1
- package/lib/types.js +0 -6
- package/lib/types.js.map +0 -1
- package/lib/typing-indicator.d.ts +0 -45
- package/lib/typing-indicator.d.ts.map +0 -1
- package/lib/typing-indicator.js +0 -132
- package/lib/typing-indicator.js.map +0 -1
- package/plugin.yml +0 -3
- package/skills/napcat/SKILL.md +0 -311
- package/src/adapter.ts +0 -101
- package/src/agent-prompt.ts +0 -114
- package/src/endpoint-base.ts +0 -376
- package/src/endpoint-http.ts +0 -109
- package/src/endpoint-ws-client.ts +0 -164
- package/src/endpoint-ws-server.ts +0 -150
- package/src/routes.ts +0 -61
- package/src/tools.ts +0 -632
- package/src/types.ts +0 -279
- package/src/typing-indicator.ts +0 -184
|
@@ -13,7 +13,7 @@ OneBot `sender.role` 透传:`owner` · `admin` · `member`。
|
|
|
13
13
|
|
|
14
14
|
| `platform(napcat,…)` | 含义 |
|
|
15
15
|
|----------------------|------|
|
|
16
|
-
| `
|
|
17
|
-
| `
|
|
16
|
+
| `scene_owner` | 群主 |
|
|
17
|
+
| `scene_admin` | 群管理员(含群主) |
|
|
18
18
|
|
|
19
|
-
使用 core 默认 `
|
|
19
|
+
使用 core 默认 `createSceneRolePlatformChecker`。
|
package/README.md
CHANGED
|
@@ -1,131 +1,99 @@
|
|
|
1
1
|
# @zhin.js/adapter-napcat
|
|
2
2
|
|
|
3
|
-
Zhin.js NapCatQQ
|
|
3
|
+
Zhin.js [NapCatQQ](https://github.com/NapNeko/NapCatQQ) 适配器(Plugin Runtime,OneBot 11 + NapCat 扩展)。默认 **正向 WebSocket 客户端**(`connection: ws`);亦支持 **反向 WS** 与 **HTTP POST 上报**(经 `httpHostToken`)。
|
|
4
4
|
|
|
5
5
|
## 功能特性
|
|
6
6
|
|
|
7
|
-
-
|
|
8
|
-
-
|
|
9
|
-
- **正向 WebSocket**(`connection: ws`):应用连 NapCat
|
|
10
|
-
-
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
- 自动重连机制(WS)与心跳检测
|
|
14
|
-
- 群聊和私聊消息处理
|
|
15
|
-
- 入站消息去重与 bot 自发消息过滤
|
|
16
|
-
- Typing Indicator(处理中提示:群聊表情回应 / 私聊输入状态)
|
|
17
|
-
- 41 个 AI 工具(群管、戳一戳、表情回应、精华消息、群公告、AI 语音等)
|
|
18
|
-
- Console 管理页面(`/console/napcat`)
|
|
19
|
-
- Agent Prompt 贡献器(deferred 任务自动优选 napcat 工具)
|
|
7
|
+
- OneBot 11 + go-cqhttp 扩展 + NapCat 独有 API
|
|
8
|
+
- 约定式 `defineAdapter` / `definePlugin`(无需 `usePlugin`)
|
|
9
|
+
- **正向 WebSocket**(`connection: ws`):应用连 NapCat WS
|
|
10
|
+
- `access_token` 鉴权(Bearer + query)
|
|
11
|
+
- 入站经 `Endpoint.emit(...)`(去重 + 自发过滤);出站 `send({ conversation, payload })`
|
|
12
|
+
- 41 个 AI 工具(`tools/`)
|
|
20
13
|
|
|
21
14
|
## 安装
|
|
22
15
|
|
|
23
16
|
```bash
|
|
24
|
-
pnpm add @zhin.js/adapter-napcat
|
|
17
|
+
pnpm add @zhin.js/adapter-napcat
|
|
25
18
|
```
|
|
26
19
|
|
|
27
|
-
|
|
20
|
+
## Plugin Runtime
|
|
28
21
|
|
|
29
|
-
|
|
22
|
+
- `@zhin.js/adapter` — 约定式 `adapters/napcat/index.ts`(`defineAdapter`)
|
|
23
|
+
- `@zhin.js/core` — `Endpoint.emit(...)` 入站、`outboundMessageToken` 出站
|
|
24
|
+
- `zhin.js` — `plugin.ts`(`definePlugin`)
|
|
25
|
+
- 配置经插件 `schema.json` 落到 `plugins.<instanceKey>`
|
|
30
26
|
|
|
31
|
-
|
|
27
|
+
入站:`gateway.receive({ conversation, message: { conversation, id }, content, sender, metadata })`(`conversation` 为 ConversationRef:私聊 `kind: 'private'`、群聊 `kind: 'group'`,临时会话群容器进 `parent`)
|
|
28
|
+
出站:`send({ conversation, payload })` → WS `send_private_msg` / `send_group_msg`
|
|
32
29
|
|
|
33
|
-
|
|
30
|
+
## 前置条件
|
|
31
|
+
|
|
32
|
+
1. 安装并登录 NapCatQQ,启用一个与 Zhin 配置匹配的 OneBot 11 连接。
|
|
33
|
+
2. 正向 WS 需 Zhin 可达 NapCat;反向 WS/HTTP 上报需 NapCat 可达 Zhin HTTP Host。
|
|
34
|
+
3. 两端配置相同的 `access_token`,不要把未鉴权端口暴露到公网。
|
|
35
|
+
|
|
36
|
+
## 最小配置
|
|
34
37
|
|
|
35
38
|
```yaml
|
|
39
|
+
# zhin.config.yml(Plugin Runtime)
|
|
36
40
|
plugins:
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
endpoints:
|
|
40
|
-
- context: napcat
|
|
41
|
+
napcat:
|
|
41
42
|
connection: ws
|
|
42
|
-
name: my-bot
|
|
43
|
-
url: "ws://127.0.0.1:3001"
|
|
44
|
-
access_token: "${NAPCAT_TOKEN}"
|
|
45
43
|
reconnect_interval: 5000
|
|
46
44
|
heartbeat_interval: 30000
|
|
45
|
+
endpoints:
|
|
46
|
+
- id: my-bot
|
|
47
|
+
url: "ws://127.0.0.1:3001"
|
|
48
|
+
access_token: "${NAPCAT_TOKEN}"
|
|
47
49
|
```
|
|
48
50
|
|
|
49
|
-
|
|
51
|
+
AdapterIndex 会把实例级连接默认值合并进每个 endpoint;协议实现只接收一份展开后的
|
|
52
|
+
endpoint 配置,不会从环境变量推断 endpoint id。
|
|
50
53
|
|
|
51
|
-
|
|
52
|
-
plugins:
|
|
53
|
-
- "@zhin.js/host-router"
|
|
54
|
-
- "@zhin.js/adapter-napcat"
|
|
55
|
-
|
|
56
|
-
endpoints:
|
|
57
|
-
- context: napcat
|
|
58
|
-
connection: wss
|
|
59
|
-
name: my-bot
|
|
60
|
-
path: "/napcat/ws"
|
|
61
|
-
access_token: "${NAPCAT_TOKEN}"
|
|
62
|
-
heartbeat_interval: 30000
|
|
63
|
-
```
|
|
54
|
+
根插件 `zhin.plugins`(或项目图)需引用 `@zhin.js/adapter-napcat`(`instanceKey: napcat`)。
|
|
64
55
|
|
|
65
|
-
|
|
56
|
+
## 连接方式
|
|
66
57
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
endpoints:
|
|
73
|
-
- context: napcat
|
|
74
|
-
connection: http
|
|
75
|
-
name: my-bot
|
|
76
|
-
http_url: "http://127.0.0.1:3000"
|
|
77
|
-
post_path: "/napcat/post"
|
|
78
|
-
access_token: "${NAPCAT_TOKEN}"
|
|
79
|
-
poll_interval: 30000
|
|
80
|
-
```
|
|
58
|
+
| connection | 状态 |
|
|
59
|
+
|------------|------|
|
|
60
|
+
| `ws` | 已实现(推荐) |
|
|
61
|
+
| `wss` | 已实现:反向 WS(httpHostToken) |
|
|
62
|
+
| `http` | 已实现:POST 入站 + `http_url/{action}` 出站 |
|
|
81
63
|
|
|
82
|
-
|
|
64
|
+
## 鉴权
|
|
83
65
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
name: my-bot
|
|
89
|
-
url: "ws://127.0.0.1:3001"
|
|
90
|
-
typingIndicator:
|
|
91
|
-
enabled: true
|
|
92
|
-
defaultEmoji: "128516"
|
|
93
|
-
privateConfig:
|
|
94
|
-
type: "message"
|
|
95
|
-
message: "正在思考中..."
|
|
96
|
-
groupConfig:
|
|
97
|
-
type: "reaction"
|
|
98
|
-
emoji: "128516"
|
|
99
|
-
```
|
|
66
|
+
- **Bearer**:`Authorization: Bearer <access_token>`
|
|
67
|
+
- 正向 WS 在 Upgrade 时附带请求头,并在 URL query 写入 `access_token`
|
|
68
|
+
|
|
69
|
+
## AI 工具
|
|
100
70
|
|
|
101
|
-
|
|
71
|
+
| 类别 | 路径 |
|
|
72
|
+
|------|------|
|
|
73
|
+
| Permit 词汇 | `PERMITS.md` |
|
|
74
|
+
| 平台工具 | `tools/<name>/index.ts` |
|
|
75
|
+
| 技能说明 | `agents/napcat/skills/napcat-*/SKILL.md`(按消息、群内容、群设置、文件历史、媒体和账号拆分) |
|
|
102
76
|
|
|
103
|
-
|
|
77
|
+
## 迁移说明(Plugin Runtime)
|
|
104
78
|
|
|
105
|
-
-
|
|
106
|
-
-
|
|
107
|
-
-
|
|
108
|
-
- 精华消息管理
|
|
109
|
-
- 群公告管理
|
|
110
|
-
- 群文件管理
|
|
111
|
-
- AI 语音 TTS
|
|
112
|
-
- 图片 OCR 文字识别
|
|
113
|
-
- 小程序卡片签名
|
|
114
|
-
- 个人资料 / 头像 / 签名修改
|
|
115
|
-
- 在线状态设置
|
|
116
|
-
- 消息历史查询
|
|
117
|
-
- 英译中翻译
|
|
79
|
+
- **notice / request / meta 侧事件**:经 the unified `Endpoint.emit(...)` ingress 归一后分发到 `handlers`(`notice.receive` / `request.receive` / `system.receive`),请求带 `$approve` / `$reject`。消息仍走 `outboundMessageToken`。
|
|
80
|
+
- **群管工具暂未迁移**:旧 Adapter 经 `createSceneManagementTools` 注册踢人 / 禁言 / 群名片等成套 agent 工具;迁移后 `tools/` 仅覆盖 NapCat 扩展 API,其余群管能力可通过 `callApi`(如 `set_group_kick`、`set_group_ban`)作为逃生舱调用。
|
|
81
|
+
- **平台权限门禁**:`plugin.ts` setup 通过 generation-owned `permissionHostToken` 调用 `host.registerPlatform('napcat', createSceneRolePlatformChecker())`,`scene_admin` / `scene_owner` 依据入站 metadata 中的 sender `role`(owner / admin)判定。
|
|
118
82
|
|
|
119
|
-
##
|
|
83
|
+
## 文档链接
|
|
120
84
|
|
|
121
|
-
|
|
85
|
+
- [NapCatQQ](https://github.com/NapNeko/NapCatQQ)
|
|
86
|
+
- [适配器概览](https://zhin.js.org/essentials/adapters)
|
|
122
87
|
|
|
123
|
-
##
|
|
88
|
+
## 故障排查
|
|
124
89
|
|
|
125
|
-
|
|
90
|
+
| 现象 | 排查 |
|
|
91
|
+
| --- | --- |
|
|
92
|
+
| WS 连接被拒绝 | 检查 NapCat URL、端口与连接方向 |
|
|
93
|
+
| 401 或握手失败 | 确认两端 token 一致,反向代理保留 Authorization |
|
|
94
|
+
| 重复或自身消息触发 | 检查是否同时启用了多条上报连接 |
|
|
95
|
+
| 请求/通知缺失 | 确认 NapCat 上报 notice/request/meta,并查看 Endpoint 对应分类 |
|
|
126
96
|
|
|
127
|
-
|
|
128
|
-
- 契约测试:`plugins/adapters/napcat/tests/l4-contract.test.ts` + `integration.test.ts`(adapter-harness)
|
|
129
|
-
- CI:`L4_SKIP_PLATFORM=1` 跳过实机;本地验证不设该变量并可配置 `ONEBOT11_WS_URL`
|
|
97
|
+
## 许可证
|
|
130
98
|
|
|
131
|
-
|
|
99
|
+
MIT License
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// Generated by build-plugin-runtime-entries.mjs. Do not edit.
|
|
2
|
+
/**
|
|
3
|
+
* Convention entry: discover `adapters/napcat/index.ts` → defineAdapter.
|
|
4
|
+
*/
|
|
5
|
+
import { defineAdapter } from 'zhin.js/adapter';
|
|
6
|
+
import { httpHostToken } from '@zhin.js/host-http';
|
|
7
|
+
import { NapCatHttpEndpoint } from "../../lib/http-endpoint.js";
|
|
8
|
+
import { resolveNapCatConfig } from "../../lib/protocol.js";
|
|
9
|
+
import { NapCatWsEndpoint } from "../../lib/ws-endpoint.js";
|
|
10
|
+
import { NapCatWssEndpoint } from "../../lib/wss-endpoint.js";
|
|
11
|
+
import { napcatRuntimeStateToken } from "../../lib/napcat-runtime-state.js";
|
|
12
|
+
export { NapCatHttpEndpoint, } from "../../lib/http-endpoint.js";
|
|
13
|
+
export { NapCatWsEndpoint, } from "../../lib/ws-endpoint.js";
|
|
14
|
+
export { NapCatWssEndpoint, } from "../../lib/wss-endpoint.js";
|
|
15
|
+
export default defineAdapter({
|
|
16
|
+
capabilities: ['inbound', 'outbound'],
|
|
17
|
+
operations: ['recall'],
|
|
18
|
+
// OneBot file 参数原生消费 url / base64:// 媒体,file:// 本地路径由 NapCat 侧读盘;
|
|
19
|
+
// 无卡片交互面,交互段降级纯文本。
|
|
20
|
+
segments: {
|
|
21
|
+
outboundMedia: ['url', 'base64', 'path'],
|
|
22
|
+
interactive: 'text',
|
|
23
|
+
},
|
|
24
|
+
create(context) {
|
|
25
|
+
const config = resolveNapCatConfig(context.config);
|
|
26
|
+
// 注册到插件运行时状态(napcat endpoint list 的"运行中"数据源)
|
|
27
|
+
context.use(napcatRuntimeStateToken).endpoints.set(config.id, {
|
|
28
|
+
id: config.id,
|
|
29
|
+
mode: config.connection,
|
|
30
|
+
});
|
|
31
|
+
if (config.connection === 'wss') {
|
|
32
|
+
return new NapCatWssEndpoint({
|
|
33
|
+
id: context.id,
|
|
34
|
+
http: context.use(httpHostToken),
|
|
35
|
+
config,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
if (config.connection === 'http') {
|
|
39
|
+
return new NapCatHttpEndpoint({
|
|
40
|
+
id: context.id,
|
|
41
|
+
http: context.use(httpHostToken),
|
|
42
|
+
config,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
return new NapCatWsEndpoint({ id: context.id, config });
|
|
46
|
+
},
|
|
47
|
+
});
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convention entry: discover `adapters/napcat/index.ts` → defineAdapter.
|
|
3
|
+
*/
|
|
4
|
+
import { defineAdapter } from 'zhin.js/adapter';
|
|
5
|
+
import { httpHostToken } from '@zhin.js/host-http';
|
|
6
|
+
import { NapCatHttpEndpoint } from '../../src/http-endpoint.js';
|
|
7
|
+
import { resolveNapCatConfig, type NapCatEndpointConfig } from '../../src/protocol.js';
|
|
8
|
+
import { NapCatWsEndpoint } from '../../src/ws-endpoint.js';
|
|
9
|
+
import { NapCatWssEndpoint } from '../../src/wss-endpoint.js';
|
|
10
|
+
import { napcatRuntimeStateToken } from '../../src/napcat-runtime-state.js';
|
|
11
|
+
|
|
12
|
+
export {
|
|
13
|
+
NapCatHttpEndpoint,
|
|
14
|
+
type NapCatHttpEndpointOptions,
|
|
15
|
+
} from '../../src/http-endpoint.js';
|
|
16
|
+
export {
|
|
17
|
+
NapCatWsEndpoint,
|
|
18
|
+
type NapCatWsEndpointOptions,
|
|
19
|
+
} from '../../src/ws-endpoint.js';
|
|
20
|
+
export {
|
|
21
|
+
NapCatWssEndpoint,
|
|
22
|
+
type NapCatWssEndpointOptions,
|
|
23
|
+
} from '../../src/wss-endpoint.js';
|
|
24
|
+
export type { NapCatWsSocket, NapCatWsCreateOptions } from '../../src/ws-types.js';
|
|
25
|
+
|
|
26
|
+
declare module '@zhin.js/core' {
|
|
27
|
+
interface AdapterEndpoints {
|
|
28
|
+
napcat: import('../../src/ws-endpoint.js').NapCatWsEndpoint;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export default defineAdapter<NapCatEndpointConfig>({
|
|
33
|
+
capabilities: ['inbound', 'outbound'],
|
|
34
|
+
operations: ['recall'],
|
|
35
|
+
// OneBot file 参数原生消费 url / base64:// 媒体,file:// 本地路径由 NapCat 侧读盘;
|
|
36
|
+
// 无卡片交互面,交互段降级纯文本。
|
|
37
|
+
segments: {
|
|
38
|
+
outboundMedia: ['url', 'base64', 'path'],
|
|
39
|
+
interactive: 'text',
|
|
40
|
+
},
|
|
41
|
+
create(context) {
|
|
42
|
+
const config = resolveNapCatConfig(context.config);
|
|
43
|
+
// 注册到插件运行时状态(napcat endpoint list 的"运行中"数据源)
|
|
44
|
+
context.use(napcatRuntimeStateToken).endpoints.set(config.id, {
|
|
45
|
+
id: config.id,
|
|
46
|
+
mode: config.connection,
|
|
47
|
+
});
|
|
48
|
+
if (config.connection === 'wss') {
|
|
49
|
+
return new NapCatWssEndpoint({
|
|
50
|
+
id: context.id,
|
|
51
|
+
http: context.use(httpHostToken),
|
|
52
|
+
config,
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
if (config.connection === 'http') {
|
|
56
|
+
return new NapCatHttpEndpoint({
|
|
57
|
+
id: context.id,
|
|
58
|
+
http: context.use(httpHostToken),
|
|
59
|
+
config,
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
return new NapCatWsEndpoint({ id: context.id, config });
|
|
63
|
+
},
|
|
64
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "NAPCAT Platform Agent",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Handles napcat platform-specific operations and progressively loads only the required platform Skill.",
|
|
5
|
+
"trigger_rules": {
|
|
6
|
+
"file_patterns": [],
|
|
7
|
+
"keywords": [
|
|
8
|
+
"napcat",
|
|
9
|
+
"adapter:napcat"
|
|
10
|
+
]
|
|
11
|
+
},
|
|
12
|
+
"entry_points": [
|
|
13
|
+
"system.md",
|
|
14
|
+
"boundaries.md",
|
|
15
|
+
"conventions.md"
|
|
16
|
+
],
|
|
17
|
+
"platforms": [
|
|
18
|
+
"napcat"
|
|
19
|
+
]
|
|
20
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: napcat-account
|
|
3
|
+
platforms:
|
|
4
|
+
- napcat
|
|
5
|
+
description: NapCatQQ 账号状态、资料、头像、签名、点赞与好友关系能力。
|
|
6
|
+
keywords:
|
|
7
|
+
- "napcat"
|
|
8
|
+
- "账号"
|
|
9
|
+
- "资料"
|
|
10
|
+
- "头像"
|
|
11
|
+
- "签名"
|
|
12
|
+
- "好友"
|
|
13
|
+
tools:
|
|
14
|
+
- "send_like"
|
|
15
|
+
- "get_user_status"
|
|
16
|
+
- "set_profile"
|
|
17
|
+
- "set_avatar"
|
|
18
|
+
- "set_online_status"
|
|
19
|
+
- "set_signature"
|
|
20
|
+
- "delete_friend"
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
# napcat-account
|
|
24
|
+
|
|
25
|
+
账号资料和好友关系属于高影响状态。先查询目标,修改与删除操作必须遵守审批策略。
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// Generated by build-plugin-runtime-entries.mjs. Do not edit.
|
|
2
|
+
import { defineAgentTool } from '@zhin.js/tool';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
export default defineAgentTool({
|
|
5
|
+
description: '删除好友。',
|
|
6
|
+
inputSchema: z.object({
|
|
7
|
+
user_id: z.number().describe('好友 QQ 号'),
|
|
8
|
+
}),
|
|
9
|
+
adapter: 'napcat',
|
|
10
|
+
tags: ['napcat', 'qq'],
|
|
11
|
+
keywords: ['删除好友', 'delete friend', '删好友'],
|
|
12
|
+
permissions: ['platform(napcat,scene_admin)'],
|
|
13
|
+
async execute({ user_id }, context) {
|
|
14
|
+
const endpoint = context.$client;
|
|
15
|
+
await endpoint.deleteFriend(user_id);
|
|
16
|
+
return { success: true };
|
|
17
|
+
},
|
|
18
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { defineAgentTool } from '@zhin.js/tool';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
|
|
4
|
+
export default defineAgentTool<{ user_id: number }>({
|
|
5
|
+
description: '删除好友。',
|
|
6
|
+
inputSchema: z.object({
|
|
7
|
+
user_id: z.number().describe('好友 QQ 号'),
|
|
8
|
+
}),
|
|
9
|
+
adapter: 'napcat',
|
|
10
|
+
tags: ['napcat', 'qq'],
|
|
11
|
+
keywords: ['删除好友', 'delete friend', '删好友'],
|
|
12
|
+
permissions: ['platform(napcat,scene_admin)'],
|
|
13
|
+
async execute({ user_id }: { user_id: number }, context) {
|
|
14
|
+
const endpoint = context.$client;
|
|
15
|
+
await endpoint.deleteFriend(user_id);
|
|
16
|
+
return { success: true };
|
|
17
|
+
},
|
|
18
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// Generated by build-plugin-runtime-entries.mjs. Do not edit.
|
|
2
|
+
import { defineAgentTool } from '@zhin.js/tool';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
export default defineAgentTool({
|
|
5
|
+
description: '获取用户在线状态。',
|
|
6
|
+
inputSchema: z.object({
|
|
7
|
+
user_id: z.number().describe('目标 QQ 号'),
|
|
8
|
+
}),
|
|
9
|
+
adapter: 'napcat',
|
|
10
|
+
tags: ['napcat', 'qq'],
|
|
11
|
+
keywords: ['在线状态', '用户状态', 'online status'],
|
|
12
|
+
async execute({ user_id }, context) {
|
|
13
|
+
const endpoint = context.$client;
|
|
14
|
+
return endpoint.ncGetUserStatus(user_id);
|
|
15
|
+
},
|
|
16
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { defineAgentTool } from '@zhin.js/tool';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
|
|
4
|
+
export default defineAgentTool<{ user_id: number }>({
|
|
5
|
+
description: '获取用户在线状态。',
|
|
6
|
+
inputSchema: z.object({
|
|
7
|
+
user_id: z.number().describe('目标 QQ 号'),
|
|
8
|
+
}),
|
|
9
|
+
adapter: 'napcat',
|
|
10
|
+
tags: ['napcat', 'qq'],
|
|
11
|
+
keywords: ['在线状态', '用户状态', 'online status'],
|
|
12
|
+
async execute({ user_id }: { user_id: number }, context) {
|
|
13
|
+
const endpoint = context.$client;
|
|
14
|
+
return endpoint.ncGetUserStatus(user_id);
|
|
15
|
+
},
|
|
16
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// Generated by build-plugin-runtime-entries.mjs. Do not edit.
|
|
2
|
+
import { defineAgentTool } from '@zhin.js/tool';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
export default defineAgentTool({
|
|
5
|
+
description: '给好友点赞(每人每天最多 10 次)。',
|
|
6
|
+
inputSchema: z.object({
|
|
7
|
+
user_id: z.number().describe('目标 QQ 号'),
|
|
8
|
+
times: z.number().optional().describe('点赞次数(1-10)'),
|
|
9
|
+
}),
|
|
10
|
+
adapter: 'napcat',
|
|
11
|
+
tags: ['napcat', 'qq'],
|
|
12
|
+
keywords: ['点赞', 'like', '赞', '好友赞'],
|
|
13
|
+
async execute({ user_id, times }, context) {
|
|
14
|
+
const endpoint = context.$client;
|
|
15
|
+
await endpoint.sendLike(user_id, times || 1);
|
|
16
|
+
return { success: true, message: `已给 ${user_id} 点赞 ${times || 1} 次` };
|
|
17
|
+
},
|
|
18
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { defineAgentTool } from '@zhin.js/tool';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
|
|
4
|
+
export default defineAgentTool<{ user_id: number; times?: number }>({
|
|
5
|
+
description: '给好友点赞(每人每天最多 10 次)。',
|
|
6
|
+
inputSchema: z.object({
|
|
7
|
+
user_id: z.number().describe('目标 QQ 号'),
|
|
8
|
+
times: z.number().optional().describe('点赞次数(1-10)'),
|
|
9
|
+
}),
|
|
10
|
+
adapter: 'napcat',
|
|
11
|
+
tags: ['napcat', 'qq'],
|
|
12
|
+
keywords: ['点赞', 'like', '赞', '好友赞'],
|
|
13
|
+
async execute({ user_id, times }: { user_id: number; times?: number }, context) {
|
|
14
|
+
const endpoint = context.$client;
|
|
15
|
+
await endpoint.sendLike(user_id, times || 1);
|
|
16
|
+
return { success: true, message: `已给 ${user_id} 点赞 ${times || 1} 次` };
|
|
17
|
+
},
|
|
18
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// Generated by build-plugin-runtime-entries.mjs. Do not edit.
|
|
2
|
+
import { defineAgentTool } from '@zhin.js/tool';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
export default defineAgentTool({
|
|
5
|
+
description: '修改 QQ 头像。',
|
|
6
|
+
inputSchema: z.object({
|
|
7
|
+
file: z.string().describe('图片(URL 或 base64)'),
|
|
8
|
+
}),
|
|
9
|
+
adapter: 'napcat',
|
|
10
|
+
tags: ['napcat', 'qq'],
|
|
11
|
+
keywords: ['头像', 'avatar', '设置头像', '换头像'],
|
|
12
|
+
async execute({ file }, context) {
|
|
13
|
+
const endpoint = context.$client;
|
|
14
|
+
await endpoint.setQQAvatar(file);
|
|
15
|
+
return { success: true };
|
|
16
|
+
},
|
|
17
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { defineAgentTool } from '@zhin.js/tool';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
|
|
4
|
+
export default defineAgentTool<{ file: string }>({
|
|
5
|
+
description: '修改 QQ 头像。',
|
|
6
|
+
inputSchema: z.object({
|
|
7
|
+
file: z.string().describe('图片(URL 或 base64)'),
|
|
8
|
+
}),
|
|
9
|
+
adapter: 'napcat',
|
|
10
|
+
tags: ['napcat', 'qq'],
|
|
11
|
+
keywords: ['头像', 'avatar', '设置头像', '换头像'],
|
|
12
|
+
async execute({ file }: { file: string }, context) {
|
|
13
|
+
const endpoint = context.$client;
|
|
14
|
+
await endpoint.setQQAvatar(file);
|
|
15
|
+
return { success: true };
|
|
16
|
+
},
|
|
17
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// Generated by build-plugin-runtime-entries.mjs. Do not edit.
|
|
2
|
+
import { defineAgentTool } from '@zhin.js/tool';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
export default defineAgentTool({
|
|
5
|
+
description: '设置在线状态(在线、隐身、忙碌等)。',
|
|
6
|
+
inputSchema: z.object({
|
|
7
|
+
status: z.number().describe('状态码(11=在线, 21=离开, 31=隐身, 41=忙碌, 50=请勿打扰, 60=Q我吧)'),
|
|
8
|
+
ext_status: z.number().optional().describe('扩展状态码'),
|
|
9
|
+
}),
|
|
10
|
+
adapter: 'napcat',
|
|
11
|
+
tags: ['napcat', 'qq'],
|
|
12
|
+
keywords: ['在线状态', '隐身', '忙碌', 'online', 'status'],
|
|
13
|
+
async execute({ status, ext_status }, context) {
|
|
14
|
+
const endpoint = context.$client;
|
|
15
|
+
await endpoint.setOnlineStatus(status, ext_status || 0);
|
|
16
|
+
return { success: true };
|
|
17
|
+
},
|
|
18
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { defineAgentTool } from '@zhin.js/tool';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
|
|
4
|
+
export default defineAgentTool<{ status: number; ext_status?: number }>({
|
|
5
|
+
description: '设置在线状态(在线、隐身、忙碌等)。',
|
|
6
|
+
inputSchema: z.object({
|
|
7
|
+
status: z.number().describe('状态码(11=在线, 21=离开, 31=隐身, 41=忙碌, 50=请勿打扰, 60=Q我吧)'),
|
|
8
|
+
ext_status: z.number().optional().describe('扩展状态码'),
|
|
9
|
+
}),
|
|
10
|
+
adapter: 'napcat',
|
|
11
|
+
tags: ['napcat', 'qq'],
|
|
12
|
+
keywords: ['在线状态', '隐身', '忙碌', 'online', 'status'],
|
|
13
|
+
async execute({ status, ext_status }: { status: number; ext_status?: number }, context) {
|
|
14
|
+
const endpoint = context.$client;
|
|
15
|
+
await endpoint.setOnlineStatus(status, ext_status || 0);
|
|
16
|
+
return { success: true };
|
|
17
|
+
},
|
|
18
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// Generated by build-plugin-runtime-entries.mjs. Do not edit.
|
|
2
|
+
import { defineAgentTool } from '@zhin.js/tool';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
export default defineAgentTool({
|
|
5
|
+
description: '修改 QQ 资料(昵称等)。',
|
|
6
|
+
inputSchema: z.object({
|
|
7
|
+
nickname: z.string().describe('昵称'),
|
|
8
|
+
company: z.string().optional().describe('公司(可选)'),
|
|
9
|
+
email: z.string().optional().describe('邮箱(可选)'),
|
|
10
|
+
college: z.string().optional().describe('学校(可选)'),
|
|
11
|
+
personal_note: z.string().optional().describe('个人说明(可选)'),
|
|
12
|
+
}),
|
|
13
|
+
adapter: 'napcat',
|
|
14
|
+
tags: ['napcat', 'qq'],
|
|
15
|
+
keywords: ['修改资料', '设置昵称', 'profile', 'set profile'],
|
|
16
|
+
async execute({ nickname, company, email, college, personal_note }, context) {
|
|
17
|
+
const endpoint = context.$client;
|
|
18
|
+
await endpoint.setQQProfile(nickname, company, email, college, personal_note);
|
|
19
|
+
return { success: true };
|
|
20
|
+
},
|
|
21
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { defineAgentTool } from '@zhin.js/tool';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
|
|
4
|
+
export default defineAgentTool<{ nickname: string; company?: string; email?: string; college?: string; personal_note?: string }>({
|
|
5
|
+
description: '修改 QQ 资料(昵称等)。',
|
|
6
|
+
inputSchema: z.object({
|
|
7
|
+
nickname: z.string().describe('昵称'),
|
|
8
|
+
company: z.string().optional().describe('公司(可选)'),
|
|
9
|
+
email: z.string().optional().describe('邮箱(可选)'),
|
|
10
|
+
college: z.string().optional().describe('学校(可选)'),
|
|
11
|
+
personal_note: z.string().optional().describe('个人说明(可选)'),
|
|
12
|
+
}),
|
|
13
|
+
adapter: 'napcat',
|
|
14
|
+
tags: ['napcat', 'qq'],
|
|
15
|
+
keywords: ['修改资料', '设置昵称', 'profile', 'set profile'],
|
|
16
|
+
async execute({ nickname, company, email, college, personal_note }: { nickname: string; company?: string; email?: string; college?: string; personal_note?: string }, context) {
|
|
17
|
+
const endpoint = context.$client;
|
|
18
|
+
await endpoint.setQQProfile(nickname, company, email, college, personal_note);
|
|
19
|
+
return { success: true };
|
|
20
|
+
},
|
|
21
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// Generated by build-plugin-runtime-entries.mjs. Do not edit.
|
|
2
|
+
import { defineAgentTool } from '@zhin.js/tool';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
export default defineAgentTool({
|
|
5
|
+
description: '设置个人签名(个性签名)。',
|
|
6
|
+
inputSchema: z.object({
|
|
7
|
+
signature: z.string().describe('签名内容'),
|
|
8
|
+
}),
|
|
9
|
+
adapter: 'napcat',
|
|
10
|
+
tags: ['napcat', 'qq'],
|
|
11
|
+
keywords: ['签名', '个性签名', 'signature', 'longnick'],
|
|
12
|
+
async execute({ signature }, context) {
|
|
13
|
+
const endpoint = context.$client;
|
|
14
|
+
await endpoint.setSelfLongnick(signature);
|
|
15
|
+
return { success: true };
|
|
16
|
+
},
|
|
17
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { defineAgentTool } from '@zhin.js/tool';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
|
|
4
|
+
export default defineAgentTool<{ signature: string }>({
|
|
5
|
+
description: '设置个人签名(个性签名)。',
|
|
6
|
+
inputSchema: z.object({
|
|
7
|
+
signature: z.string().describe('签名内容'),
|
|
8
|
+
}),
|
|
9
|
+
adapter: 'napcat',
|
|
10
|
+
tags: ['napcat', 'qq'],
|
|
11
|
+
keywords: ['签名', '个性签名', 'signature', 'longnick'],
|
|
12
|
+
async execute({ signature }: { signature: string }, context) {
|
|
13
|
+
const endpoint = context.$client;
|
|
14
|
+
await endpoint.setSelfLongnick(signature);
|
|
15
|
+
return { success: true };
|
|
16
|
+
},
|
|
17
|
+
});
|