@zhin.js/adapter-qq 5.0.1 → 5.0.3
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 +60 -0
- package/README.md +52 -408
- package/adapters/qq.ts +45 -0
- package/agent/tools/add_role.ts +23 -0
- package/agent/tools/channel_info.ts +19 -0
- package/agent/tools/create_role.ts +22 -0
- package/agent/tools/list_channels.ts +20 -0
- package/agent/tools/list_guilds.ts +17 -0
- package/agent/tools/list_roles.ts +20 -0
- package/agent/tools/member_detail.ts +20 -0
- package/agent/tools/remove_role.ts +23 -0
- package/lib/endpoint.d.ts +64 -120
- package/lib/endpoint.js +279 -564
- package/lib/index.d.ts +6 -23
- package/lib/index.js +6 -375
- package/lib/platform-permit.d.ts +1 -2
- package/lib/platform-permit.js +4 -2
- package/lib/protocol.d.ts +96 -0
- package/lib/protocol.js +129 -0
- package/lib/qq-agent-deps.d.ts +21 -0
- package/lib/qq-agent-deps.js +30 -0
- package/lib/webhook.d.ts +18 -0
- package/lib/webhook.js +100 -0
- package/lib/ws.d.ts +24 -0
- package/lib/ws.js +118 -0
- package/package.json +47 -33
- package/plugin.ts +13 -0
- package/schema.json +51 -0
- package/src/endpoint.ts +313 -605
- package/src/index.ts +55 -368
- package/src/platform-permit.ts +1 -2
- package/src/protocol.ts +229 -0
- package/src/qq-agent-deps.ts +60 -0
- package/src/webhook.ts +127 -0
- package/src/ws.ts +172 -0
- package/client/Dashboard.tsx +0 -230
- package/client/index.tsx +0 -11
- package/client/tsconfig.json +0 -7
- package/client/utils/api.ts +0 -30
- package/dist/index.js +0 -30
- package/lib/adapter.d.ts +0 -32
- package/lib/adapter.d.ts.map +0 -1
- package/lib/adapter.js +0 -82
- package/lib/adapter.js.map +0 -1
- package/lib/endpoint.d.ts.map +0 -1
- package/lib/endpoint.js.map +0 -1
- package/lib/gateway-config.d.ts +0 -14
- package/lib/gateway-config.d.ts.map +0 -1
- package/lib/gateway-config.js +0 -32
- package/lib/gateway-config.js.map +0 -1
- package/lib/group-at-normalize.d.ts +0 -8
- package/lib/group-at-normalize.d.ts.map +0 -1
- package/lib/group-at-normalize.js +0 -68
- package/lib/group-at-normalize.js.map +0 -1
- package/lib/inbound-action.d.ts +0 -15
- package/lib/inbound-action.d.ts.map +0 -1
- package/lib/inbound-action.js +0 -57
- package/lib/inbound-action.js.map +0 -1
- package/lib/inbound-normalize.d.ts +0 -11
- package/lib/inbound-normalize.d.ts.map +0 -1
- package/lib/inbound-normalize.js +0 -47
- package/lib/inbound-normalize.js.map +0 -1
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/mention-enrich.d.ts +0 -12
- package/lib/mention-enrich.d.ts.map +0 -1
- package/lib/mention-enrich.js +0 -52
- package/lib/mention-enrich.js.map +0 -1
- package/lib/outbound-keyboard.d.ts +0 -4
- package/lib/outbound-keyboard.d.ts.map +0 -1
- package/lib/outbound-keyboard.js +0 -96
- package/lib/outbound-keyboard.js.map +0 -1
- package/lib/outbound-markdown.d.ts +0 -24
- package/lib/outbound-markdown.d.ts.map +0 -1
- package/lib/outbound-markdown.js +0 -177
- package/lib/outbound-markdown.js.map +0 -1
- package/lib/outbound-media.d.ts +0 -11
- package/lib/outbound-media.d.ts.map +0 -1
- package/lib/outbound-media.js +0 -51
- package/lib/outbound-media.js.map +0 -1
- package/lib/outbound-mixed-media.d.ts +0 -21
- package/lib/outbound-mixed-media.d.ts.map +0 -1
- package/lib/outbound-mixed-media.js +0 -78
- package/lib/outbound-mixed-media.js.map +0 -1
- package/lib/platform-permit.d.ts.map +0 -1
- package/lib/platform-permit.js.map +0 -1
- package/lib/qq-bind-api.d.ts +0 -37
- package/lib/qq-bind-api.d.ts.map +0 -1
- package/lib/qq-bind-api.js +0 -90
- package/lib/qq-bind-api.js.map +0 -1
- package/lib/qq-bind-flow.d.ts +0 -20
- package/lib/qq-bind-flow.d.ts.map +0 -1
- package/lib/qq-bind-flow.js +0 -86
- package/lib/qq-bind-flow.js.map +0 -1
- package/lib/qq-bind-persist.d.ts +0 -11
- package/lib/qq-bind-persist.d.ts.map +0 -1
- package/lib/qq-bind-persist.js +0 -52
- package/lib/qq-bind-persist.js.map +0 -1
- package/lib/qq-endpoint-manager.d.ts +0 -16
- package/lib/qq-endpoint-manager.d.ts.map +0 -1
- package/lib/qq-endpoint-manager.js +0 -159
- package/lib/qq-endpoint-manager.js.map +0 -1
- package/lib/sdk-version.d.ts +0 -8
- package/lib/sdk-version.d.ts.map +0 -1
- package/lib/sdk-version.js +0 -19
- package/lib/sdk-version.js.map +0 -1
- package/lib/segment-mapper.d.ts +0 -2
- package/lib/segment-mapper.d.ts.map +0 -1
- package/lib/segment-mapper.js +0 -2
- package/lib/segment-mapper.js.map +0 -1
- package/lib/types.d.ts +0 -45
- package/lib/types.d.ts.map +0 -1
- package/lib/types.js +0 -2
- package/lib/types.js.map +0 -1
- package/plugin.yml +0 -3
- package/src/adapter.ts +0 -101
- package/src/gateway-config.ts +0 -48
- package/src/group-at-normalize.ts +0 -76
- package/src/inbound-action.ts +0 -87
- package/src/inbound-normalize.ts +0 -57
- package/src/mention-enrich.ts +0 -71
- package/src/outbound-keyboard.ts +0 -118
- package/src/outbound-markdown.ts +0 -203
- package/src/outbound-media.ts +0 -58
- package/src/outbound-mixed-media.ts +0 -101
- package/src/qq-bind-api.ts +0 -145
- package/src/qq-bind-flow.ts +0 -127
- package/src/qq-bind-persist.ts +0 -71
- package/src/qq-endpoint-manager.ts +0 -199
- package/src/sdk-version.ts +0 -21
- package/src/segment-mapper.ts +0 -1
- package/src/types.ts +0 -53
- /package/{skills/qq → agent}/PERMITS.md +0 -0
- /package/{skills/qq/SKILL.md → agent/skills/qq.md} +0 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { defineAgentTool } from '@zhin.js/agent/tools';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { platformPermit } from '../../src/platform-permit.js';
|
|
4
|
+
import { getQqAgentDeps } from '../../src/qq-agent-deps.js';
|
|
5
|
+
|
|
6
|
+
export default defineAgentTool<{ endpoint_id: string; guild_id: string }>({
|
|
7
|
+
description: '获取 QQ 频道下的子频道列表',
|
|
8
|
+
inputSchema: z.object({
|
|
9
|
+
endpoint_id: z.string().describe('Endpoint 名称'),
|
|
10
|
+
guild_id: z.string().describe('频道 ID'),
|
|
11
|
+
}),
|
|
12
|
+
platforms: ['qq'],
|
|
13
|
+
tags: ['qq'],
|
|
14
|
+
permissions: [platformPermit('manage_channels')],
|
|
15
|
+
async execute({ endpoint_id, guild_id }: { endpoint_id: string; guild_id: string }) {
|
|
16
|
+
const endpoint = getQqAgentDeps().getEndpoint(endpoint_id);
|
|
17
|
+
const channels = await endpoint.getChannels(guild_id);
|
|
18
|
+
return { channels, count: channels.length };
|
|
19
|
+
},
|
|
20
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { defineAgentTool } from '@zhin.js/agent/tools';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { getQqAgentDeps } from '../../src/qq-agent-deps.js';
|
|
4
|
+
|
|
5
|
+
export default defineAgentTool<{ endpoint_id: string }>({
|
|
6
|
+
description: '获取 QQ 频道列表',
|
|
7
|
+
inputSchema: z.object({
|
|
8
|
+
endpoint_id: z.string().describe('Endpoint 名称'),
|
|
9
|
+
}),
|
|
10
|
+
platforms: ['qq'],
|
|
11
|
+
tags: ['qq'],
|
|
12
|
+
async execute({ endpoint_id }: { endpoint_id: string }) {
|
|
13
|
+
const endpoint = getQqAgentDeps().getEndpoint(endpoint_id);
|
|
14
|
+
const guilds = await endpoint.getGuilds();
|
|
15
|
+
return { guilds, count: guilds.length };
|
|
16
|
+
},
|
|
17
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { defineAgentTool } from '@zhin.js/agent/tools';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { platformPermit } from '../../src/platform-permit.js';
|
|
4
|
+
import { getQqAgentDeps } from '../../src/qq-agent-deps.js';
|
|
5
|
+
|
|
6
|
+
export default defineAgentTool<{ endpoint_id: string; guild_id: string }>({
|
|
7
|
+
description: '获取 QQ 频道角色列表',
|
|
8
|
+
inputSchema: z.object({
|
|
9
|
+
endpoint_id: z.string().describe('Endpoint 名称'),
|
|
10
|
+
guild_id: z.string().describe('频道 ID'),
|
|
11
|
+
}),
|
|
12
|
+
platforms: ['qq'],
|
|
13
|
+
tags: ['qq'],
|
|
14
|
+
permissions: [platformPermit('manage_roles')],
|
|
15
|
+
async execute({ endpoint_id, guild_id }: { endpoint_id: string; guild_id: string }) {
|
|
16
|
+
const endpoint = getQqAgentDeps().getEndpoint(endpoint_id);
|
|
17
|
+
const roles = await endpoint.getGuildRoles(guild_id);
|
|
18
|
+
return { roles, count: roles.length };
|
|
19
|
+
},
|
|
20
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { defineAgentTool } from '@zhin.js/agent/tools';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { platformPermit } from '../../src/platform-permit.js';
|
|
4
|
+
import { getQqAgentDeps } from '../../src/qq-agent-deps.js';
|
|
5
|
+
|
|
6
|
+
export default defineAgentTool<{ endpoint_id: string; guild_id: string; user_id: string }>({
|
|
7
|
+
description: '获取 QQ 频道中指定成员的详细信息',
|
|
8
|
+
inputSchema: z.object({
|
|
9
|
+
endpoint_id: z.string().describe('Endpoint 名称'),
|
|
10
|
+
guild_id: z.string().describe('频道 ID'),
|
|
11
|
+
user_id: z.string().describe('用户 ID'),
|
|
12
|
+
}),
|
|
13
|
+
platforms: ['qq'],
|
|
14
|
+
tags: ['qq'],
|
|
15
|
+
permissions: [platformPermit('guild_admin')],
|
|
16
|
+
async execute({ endpoint_id, guild_id, user_id }: { endpoint_id: string; guild_id: string; user_id: string }) {
|
|
17
|
+
const endpoint = getQqAgentDeps().getEndpoint(endpoint_id);
|
|
18
|
+
return endpoint.getGuildMember(guild_id, user_id);
|
|
19
|
+
},
|
|
20
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { defineAgentTool } from '@zhin.js/agent/tools';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { platformPermit } from '../../src/platform-permit.js';
|
|
4
|
+
import { getQqAgentDeps } from '../../src/qq-agent-deps.js';
|
|
5
|
+
|
|
6
|
+
export default defineAgentTool<{ endpoint_id: string; guild_id: string; channel_id: string; user_id: string; role_id: string }>({
|
|
7
|
+
description: '移除成员的 QQ 频道角色',
|
|
8
|
+
inputSchema: z.object({
|
|
9
|
+
endpoint_id: z.string().describe('Endpoint 名称'),
|
|
10
|
+
guild_id: z.string().describe('频道 ID'),
|
|
11
|
+
channel_id: z.string().describe('子频道 ID'),
|
|
12
|
+
user_id: z.string().describe('用户 ID'),
|
|
13
|
+
role_id: z.string().describe('角色 ID'),
|
|
14
|
+
}),
|
|
15
|
+
platforms: ['qq'],
|
|
16
|
+
tags: ['qq'],
|
|
17
|
+
permissions: [platformPermit('manage_roles')],
|
|
18
|
+
async execute({ endpoint_id, guild_id, channel_id, user_id, role_id }: { endpoint_id: string; guild_id: string; channel_id: string; user_id: string; role_id: string }) {
|
|
19
|
+
const endpoint = getQqAgentDeps().getEndpoint(endpoint_id);
|
|
20
|
+
const success = await endpoint.removeMemberRole(guild_id, channel_id, user_id, role_id);
|
|
21
|
+
return { success, message: success ? '已移除成员的角色' : '操作失败' };
|
|
22
|
+
},
|
|
23
|
+
});
|
package/lib/endpoint.d.ts
CHANGED
|
@@ -1,125 +1,69 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* QQ
|
|
2
|
+
* QQ endpoints — lifecycle, outbound, admit, agent tool surface.
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
import type {
|
|
8
|
-
import { type
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
export
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
getGuildMembers(guildId: string): Promise<any[]>;
|
|
68
|
-
/**
|
|
69
|
-
* 获取频道成员详情
|
|
70
|
-
* @param guildId 频道 ID
|
|
71
|
-
* @param userId 用户 ID
|
|
72
|
-
*/
|
|
73
|
-
getGuildMember(guildId: string, userId: string): Promise<any>;
|
|
74
|
-
/**
|
|
75
|
-
* 删除频道成员(踢出)
|
|
76
|
-
* @param guildId 频道 ID
|
|
77
|
-
* @param userId 用户 ID
|
|
78
|
-
* @param addBlacklist 是否加入黑名单
|
|
79
|
-
* @param deleteHistoryMsg 删除历史消息天数 (-1不删除,0全部删除,3/7/15/30)
|
|
80
|
-
*/
|
|
81
|
-
removeGuildMember(guildId: string, userId: string, addBlacklist?: boolean, deleteHistoryMsg?: -1 | 0 | 3 | 7 | 15 | 30): Promise<boolean>;
|
|
82
|
-
/**
|
|
83
|
-
* 获取频道角色列表
|
|
84
|
-
* @param guildId 频道 ID
|
|
85
|
-
*/
|
|
86
|
-
getGuildRoles(guildId: string): Promise<any[]>;
|
|
87
|
-
/**
|
|
88
|
-
* 创建频道角色
|
|
89
|
-
* @param guildId 频道 ID
|
|
90
|
-
* @param name 角色名
|
|
91
|
-
* @param color 颜色
|
|
92
|
-
* @param hoist 是否在成员列表中单独展示 (0 或 1)
|
|
93
|
-
*/
|
|
94
|
-
createGuildRole(guildId: string, name: string, color?: number, hoist?: 0 | 1): Promise<any>;
|
|
95
|
-
/**
|
|
96
|
-
* 给成员添加角色
|
|
97
|
-
* @param guildId 频道 ID
|
|
98
|
-
* @param channelId 子频道 ID
|
|
99
|
-
* @param userId 用户 ID
|
|
100
|
-
* @param roleId 角色 ID
|
|
101
|
-
*/
|
|
4
|
+
import type { EndpointInstance } from '@zhin.js/adapter';
|
|
5
|
+
import type { MessageGateway } from '@zhin.js/core/runtime';
|
|
6
|
+
import type { HttpHost } from '@zhin.js/host-http';
|
|
7
|
+
import type { CapabilityId } from '@zhin.js/plugin-runtime';
|
|
8
|
+
import { type QqInboundMessage, type ResolvedQqHttpConfig, type ResolvedQqWebsocketConfig } from './protocol.js';
|
|
9
|
+
import { type CreateQqHttpBot } from './webhook.js';
|
|
10
|
+
import { type CreateQqBot } from './ws.js';
|
|
11
|
+
export type { CreateQqBot, QqBotTransport } from './ws.js';
|
|
12
|
+
export type { CreateQqHttpBot, QqHttpBotTransport } from './webhook.js';
|
|
13
|
+
export interface QqEndpointOptions {
|
|
14
|
+
readonly id: CapabilityId;
|
|
15
|
+
readonly gateway: MessageGateway;
|
|
16
|
+
readonly config: ResolvedQqWebsocketConfig;
|
|
17
|
+
readonly createBot?: CreateQqBot;
|
|
18
|
+
}
|
|
19
|
+
export declare class QqWebsocketEndpoint implements EndpointInstance {
|
|
20
|
+
#private;
|
|
21
|
+
constructor(options: QqEndpointOptions);
|
|
22
|
+
start(): Promise<void>;
|
|
23
|
+
open(): void;
|
|
24
|
+
close(): void;
|
|
25
|
+
stop(): Promise<void>;
|
|
26
|
+
send({ target, payload }: {
|
|
27
|
+
readonly target: string;
|
|
28
|
+
readonly payload: unknown;
|
|
29
|
+
}): Promise<string>;
|
|
30
|
+
/** Test / internal: admit a message when open. */
|
|
31
|
+
admit(msg: QqInboundMessage): void;
|
|
32
|
+
getGuilds(): Promise<unknown[]>;
|
|
33
|
+
getChannels(guildId: string): Promise<unknown[]>;
|
|
34
|
+
getChannelInfo(channelId: string): Promise<unknown>;
|
|
35
|
+
getGuildMember(guildId: string, userId: string): Promise<unknown>;
|
|
36
|
+
getGuildRoles(guildId: string): Promise<unknown[]>;
|
|
37
|
+
createGuildRole(guildId: string, name: string, color?: number): Promise<unknown>;
|
|
38
|
+
addMemberRole(guildId: string, channelId: string, userId: string, roleId: string): Promise<boolean>;
|
|
39
|
+
removeMemberRole(guildId: string, channelId: string, userId: string, roleId: string): Promise<boolean>;
|
|
40
|
+
}
|
|
41
|
+
export interface QqHttpEndpointOptions {
|
|
42
|
+
readonly id: CapabilityId;
|
|
43
|
+
readonly gateway: MessageGateway;
|
|
44
|
+
readonly http: HttpHost;
|
|
45
|
+
readonly config: ResolvedQqHttpConfig;
|
|
46
|
+
readonly createBot?: CreateQqHttpBot;
|
|
47
|
+
}
|
|
48
|
+
/** Webhook / middleware inbound via httpHostToken POST (qq-official-bot Middleware receiver). */
|
|
49
|
+
export declare class QqHttpEndpoint implements EndpointInstance {
|
|
50
|
+
#private;
|
|
51
|
+
constructor(options: QqHttpEndpointOptions);
|
|
52
|
+
start(): Promise<void>;
|
|
53
|
+
open(): void;
|
|
54
|
+
close(): void;
|
|
55
|
+
stop(): Promise<void>;
|
|
56
|
+
send({ target, payload }: {
|
|
57
|
+
readonly target: string;
|
|
58
|
+
readonly payload: unknown;
|
|
59
|
+
}): Promise<string>;
|
|
60
|
+
admit(msg: QqInboundMessage): void;
|
|
61
|
+
getGuilds(): Promise<unknown[]>;
|
|
62
|
+
getChannels(guildId: string): Promise<unknown[]>;
|
|
63
|
+
getChannelInfo(channelId: string): Promise<unknown>;
|
|
64
|
+
getGuildMember(guildId: string, userId: string): Promise<unknown>;
|
|
65
|
+
getGuildRoles(guildId: string): Promise<unknown[]>;
|
|
66
|
+
createGuildRole(guildId: string, name: string, color?: number): Promise<unknown>;
|
|
102
67
|
addMemberRole(guildId: string, channelId: string, userId: string, roleId: string): Promise<boolean>;
|
|
103
|
-
/**
|
|
104
|
-
* 移除成员角色
|
|
105
|
-
* @param guildId 频道 ID
|
|
106
|
-
* @param channelId 子频道 ID
|
|
107
|
-
* @param userId 用户 ID
|
|
108
|
-
* @param roleId 角色 ID
|
|
109
|
-
*/
|
|
110
68
|
removeMemberRole(guildId: string, channelId: string, userId: string, roleId: string): Promise<boolean>;
|
|
111
|
-
/**
|
|
112
|
-
* 禁言成员(批量)
|
|
113
|
-
* @param guildId 频道 ID
|
|
114
|
-
* @param userIds 用户 ID 列表
|
|
115
|
-
* @param muteSeconds 禁言时长(秒),0 表示解除禁言
|
|
116
|
-
*/
|
|
117
|
-
muteMembers(guildId: string, userIds: string[], muteSeconds: number): Promise<boolean>;
|
|
118
|
-
/**
|
|
119
|
-
* 全员禁言
|
|
120
|
-
* @param guildId 频道 ID
|
|
121
|
-
* @param muteSeconds 禁言时长(秒),0 表示解除禁言
|
|
122
|
-
*/
|
|
123
|
-
muteAll(guildId: string, muteSeconds: number): Promise<boolean>;
|
|
124
69
|
}
|
|
125
|
-
//# sourceMappingURL=endpoint.d.ts.map
|