@zhin.js/adapter-napcat 7.0.0 → 7.0.1
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 +22 -0
- package/README.md +18 -3
- package/adapters/napcat.js +1 -8
- package/adapters/napcat.ts +1 -8
- package/agent/tools/ai_tts.ts +4 -6
- package/agent/tools/del_group_notice.ts +4 -6
- package/agent/tools/delete_essence_msg.ts +4 -6
- package/agent/tools/delete_friend.ts +4 -6
- package/agent/tools/download_file.ts +4 -6
- package/agent/tools/forward_single_msg.ts +4 -8
- package/agent/tools/get_ai_characters.ts +4 -6
- package/agent/tools/get_essence_list.ts +4 -6
- package/agent/tools/get_friend_msg_history.ts +4 -6
- package/agent/tools/get_group_file_url.ts +4 -6
- package/agent/tools/get_group_info_ex.ts +4 -6
- package/agent/tools/get_group_msg_history.ts +4 -6
- package/agent/tools/get_group_notice.ts +4 -6
- package/agent/tools/get_group_root_files.ts +4 -6
- package/agent/tools/get_group_shut_list.ts +4 -6
- package/agent/tools/get_mini_app_ark.ts +4 -6
- package/agent/tools/get_user_status.ts +4 -6
- package/agent/tools/group_sign.ts +4 -6
- package/agent/tools/mark_msg_as_read.ts +4 -6
- package/agent/tools/ocr_image.ts +4 -6
- package/agent/tools/send_forward_msg.ts +4 -8
- package/agent/tools/send_group_notice.ts +4 -6
- package/agent/tools/send_like.ts +4 -6
- package/agent/tools/send_poke.ts +4 -6
- package/agent/tools/set_avatar.ts +4 -6
- package/agent/tools/set_emoji_reaction.ts +4 -6
- package/agent/tools/set_essence_msg.ts +4 -6
- package/agent/tools/set_group_portrait.ts +4 -6
- package/agent/tools/set_online_status.ts +4 -6
- package/agent/tools/set_profile.ts +4 -6
- package/agent/tools/set_signature.ts +4 -6
- package/agent/tools/set_title.ts +4 -6
- package/agent/tools/translate.ts +4 -6
- package/agent/tools/upload_group_file.ts +4 -6
- package/lib/{napcat-agent-deps.d.ts → client.d.ts} +15 -14
- package/lib/client.js +62 -0
- package/lib/http-endpoint.d.ts +5 -6
- package/lib/http-endpoint.js +22 -12
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/napcat-endpoint-commands.d.ts +1 -1
- package/lib/side-event-dispatch.d.ts +2 -2
- package/lib/side-event-dispatch.js +3 -3
- package/lib/ws-endpoint.d.ts +5 -41
- package/lib/ws-endpoint.js +24 -156
- package/lib/wss-endpoint.d.ts +5 -6
- package/lib/wss-endpoint.js +23 -13
- package/package.json +15 -14
- package/src/client.ts +79 -0
- package/src/http-endpoint.ts +24 -20
- package/src/index.ts +4 -7
- package/src/side-event-dispatch.ts +4 -4
- package/src/ws-endpoint.ts +26 -202
- package/src/wss-endpoint.ts +25 -21
- package/lib/napcat-agent-deps.js +0 -33
- package/src/napcat-agent-deps.ts +0 -95
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# @zhin.js/adapter-napcat
|
|
2
2
|
|
|
3
|
+
## 7.0.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 1fc78bc: Unify native platform Client access behind the literal `adapter` discriminant. Handlers infer both native events and Clients, while command, inbound/outbound middleware, and both Agent tool authoring surfaces expose the exact operation-scoped Client through a lazy `$client` getter. Definitions without `adapter` keep `$client` typed as `unknown`, and runtime dispatch rejects adapter mismatches before resolving the Client. Bundled platform tools now use this single path instead of model-provided endpoint ids and adapter-specific dependency wrappers. Every adapter registers one Client/EventMap contract, and protocol adapters including NapCat, Milky, OneBot and Satori now produce transport-independent Client objects rather than letting Endpoint instances impersonate Clients.
|
|
8
|
+
- Updated dependencies [e9c6a73]
|
|
9
|
+
- Updated dependencies [4e8117c]
|
|
10
|
+
- Updated dependencies [902fa35]
|
|
11
|
+
- Updated dependencies [54bfd6b]
|
|
12
|
+
- Updated dependencies [12025ee]
|
|
13
|
+
- Updated dependencies [09b14d6]
|
|
14
|
+
- Updated dependencies [1fc78bc]
|
|
15
|
+
- @zhin.js/agent@1.1.16
|
|
16
|
+
- @zhin.js/adapter@1.2.1
|
|
17
|
+
- @zhin.js/core@1.5.14
|
|
18
|
+
- @zhin.js/host-http@1.0.13
|
|
19
|
+
- @zhin.js/command@1.0.16
|
|
20
|
+
- @zhin.js/logger@1.0.77
|
|
21
|
+
- zhin.js@6.0.14
|
|
22
|
+
- @zhin.js/feature-kit@1.0.13
|
|
23
|
+
- @zhin.js/permission@1.0.4
|
|
24
|
+
|
|
3
25
|
## 7.0.0
|
|
4
26
|
|
|
5
27
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@ Zhin.js [NapCatQQ](https://github.com/NapNeko/NapCatQQ) 适配器(Plugin Runti
|
|
|
8
8
|
- 约定式 `defineAdapter` / `definePlugin`(无需 `usePlugin`)
|
|
9
9
|
- **正向 WebSocket**(`connection: ws`):应用连 NapCat WS
|
|
10
10
|
- `access_token` 鉴权(Bearer + query)
|
|
11
|
-
- 入站经 `
|
|
11
|
+
- 入站经 `Endpoint.emit(...)`(去重 + 自发过滤);出站 `send({ conversation, payload })`
|
|
12
12
|
- 41 个 AI 工具(`agent/tools/`)
|
|
13
13
|
|
|
14
14
|
## 安装
|
|
@@ -20,13 +20,19 @@ pnpm add @zhin.js/adapter-napcat
|
|
|
20
20
|
## Plugin Runtime
|
|
21
21
|
|
|
22
22
|
- `@zhin.js/adapter` — 约定式 `adapters/napcat.ts`(`defineAdapter`)
|
|
23
|
-
- `@zhin.js/core` — `
|
|
23
|
+
- `@zhin.js/core` — `Endpoint.emit(...)` 入站、`outboundMessageToken` 出站
|
|
24
24
|
- `zhin.js` — `plugin.ts`(`definePlugin`)
|
|
25
25
|
- 配置经插件 `schema.json` 落到 `plugins.<instanceKey>`
|
|
26
26
|
|
|
27
27
|
入站:`gateway.receive({ conversation, message: { conversation, id }, content, sender, metadata })`(`conversation` 为 ConversationRef:私聊 `kind: 'private'`、群聊 `kind: 'group'`,临时会话群容器进 `parent`)
|
|
28
28
|
出站:`send({ conversation, payload })` → WS `send_private_msg` / `send_group_msg`
|
|
29
29
|
|
|
30
|
+
## 前置条件
|
|
31
|
+
|
|
32
|
+
1. 安装并登录 NapCatQQ,启用一个与 Zhin 配置匹配的 OneBot 11 连接。
|
|
33
|
+
2. 正向 WS 需 Zhin 可达 NapCat;反向 WS/HTTP 上报需 NapCat 可达 Zhin HTTP Host。
|
|
34
|
+
3. 两端配置相同的 `access_token`,不要把未鉴权端口暴露到公网。
|
|
35
|
+
|
|
30
36
|
## 最小配置
|
|
31
37
|
|
|
32
38
|
```yaml
|
|
@@ -67,7 +73,7 @@ plugins:
|
|
|
67
73
|
|
|
68
74
|
## 迁移说明(Plugin Runtime)
|
|
69
75
|
|
|
70
|
-
- **notice / request / meta 侧事件**:经 `
|
|
76
|
+
- **notice / request / meta 侧事件**:经 the unified `Endpoint.emit(...)` ingress 归一后分发到 `handlers`(`notice.receive` / `request.receive` / `system.receive`),请求带 `$approve` / `$reject`。消息仍走 `outboundMessageToken`。
|
|
71
77
|
- **群管工具暂未迁移**:旧 Adapter 经 `createSceneManagementTools` 注册踢人 / 禁言 / 群名片等成套 agent 工具;迁移后 `agent/tools/` 仅覆盖 NapCat 扩展 API,其余群管能力可通过 `callApi`(如 `set_group_kick`、`set_group_ban`)作为逃生舱调用。
|
|
72
78
|
- **平台权限门禁**:`plugin.ts` setup 已注册 `registerDefaultScenePlatformPermitChecker('napcat')`,`scene_admin` / `scene_owner` 依据入站 metadata 中的 sender `role`(owner / admin)判定。
|
|
73
79
|
|
|
@@ -76,6 +82,15 @@ plugins:
|
|
|
76
82
|
- [NapCatQQ](https://github.com/NapNeko/NapCatQQ)
|
|
77
83
|
- [适配器概览](https://zhin.js.org/essentials/adapters)
|
|
78
84
|
|
|
85
|
+
## 故障排查
|
|
86
|
+
|
|
87
|
+
| 现象 | 排查 |
|
|
88
|
+
| --- | --- |
|
|
89
|
+
| WS 连接被拒绝 | 检查 NapCat URL、端口与连接方向 |
|
|
90
|
+
| 401 或握手失败 | 确认两端 token 一致,反向代理保留 Authorization |
|
|
91
|
+
| 重复或自身消息触发 | 检查是否同时启用了多条上报连接 |
|
|
92
|
+
| 请求/通知缺失 | 确认 NapCat 上报 notice/request/meta,并查看 Endpoint 对应分类 |
|
|
93
|
+
|
|
79
94
|
## 许可证
|
|
80
95
|
|
|
81
96
|
MIT License
|
package/adapters/napcat.js
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
* Convention entry: discover `adapters/napcat.ts` → defineAdapter.
|
|
4
4
|
*/
|
|
5
5
|
import { defineAdapter } from 'zhin.js/adapter';
|
|
6
|
-
import { messageGatewayToken, sideEventGatewayToken } from '@zhin.js/core/runtime';
|
|
7
6
|
import { httpHostToken } from '@zhin.js/host-http';
|
|
8
7
|
import { NapCatHttpEndpoint } from "../lib/http-endpoint.js";
|
|
9
8
|
import { resolveNapCatConfig } from "../lib/protocol.js";
|
|
@@ -24,8 +23,6 @@ export default defineAdapter({
|
|
|
24
23
|
},
|
|
25
24
|
create(context) {
|
|
26
25
|
const config = resolveNapCatConfig(context.config);
|
|
27
|
-
const gateway = context.use(messageGatewayToken);
|
|
28
|
-
const sideEvents = context.use(sideEventGatewayToken);
|
|
29
26
|
// 注册到插件运行时状态(napcat.endpoint list 的"运行中"数据源)
|
|
30
27
|
context.use(napcatRuntimeStateToken).endpoints.set(config.id, {
|
|
31
28
|
id: config.id,
|
|
@@ -34,8 +31,6 @@ export default defineAdapter({
|
|
|
34
31
|
if (config.connection === 'wss') {
|
|
35
32
|
return new NapCatWssEndpoint({
|
|
36
33
|
id: context.id,
|
|
37
|
-
gateway,
|
|
38
|
-
sideEvents,
|
|
39
34
|
http: context.use(httpHostToken),
|
|
40
35
|
config,
|
|
41
36
|
});
|
|
@@ -43,12 +38,10 @@ export default defineAdapter({
|
|
|
43
38
|
if (config.connection === 'http') {
|
|
44
39
|
return new NapCatHttpEndpoint({
|
|
45
40
|
id: context.id,
|
|
46
|
-
gateway,
|
|
47
|
-
sideEvents,
|
|
48
41
|
http: context.use(httpHostToken),
|
|
49
42
|
config,
|
|
50
43
|
});
|
|
51
44
|
}
|
|
52
|
-
return new NapCatWsEndpoint({ id: context.id,
|
|
45
|
+
return new NapCatWsEndpoint({ id: context.id, config });
|
|
53
46
|
},
|
|
54
47
|
});
|
package/adapters/napcat.ts
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
* Convention entry: discover `adapters/napcat.ts` → defineAdapter.
|
|
3
3
|
*/
|
|
4
4
|
import { defineAdapter } from 'zhin.js/adapter';
|
|
5
|
-
import { messageGatewayToken, sideEventGatewayToken } from '@zhin.js/core/runtime';
|
|
6
5
|
import { httpHostToken } from '@zhin.js/host-http';
|
|
7
6
|
import { NapCatHttpEndpoint } from '../src/http-endpoint.js';
|
|
8
7
|
import { resolveNapCatConfig, type NapCatAdapterConfig } from '../src/protocol.js';
|
|
@@ -41,8 +40,6 @@ export default defineAdapter<NapCatAdapterConfig>({
|
|
|
41
40
|
},
|
|
42
41
|
create(context) {
|
|
43
42
|
const config = resolveNapCatConfig(context.config);
|
|
44
|
-
const gateway = context.use(messageGatewayToken);
|
|
45
|
-
const sideEvents = context.use(sideEventGatewayToken);
|
|
46
43
|
// 注册到插件运行时状态(napcat.endpoint list 的"运行中"数据源)
|
|
47
44
|
context.use(napcatRuntimeStateToken).endpoints.set(config.id, {
|
|
48
45
|
id: config.id,
|
|
@@ -51,8 +48,6 @@ export default defineAdapter<NapCatAdapterConfig>({
|
|
|
51
48
|
if (config.connection === 'wss') {
|
|
52
49
|
return new NapCatWssEndpoint({
|
|
53
50
|
id: context.id,
|
|
54
|
-
gateway,
|
|
55
|
-
sideEvents,
|
|
56
51
|
http: context.use(httpHostToken),
|
|
57
52
|
config,
|
|
58
53
|
});
|
|
@@ -60,12 +55,10 @@ export default defineAdapter<NapCatAdapterConfig>({
|
|
|
60
55
|
if (config.connection === 'http') {
|
|
61
56
|
return new NapCatHttpEndpoint({
|
|
62
57
|
id: context.id,
|
|
63
|
-
gateway,
|
|
64
|
-
sideEvents,
|
|
65
58
|
http: context.use(httpHostToken),
|
|
66
59
|
config,
|
|
67
60
|
});
|
|
68
61
|
}
|
|
69
|
-
return new NapCatWsEndpoint({ id: context.id,
|
|
62
|
+
return new NapCatWsEndpoint({ id: context.id, config });
|
|
70
63
|
},
|
|
71
64
|
});
|
package/agent/tools/ai_tts.ts
CHANGED
|
@@ -1,21 +1,19 @@
|
|
|
1
1
|
import { defineAgentTool } from '@zhin.js/agent/tools';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
-
import { getEndpoint } from '../../src/napcat-agent-deps.js';
|
|
4
3
|
|
|
5
|
-
export default defineAgentTool<{
|
|
4
|
+
export default defineAgentTool<{ group_id: number; character: string; text: string }>({
|
|
6
5
|
description: 'AI 文字转语音,在群聊中发送 AI 语音消息。',
|
|
7
6
|
inputSchema: z.object({
|
|
8
|
-
endpoint_id: z.string().describe('Endpoint 名称'),
|
|
9
7
|
group_id: z.number().describe('群号'),
|
|
10
8
|
character: z.string().describe('AI 语音角色 ID(可先用 napcat_get_ai_characters 查询)'),
|
|
11
9
|
text: z.string().describe('要转为语音的文字'),
|
|
12
10
|
}),
|
|
13
|
-
|
|
11
|
+
adapter: 'napcat',
|
|
14
12
|
tags: ['napcat', 'qq'],
|
|
15
13
|
keywords: ['AI语音', 'TTS', '文字转语音', 'ai record'],
|
|
16
14
|
scopes: ['group'],
|
|
17
|
-
async execute({
|
|
18
|
-
const endpoint =
|
|
15
|
+
async execute({ group_id, character, text }: { group_id: number; character: string; text: string }, context) {
|
|
16
|
+
const endpoint = context.$client;
|
|
19
17
|
return endpoint.sendGroupAiRecord(group_id, character, text);
|
|
20
18
|
},
|
|
21
19
|
});
|
|
@@ -1,21 +1,19 @@
|
|
|
1
1
|
import { defineAgentTool } from '@zhin.js/agent/tools';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
-
import { getEndpoint } from '../../src/napcat-agent-deps.js';
|
|
4
3
|
|
|
5
|
-
export default defineAgentTool<{
|
|
4
|
+
export default defineAgentTool<{ group_id: number; notice_id: string }>({
|
|
6
5
|
description: '删除群公告。',
|
|
7
6
|
inputSchema: z.object({
|
|
8
|
-
endpoint_id: z.string().describe('Endpoint 名称'),
|
|
9
7
|
group_id: z.number().describe('群号'),
|
|
10
8
|
notice_id: z.string().describe('公告 ID'),
|
|
11
9
|
}),
|
|
12
|
-
|
|
10
|
+
adapter: 'napcat',
|
|
13
11
|
tags: ['napcat', 'qq'],
|
|
14
12
|
keywords: ['删除公告', 'delete notice'],
|
|
15
13
|
permissions: ['platform(napcat,scene_admin)'],
|
|
16
14
|
scopes: ['group'],
|
|
17
|
-
async execute({
|
|
18
|
-
const endpoint =
|
|
15
|
+
async execute({ group_id, notice_id }: { group_id: number; notice_id: string }, context) {
|
|
16
|
+
const endpoint = context.$client;
|
|
19
17
|
await endpoint.deleteGroupNotice(group_id, notice_id);
|
|
20
18
|
return { success: true };
|
|
21
19
|
},
|
|
@@ -1,20 +1,18 @@
|
|
|
1
1
|
import { defineAgentTool } from '@zhin.js/agent/tools';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
-
import { getEndpoint } from '../../src/napcat-agent-deps.js';
|
|
4
3
|
|
|
5
|
-
export default defineAgentTool<{
|
|
4
|
+
export default defineAgentTool<{ message_id: number }>({
|
|
6
5
|
description: '移除群精华消息。',
|
|
7
6
|
inputSchema: z.object({
|
|
8
|
-
endpoint_id: z.string().describe('Endpoint 名称'),
|
|
9
7
|
message_id: z.number().describe('消息 ID'),
|
|
10
8
|
}),
|
|
11
|
-
|
|
9
|
+
adapter: 'napcat',
|
|
12
10
|
tags: ['napcat', 'qq'],
|
|
13
11
|
keywords: ['取消精华', '移除精华', 'delete essence'],
|
|
14
12
|
permissions: ['platform(napcat,scene_admin)'],
|
|
15
13
|
scopes: ['group'],
|
|
16
|
-
async execute({
|
|
17
|
-
const endpoint =
|
|
14
|
+
async execute({ message_id }: { message_id: number }, context) {
|
|
15
|
+
const endpoint = context.$client;
|
|
18
16
|
await endpoint.deleteEssenceMsg(message_id);
|
|
19
17
|
return { success: true };
|
|
20
18
|
},
|
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
import { defineAgentTool } from '@zhin.js/agent/tools';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
-
import { getEndpoint } from '../../src/napcat-agent-deps.js';
|
|
4
3
|
|
|
5
|
-
export default defineAgentTool<{
|
|
4
|
+
export default defineAgentTool<{ user_id: number }>({
|
|
6
5
|
description: '删除好友。',
|
|
7
6
|
inputSchema: z.object({
|
|
8
|
-
endpoint_id: z.string().describe('Endpoint 名称'),
|
|
9
7
|
user_id: z.number().describe('好友 QQ 号'),
|
|
10
8
|
}),
|
|
11
|
-
|
|
9
|
+
adapter: 'napcat',
|
|
12
10
|
tags: ['napcat', 'qq'],
|
|
13
11
|
keywords: ['删除好友', 'delete friend', '删好友'],
|
|
14
12
|
permissions: ['platform(napcat,scene_admin)'],
|
|
15
|
-
async execute({
|
|
16
|
-
const endpoint =
|
|
13
|
+
async execute({ user_id }: { user_id: number }, context) {
|
|
14
|
+
const endpoint = context.$client;
|
|
17
15
|
await endpoint.deleteFriend(user_id);
|
|
18
16
|
return { success: true };
|
|
19
17
|
},
|
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
import { defineAgentTool } from '@zhin.js/agent/tools';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
-
import { getEndpoint } from '../../src/napcat-agent-deps.js';
|
|
4
3
|
|
|
5
|
-
export default defineAgentTool<{
|
|
4
|
+
export default defineAgentTool<{ url: string; thread_count?: number }>({
|
|
6
5
|
description: '下载文件到 NapCat 缓存目录,返回本地路径。',
|
|
7
6
|
inputSchema: z.object({
|
|
8
|
-
endpoint_id: z.string().describe('Endpoint 名称'),
|
|
9
7
|
url: z.string().describe('文件 URL'),
|
|
10
8
|
thread_count: z.number().optional().describe('下载线程数(可选,默认 1)'),
|
|
11
9
|
}),
|
|
12
|
-
|
|
10
|
+
adapter: 'napcat',
|
|
13
11
|
tags: ['napcat', 'qq'],
|
|
14
12
|
keywords: ['下载', 'download', '下载文件'],
|
|
15
|
-
async execute({
|
|
16
|
-
const endpoint =
|
|
13
|
+
async execute({ url, thread_count }: { url: string; thread_count?: number }, context) {
|
|
14
|
+
const endpoint = context.$client;
|
|
17
15
|
return endpoint.downloadFile(url, thread_count || 1);
|
|
18
16
|
},
|
|
19
17
|
});
|
|
@@ -1,30 +1,26 @@
|
|
|
1
1
|
import { defineAgentTool } from '@zhin.js/agent/tools';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
-
import { getEndpoint } from '../../src/napcat-agent-deps.js';
|
|
4
3
|
|
|
5
4
|
export default defineAgentTool<{
|
|
6
|
-
endpoint_id: string;
|
|
7
5
|
target_type: 'friend' | 'group';
|
|
8
6
|
target_id: number;
|
|
9
7
|
message_id: number;
|
|
10
8
|
}>({
|
|
11
9
|
description: '转发单条消息到指定好友或群。',
|
|
12
10
|
inputSchema: z.object({
|
|
13
|
-
endpoint_id: z.string().describe('Endpoint 名称'),
|
|
14
11
|
target_type: z.enum(['friend', 'group']).describe('friend 或 group'),
|
|
15
12
|
target_id: z.number().describe('目标好友 QQ 号或群号'),
|
|
16
13
|
message_id: z.number().describe('要转发的消息 ID'),
|
|
17
14
|
}),
|
|
18
|
-
|
|
15
|
+
adapter: 'napcat',
|
|
19
16
|
tags: ['napcat', 'qq'],
|
|
20
17
|
keywords: ['转发', 'forward', '单条转发'],
|
|
21
|
-
async execute({
|
|
22
|
-
endpoint_id: string;
|
|
18
|
+
async execute({ target_type, target_id, message_id }: {
|
|
23
19
|
target_type: 'friend' | 'group';
|
|
24
20
|
target_id: number;
|
|
25
21
|
message_id: number;
|
|
26
|
-
}) {
|
|
27
|
-
const endpoint =
|
|
22
|
+
}, context) {
|
|
23
|
+
const endpoint = context.$client;
|
|
28
24
|
if (target_type === 'friend') await endpoint.forwardFriendSingleMsg(target_id, message_id);
|
|
29
25
|
else await endpoint.forwardGroupSingleMsg(target_id, message_id);
|
|
30
26
|
return { success: true };
|
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
import { defineAgentTool } from '@zhin.js/agent/tools';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
-
import { getEndpoint } from '../../src/napcat-agent-deps.js';
|
|
4
3
|
|
|
5
|
-
export default defineAgentTool<{
|
|
4
|
+
export default defineAgentTool<{ group_id: number }>({
|
|
6
5
|
description: '获取 AI 语音角色列表,用于 napcat_ai_tts 的 character 参数。',
|
|
7
6
|
inputSchema: z.object({
|
|
8
|
-
endpoint_id: z.string().describe('Endpoint 名称'),
|
|
9
7
|
group_id: z.number().describe('群号'),
|
|
10
8
|
}),
|
|
11
|
-
|
|
9
|
+
adapter: 'napcat',
|
|
12
10
|
tags: ['napcat', 'qq'],
|
|
13
11
|
keywords: ['AI角色', 'ai characters', '语音角色'],
|
|
14
12
|
scopes: ['group'],
|
|
15
|
-
async execute({
|
|
16
|
-
const endpoint =
|
|
13
|
+
async execute({ group_id }: { group_id: number }, context) {
|
|
14
|
+
const endpoint = context.$client;
|
|
17
15
|
return endpoint.getAiCharacters(group_id);
|
|
18
16
|
},
|
|
19
17
|
});
|
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
import { defineAgentTool } from '@zhin.js/agent/tools';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
-
import { getEndpoint } from '../../src/napcat-agent-deps.js';
|
|
4
3
|
|
|
5
|
-
export default defineAgentTool<{
|
|
4
|
+
export default defineAgentTool<{ group_id: number }>({
|
|
6
5
|
description: '获取群精华消息列表。',
|
|
7
6
|
inputSchema: z.object({
|
|
8
|
-
endpoint_id: z.string().describe('Endpoint 名称'),
|
|
9
7
|
group_id: z.number().describe('群号'),
|
|
10
8
|
}),
|
|
11
|
-
|
|
9
|
+
adapter: 'napcat',
|
|
12
10
|
tags: ['napcat', 'qq'],
|
|
13
11
|
keywords: ['精华列表', 'essence list'],
|
|
14
12
|
scopes: ['group'],
|
|
15
|
-
async execute({
|
|
16
|
-
const endpoint =
|
|
13
|
+
async execute({ group_id }: { group_id: number }, context) {
|
|
14
|
+
const endpoint = context.$client;
|
|
17
15
|
return endpoint.getEssenceMsgList(group_id);
|
|
18
16
|
},
|
|
19
17
|
});
|
|
@@ -1,20 +1,18 @@
|
|
|
1
1
|
import { defineAgentTool } from '@zhin.js/agent/tools';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
-
import { getEndpoint } from '../../src/napcat-agent-deps.js';
|
|
4
3
|
|
|
5
|
-
export default defineAgentTool<{
|
|
4
|
+
export default defineAgentTool<{ user_id: number; message_seq?: number; count?: number }>({
|
|
6
5
|
description: '获取私聊消息历史记录。',
|
|
7
6
|
inputSchema: z.object({
|
|
8
|
-
endpoint_id: z.string().describe('Endpoint 名称'),
|
|
9
7
|
user_id: z.number().describe('QQ 号'),
|
|
10
8
|
message_seq: z.number().optional().describe('起始消息序号(可选)'),
|
|
11
9
|
count: z.number().optional().describe('获取条数(可选)'),
|
|
12
10
|
}),
|
|
13
|
-
|
|
11
|
+
adapter: 'napcat',
|
|
14
12
|
tags: ['napcat', 'qq'],
|
|
15
13
|
keywords: ['私聊记录', '好友聊天记录', 'friend history'],
|
|
16
|
-
async execute({
|
|
17
|
-
const endpoint =
|
|
14
|
+
async execute({ user_id, message_seq, count }: { user_id: number; message_seq?: number; count?: number }, context) {
|
|
15
|
+
const endpoint = context.$client;
|
|
18
16
|
return endpoint.getFriendMsgHistory(user_id, message_seq, count);
|
|
19
17
|
},
|
|
20
18
|
});
|
|
@@ -1,21 +1,19 @@
|
|
|
1
1
|
import { defineAgentTool } from '@zhin.js/agent/tools';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
-
import { getEndpoint } from '../../src/napcat-agent-deps.js';
|
|
4
3
|
|
|
5
|
-
export default defineAgentTool<{
|
|
4
|
+
export default defineAgentTool<{ group_id: number; file_id: string; busid: number }>({
|
|
6
5
|
description: '获取群文件下载链接。',
|
|
7
6
|
inputSchema: z.object({
|
|
8
|
-
endpoint_id: z.string().describe('Endpoint 名称'),
|
|
9
7
|
group_id: z.number().describe('群号'),
|
|
10
8
|
file_id: z.string().describe('文件 ID'),
|
|
11
9
|
busid: z.number().describe('文件类型 ID'),
|
|
12
10
|
}),
|
|
13
|
-
|
|
11
|
+
adapter: 'napcat',
|
|
14
12
|
tags: ['napcat', 'qq'],
|
|
15
13
|
keywords: ['文件链接', 'file url', '下载文件'],
|
|
16
14
|
scopes: ['group'],
|
|
17
|
-
async execute({
|
|
18
|
-
const endpoint =
|
|
15
|
+
async execute({ group_id, file_id, busid }: { group_id: number; file_id: string; busid: number }, context) {
|
|
16
|
+
const endpoint = context.$client;
|
|
19
17
|
return endpoint.getGroupFileUrl(group_id, file_id, busid);
|
|
20
18
|
},
|
|
21
19
|
});
|
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
import { defineAgentTool } from '@zhin.js/agent/tools';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
-
import { getEndpoint } from '../../src/napcat-agent-deps.js';
|
|
4
3
|
|
|
5
|
-
export default defineAgentTool<{
|
|
4
|
+
export default defineAgentTool<{ group_id: number }>({
|
|
6
5
|
description: '获取群组额外详细信息。',
|
|
7
6
|
inputSchema: z.object({
|
|
8
|
-
endpoint_id: z.string().describe('Endpoint 名称'),
|
|
9
7
|
group_id: z.number().describe('群号'),
|
|
10
8
|
}),
|
|
11
|
-
|
|
9
|
+
adapter: 'napcat',
|
|
12
10
|
tags: ['napcat', 'qq'],
|
|
13
11
|
keywords: ['群详情', '群额外信息', 'group info ex'],
|
|
14
12
|
scopes: ['group'],
|
|
15
|
-
async execute({
|
|
16
|
-
const endpoint =
|
|
13
|
+
async execute({ group_id }: { group_id: number }, context) {
|
|
14
|
+
const endpoint = context.$client;
|
|
17
15
|
return endpoint.getGroupInfoEx(group_id);
|
|
18
16
|
},
|
|
19
17
|
});
|
|
@@ -1,21 +1,19 @@
|
|
|
1
1
|
import { defineAgentTool } from '@zhin.js/agent/tools';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
-
import { getEndpoint } from '../../src/napcat-agent-deps.js';
|
|
4
3
|
|
|
5
|
-
export default defineAgentTool<{
|
|
4
|
+
export default defineAgentTool<{ group_id: number; message_seq?: number; count?: number }>({
|
|
6
5
|
description: '获取群消息历史记录。',
|
|
7
6
|
inputSchema: z.object({
|
|
8
|
-
endpoint_id: z.string().describe('Endpoint 名称'),
|
|
9
7
|
group_id: z.number().describe('群号'),
|
|
10
8
|
message_seq: z.number().optional().describe('起始消息序号(可选,不传从最新开始)'),
|
|
11
9
|
count: z.number().optional().describe('获取条数(可选)'),
|
|
12
10
|
}),
|
|
13
|
-
|
|
11
|
+
adapter: 'napcat',
|
|
14
12
|
tags: ['napcat', 'qq'],
|
|
15
13
|
keywords: ['群消息历史', '聊天记录', 'message history'],
|
|
16
14
|
scopes: ['group'],
|
|
17
|
-
async execute({
|
|
18
|
-
const endpoint =
|
|
15
|
+
async execute({ group_id, message_seq, count }: { group_id: number; message_seq?: number; count?: number }, context) {
|
|
16
|
+
const endpoint = context.$client;
|
|
19
17
|
return endpoint.getGroupMsgHistory(group_id, message_seq, count);
|
|
20
18
|
},
|
|
21
19
|
});
|
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
import { defineAgentTool } from '@zhin.js/agent/tools';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
-
import { getEndpoint } from '../../src/napcat-agent-deps.js';
|
|
4
3
|
|
|
5
|
-
export default defineAgentTool<{
|
|
4
|
+
export default defineAgentTool<{ group_id: number }>({
|
|
6
5
|
description: '获取群公告列表。',
|
|
7
6
|
inputSchema: z.object({
|
|
8
|
-
endpoint_id: z.string().describe('Endpoint 名称'),
|
|
9
7
|
group_id: z.number().describe('群号'),
|
|
10
8
|
}),
|
|
11
|
-
|
|
9
|
+
adapter: 'napcat',
|
|
12
10
|
tags: ['napcat', 'qq'],
|
|
13
11
|
keywords: ['群公告', '获取公告', 'get notice'],
|
|
14
12
|
scopes: ['group'],
|
|
15
|
-
async execute({
|
|
16
|
-
const endpoint =
|
|
13
|
+
async execute({ group_id }: { group_id: number }, context) {
|
|
14
|
+
const endpoint = context.$client;
|
|
17
15
|
return endpoint.getGroupNotice(group_id);
|
|
18
16
|
},
|
|
19
17
|
});
|
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
import { defineAgentTool } from '@zhin.js/agent/tools';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
-
import { getEndpoint } from '../../src/napcat-agent-deps.js';
|
|
4
3
|
|
|
5
|
-
export default defineAgentTool<{
|
|
4
|
+
export default defineAgentTool<{ group_id: number }>({
|
|
6
5
|
description: '获取群根目录文件列表。',
|
|
7
6
|
inputSchema: z.object({
|
|
8
|
-
endpoint_id: z.string().describe('Endpoint 名称'),
|
|
9
7
|
group_id: z.number().describe('群号'),
|
|
10
8
|
}),
|
|
11
|
-
|
|
9
|
+
adapter: 'napcat',
|
|
12
10
|
tags: ['napcat', 'qq'],
|
|
13
11
|
keywords: ['群文件列表', 'group files'],
|
|
14
12
|
scopes: ['group'],
|
|
15
|
-
async execute({
|
|
16
|
-
const endpoint =
|
|
13
|
+
async execute({ group_id }: { group_id: number }, context) {
|
|
14
|
+
const endpoint = context.$client;
|
|
17
15
|
return endpoint.getGroupRootFiles(group_id);
|
|
18
16
|
},
|
|
19
17
|
});
|
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
import { defineAgentTool } from '@zhin.js/agent/tools';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
-
import { getEndpoint } from '../../src/napcat-agent-deps.js';
|
|
4
3
|
|
|
5
|
-
export default defineAgentTool<{
|
|
4
|
+
export default defineAgentTool<{ group_id: number }>({
|
|
6
5
|
description: '获取群禁言列表。',
|
|
7
6
|
inputSchema: z.object({
|
|
8
|
-
endpoint_id: z.string().describe('Endpoint 名称'),
|
|
9
7
|
group_id: z.number().describe('群号'),
|
|
10
8
|
}),
|
|
11
|
-
|
|
9
|
+
adapter: 'napcat',
|
|
12
10
|
tags: ['napcat', 'qq'],
|
|
13
11
|
keywords: ['禁言列表', 'shut list', '被禁言'],
|
|
14
12
|
scopes: ['group'],
|
|
15
|
-
async execute({
|
|
16
|
-
const endpoint =
|
|
13
|
+
async execute({ group_id }: { group_id: number }, context) {
|
|
14
|
+
const endpoint = context.$client;
|
|
17
15
|
return endpoint.getGroupShutList(group_id);
|
|
18
16
|
},
|
|
19
17
|
});
|
|
@@ -1,22 +1,20 @@
|
|
|
1
1
|
import { defineAgentTool } from '@zhin.js/agent/tools';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
-
import { getEndpoint } from '../../src/napcat-agent-deps.js';
|
|
4
3
|
|
|
5
|
-
export default defineAgentTool<{
|
|
4
|
+
export default defineAgentTool<{ type: string; title: string; desc: string; pic_url: string; jump_url: string }>({
|
|
6
5
|
description: '签名小程序卡片(如 B 站分享卡片等)。',
|
|
7
6
|
inputSchema: z.object({
|
|
8
|
-
endpoint_id: z.string().describe('Endpoint 名称'),
|
|
9
7
|
type: z.string().describe('卡片类型'),
|
|
10
8
|
title: z.string().describe('标题'),
|
|
11
9
|
desc: z.string().describe('描述'),
|
|
12
10
|
pic_url: z.string().describe('图片 URL'),
|
|
13
11
|
jump_url: z.string().describe('跳转 URL'),
|
|
14
12
|
}),
|
|
15
|
-
|
|
13
|
+
adapter: 'napcat',
|
|
16
14
|
tags: ['napcat', 'qq'],
|
|
17
15
|
keywords: ['小程序', 'mini app', '卡片', 'ark'],
|
|
18
|
-
async execute({
|
|
19
|
-
const endpoint =
|
|
16
|
+
async execute({ type, title, desc, pic_url, jump_url }: { type: string; title: string; desc: string; pic_url: string; jump_url: string }, context) {
|
|
17
|
+
const endpoint = context.$client;
|
|
20
18
|
return endpoint.getMiniAppArk(type, title, desc, pic_url, jump_url);
|
|
21
19
|
},
|
|
22
20
|
});
|
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
import { defineAgentTool } from '@zhin.js/agent/tools';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
-
import { getEndpoint } from '../../src/napcat-agent-deps.js';
|
|
4
3
|
|
|
5
|
-
export default defineAgentTool<{
|
|
4
|
+
export default defineAgentTool<{ user_id: number }>({
|
|
6
5
|
description: '获取用户在线状态。',
|
|
7
6
|
inputSchema: z.object({
|
|
8
|
-
endpoint_id: z.string().describe('Endpoint 名称'),
|
|
9
7
|
user_id: z.number().describe('目标 QQ 号'),
|
|
10
8
|
}),
|
|
11
|
-
|
|
9
|
+
adapter: 'napcat',
|
|
12
10
|
tags: ['napcat', 'qq'],
|
|
13
11
|
keywords: ['在线状态', '用户状态', 'online status'],
|
|
14
|
-
async execute({
|
|
15
|
-
const endpoint =
|
|
12
|
+
async execute({ user_id }: { user_id: number }, context) {
|
|
13
|
+
const endpoint = context.$client;
|
|
16
14
|
return endpoint.ncGetUserStatus(user_id);
|
|
17
15
|
},
|
|
18
16
|
});
|
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
import { defineAgentTool } from '@zhin.js/agent/tools';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
-
import { getEndpoint } from '../../src/napcat-agent-deps.js';
|
|
4
3
|
|
|
5
|
-
export default defineAgentTool<{
|
|
4
|
+
export default defineAgentTool<{ group_id: number }>({
|
|
6
5
|
description: '群签到/群打卡。',
|
|
7
6
|
inputSchema: z.object({
|
|
8
|
-
endpoint_id: z.string().describe('Endpoint 名称'),
|
|
9
7
|
group_id: z.number().describe('群号'),
|
|
10
8
|
}),
|
|
11
|
-
|
|
9
|
+
adapter: 'napcat',
|
|
12
10
|
tags: ['napcat', 'qq'],
|
|
13
11
|
keywords: ['签到', '打卡', 'sign', 'check in'],
|
|
14
12
|
scopes: ['group'],
|
|
15
|
-
async execute({
|
|
16
|
-
const endpoint =
|
|
13
|
+
async execute({ group_id }: { group_id: number }, context) {
|
|
14
|
+
const endpoint = context.$client;
|
|
17
15
|
await endpoint.sendGroupSign(group_id);
|
|
18
16
|
return { success: true };
|
|
19
17
|
},
|