@zhin.js/adapter-kook 1.0.84 → 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 +898 -17
- package/PERMITS.md +23 -0
- package/README.md +73 -374
- package/adapters/kook/index.js +41 -0
- package/adapters/kook/index.ts +56 -0
- package/agents/kook/agent.json +20 -0
- package/agents/kook/boundaries.md +3 -0
- package/agents/kook/conventions.md +3 -0
- package/agents/kook/skills/kook/SKILL.md +20 -0
- package/agents/kook/skills/kook/tools/blacklist/index.js +31 -0
- package/agents/kook/skills/kook/tools/blacklist/index.ts +31 -0
- package/agents/kook/skills/kook/tools/create_role/index.js +23 -0
- package/agents/kook/skills/kook/tools/create_role/index.ts +23 -0
- package/agents/kook/skills/kook/tools/delete_role/index.js +19 -0
- package/agents/kook/skills/kook/tools/delete_role/index.ts +19 -0
- package/agents/kook/skills/kook/tools/grant_role/index.js +20 -0
- package/agents/kook/skills/kook/tools/grant_role/index.ts +20 -0
- package/agents/kook/skills/kook/tools/list_roles/index.js +25 -0
- package/agents/kook/skills/kook/tools/list_roles/index.ts +25 -0
- package/agents/kook/skills/kook/tools/revoke_role/index.js +20 -0
- package/agents/kook/skills/kook/tools/revoke_role/index.ts +20 -0
- package/agents/kook/system.md +3 -0
- package/commands/kook/endpoint/add/[id]/index.js +3 -0
- package/commands/kook/endpoint/add/[id]/index.ts +3 -0
- package/commands/kook/endpoint/definition.js +19 -0
- package/commands/kook/endpoint/definition.ts +19 -0
- package/commands/kook/endpoint/list/index.js +3 -0
- package/commands/kook/endpoint/list/index.ts +3 -0
- package/commands/kook/endpoint/remove/[id]/index.js +3 -0
- package/commands/kook/endpoint/remove/[id]/index.ts +3 -0
- package/lib/client.d.ts +11 -0
- package/lib/client.js +2 -0
- package/lib/endpoint.d.ts +59 -0
- package/lib/endpoint.js +374 -0
- package/lib/index.d.ts +6 -18
- package/lib/index.js +6 -342
- package/lib/kook-runtime-state.d.ts +1 -0
- package/lib/kook-runtime-state.js +6 -0
- package/lib/platform-permit.d.ts +22 -0
- package/lib/platform-permit.js +48 -0
- package/lib/protocol.d.ts +126 -0
- package/lib/protocol.js +300 -0
- package/lib/side-event-dispatch.d.ts +3 -0
- package/lib/side-event-dispatch.js +49 -0
- package/lib/webhook.d.ts +16 -0
- package/lib/webhook.js +71 -0
- package/lib/ws.d.ts +56 -0
- package/lib/ws.js +63 -0
- package/package.json +73 -29
- package/plugin.js +19 -0
- package/schema.json +171 -0
- package/src/client.ts +15 -0
- package/src/endpoint.ts +433 -0
- package/src/index.ts +45 -322
- package/src/kook-runtime-state.ts +7 -0
- package/src/platform-permit.ts +75 -0
- package/src/protocol.ts +433 -0
- package/src/side-event-dispatch.ts +54 -0
- package/src/webhook.ts +114 -0
- package/src/ws.ts +131 -0
- package/client/Dashboard.tsx +0 -255
- package/client/index.tsx +0 -11
- package/client/tsconfig.json +0 -7
- package/client/utils/api.ts +0 -17
- package/dist/index.js +0 -31
- package/lib/adapter.d.ts +0 -26
- package/lib/adapter.d.ts.map +0 -1
- package/lib/adapter.js +0 -61
- package/lib/adapter.js.map +0 -1
- package/lib/bot.d.ts +0 -122
- package/lib/bot.d.ts.map +0 -1
- package/lib/bot.js +0 -608
- package/lib/bot.js.map +0 -1
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/types.d.ts +0 -32
- package/lib/types.d.ts.map +0 -1
- package/lib/types.js +0 -8
- package/lib/types.js.map +0 -1
- package/plugin.yml +0 -3
- package/skills/kook/SKILL.md +0 -80
- package/src/adapter.ts +0 -71
- package/src/bot.ts +0 -693
- package/src/types.ts +0 -36
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { defineAgentTool } from '@zhin.js/tool';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { platformPermission } from '@zhin.js/permission';
|
|
4
|
+
|
|
5
|
+
export default defineAgentTool<{ guild_id: string; action: 'add' | 'remove'; user_id: string; remark?: string }>({
|
|
6
|
+
description: 'KOOK 服务器黑名单管理:添加/移除',
|
|
7
|
+
inputSchema: z.object({
|
|
8
|
+
guild_id: z.string().describe('服务器 ID'),
|
|
9
|
+
action: z.enum(['add', 'remove']).describe('add|remove'),
|
|
10
|
+
user_id: z.string().describe('用户 ID'),
|
|
11
|
+
remark: z.string().optional().describe('备注(add 可选)'),
|
|
12
|
+
}),
|
|
13
|
+
adapter: 'kook',
|
|
14
|
+
tags: ['kook'],
|
|
15
|
+
permissions: [platformPermission('kook', 'guild_admin')],
|
|
16
|
+
async execute({ guild_id, action, user_id, remark }: { guild_id: string; action: 'add' | 'remove'; user_id: string; remark?: string }, context) {
|
|
17
|
+
const member = context.$client.pickGuildMember(guild_id, user_id);
|
|
18
|
+
switch (action) {
|
|
19
|
+
case 'add': {
|
|
20
|
+
const success = await member.addToBlackList(remark);
|
|
21
|
+
return { success, message: success ? `已将 ${user_id} 加入黑名单` : '操作失败' };
|
|
22
|
+
}
|
|
23
|
+
case 'remove': {
|
|
24
|
+
const success = await member.removeFromBlackList();
|
|
25
|
+
return { success, message: success ? `已将 ${user_id} 从黑名单移除` : '操作失败' };
|
|
26
|
+
}
|
|
27
|
+
default:
|
|
28
|
+
return { success: false, message: `未知操作: ${action}` };
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// Generated by build-plugin-runtime-entries.mjs. Do not edit.
|
|
2
|
+
import { defineAgentTool } from '@zhin.js/tool';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
import { platformPermission } from '@zhin.js/permission';
|
|
5
|
+
export default defineAgentTool({
|
|
6
|
+
description: '在 KOOK 服务器中创建新角色',
|
|
7
|
+
inputSchema: z.object({
|
|
8
|
+
guild_id: z.string().describe('服务器 ID'),
|
|
9
|
+
name: z.string().describe('角色名称'),
|
|
10
|
+
}),
|
|
11
|
+
adapter: 'kook',
|
|
12
|
+
tags: ['kook'],
|
|
13
|
+
permissions: [platformPermission('kook', 'guild_owner')],
|
|
14
|
+
async execute({ guild_id, name }, context) {
|
|
15
|
+
const client = context.$client;
|
|
16
|
+
const role = await client.pickGuild(guild_id).createRole(name);
|
|
17
|
+
return {
|
|
18
|
+
success: true,
|
|
19
|
+
message: `已创建角色 "${name}"`,
|
|
20
|
+
role: { id: role.role_id, name: role.name },
|
|
21
|
+
};
|
|
22
|
+
},
|
|
23
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { defineAgentTool } from '@zhin.js/tool';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { platformPermission } from '@zhin.js/permission';
|
|
4
|
+
|
|
5
|
+
export default defineAgentTool<{ guild_id: string; name: string }>({
|
|
6
|
+
description: '在 KOOK 服务器中创建新角色',
|
|
7
|
+
inputSchema: z.object({
|
|
8
|
+
guild_id: z.string().describe('服务器 ID'),
|
|
9
|
+
name: z.string().describe('角色名称'),
|
|
10
|
+
}),
|
|
11
|
+
adapter: 'kook',
|
|
12
|
+
tags: ['kook'],
|
|
13
|
+
permissions: [platformPermission('kook', 'guild_owner')],
|
|
14
|
+
async execute({ guild_id, name }: { guild_id: string; name: string }, context) {
|
|
15
|
+
const client = context.$client;
|
|
16
|
+
const role = await client.pickGuild(guild_id).createRole(name);
|
|
17
|
+
return {
|
|
18
|
+
success: true,
|
|
19
|
+
message: `已创建角色 "${name}"`,
|
|
20
|
+
role: { id: role.role_id, name: role.name },
|
|
21
|
+
};
|
|
22
|
+
},
|
|
23
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// Generated by build-plugin-runtime-entries.mjs. Do not edit.
|
|
2
|
+
import { defineAgentTool } from '@zhin.js/tool';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
import { platformPermission } from '@zhin.js/permission';
|
|
5
|
+
export default defineAgentTool({
|
|
6
|
+
description: '删除 KOOK 服务器中的角色',
|
|
7
|
+
inputSchema: z.object({
|
|
8
|
+
guild_id: z.string().describe('服务器 ID'),
|
|
9
|
+
role_id: z.string().describe('角色 ID'),
|
|
10
|
+
}),
|
|
11
|
+
adapter: 'kook',
|
|
12
|
+
tags: ['kook'],
|
|
13
|
+
permissions: [platformPermission('kook', 'guild_owner')],
|
|
14
|
+
async execute({ guild_id, role_id }, context) {
|
|
15
|
+
const client = context.$client;
|
|
16
|
+
const success = await client.pickGuild(guild_id).deleteRole(role_id);
|
|
17
|
+
return { success, message: success ? `已删除角色 ${role_id}` : '删除角色失败' };
|
|
18
|
+
},
|
|
19
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { defineAgentTool } from '@zhin.js/tool';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { platformPermission } from '@zhin.js/permission';
|
|
4
|
+
|
|
5
|
+
export default defineAgentTool<{ guild_id: string; role_id: string }>({
|
|
6
|
+
description: '删除 KOOK 服务器中的角色',
|
|
7
|
+
inputSchema: z.object({
|
|
8
|
+
guild_id: z.string().describe('服务器 ID'),
|
|
9
|
+
role_id: z.string().describe('角色 ID'),
|
|
10
|
+
}),
|
|
11
|
+
adapter: 'kook',
|
|
12
|
+
tags: ['kook'],
|
|
13
|
+
permissions: [platformPermission('kook', 'guild_owner')],
|
|
14
|
+
async execute({ guild_id, role_id }: { guild_id: string; role_id: string }, context) {
|
|
15
|
+
const client = context.$client;
|
|
16
|
+
const success = await client.pickGuild(guild_id).deleteRole(role_id);
|
|
17
|
+
return { success, message: success ? `已删除角色 ${role_id}` : '删除角色失败' };
|
|
18
|
+
},
|
|
19
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// Generated by build-plugin-runtime-entries.mjs. Do not edit.
|
|
2
|
+
import { defineAgentTool } from '@zhin.js/tool';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
import { platformPermission } from '@zhin.js/permission';
|
|
5
|
+
export default defineAgentTool({
|
|
6
|
+
description: '给用户授予 KOOK 服务器角色',
|
|
7
|
+
inputSchema: z.object({
|
|
8
|
+
guild_id: z.string().describe('服务器 ID'),
|
|
9
|
+
user_id: z.string().describe('用户 ID'),
|
|
10
|
+
role_id: z.string().describe('角色 ID'),
|
|
11
|
+
}),
|
|
12
|
+
adapter: 'kook',
|
|
13
|
+
tags: ['kook'],
|
|
14
|
+
permissions: [platformPermission('kook', 'manage_roles')],
|
|
15
|
+
async execute({ guild_id, user_id, role_id }, context) {
|
|
16
|
+
const client = context.$client;
|
|
17
|
+
const success = await client.pickGuildMember(guild_id, user_id).grant(role_id);
|
|
18
|
+
return { success, message: success ? `已授予用户 ${user_id} 角色 ${role_id}` : '授予角色失败' };
|
|
19
|
+
},
|
|
20
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { defineAgentTool } from '@zhin.js/tool';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { platformPermission } from '@zhin.js/permission';
|
|
4
|
+
|
|
5
|
+
export default defineAgentTool<{ guild_id: string; user_id: string; role_id: string }>({
|
|
6
|
+
description: '给用户授予 KOOK 服务器角色',
|
|
7
|
+
inputSchema: z.object({
|
|
8
|
+
guild_id: z.string().describe('服务器 ID'),
|
|
9
|
+
user_id: z.string().describe('用户 ID'),
|
|
10
|
+
role_id: z.string().describe('角色 ID'),
|
|
11
|
+
}),
|
|
12
|
+
adapter: 'kook',
|
|
13
|
+
tags: ['kook'],
|
|
14
|
+
permissions: [platformPermission('kook', 'manage_roles')],
|
|
15
|
+
async execute({ guild_id, user_id, role_id }: { guild_id: string; user_id: string; role_id: string }, context) {
|
|
16
|
+
const client = context.$client;
|
|
17
|
+
const success = await client.pickGuildMember(guild_id, user_id).grant(role_id);
|
|
18
|
+
return { success, message: success ? `已授予用户 ${user_id} 角色 ${role_id}` : '授予角色失败' };
|
|
19
|
+
},
|
|
20
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
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: '获取 KOOK 服务器的角色列表',
|
|
6
|
+
inputSchema: z.object({
|
|
7
|
+
guild_id: z.string().describe('服务器 ID'),
|
|
8
|
+
}),
|
|
9
|
+
adapter: 'kook',
|
|
10
|
+
tags: ['kook'],
|
|
11
|
+
async execute({ guild_id }, context) {
|
|
12
|
+
const client = context.$client;
|
|
13
|
+
const roles = await client.pickGuild(guild_id).getRoleList();
|
|
14
|
+
return {
|
|
15
|
+
roles: roles.map((r) => ({
|
|
16
|
+
id: String(r.role_id),
|
|
17
|
+
name: r.name,
|
|
18
|
+
color: r.color,
|
|
19
|
+
position: r.position,
|
|
20
|
+
permissions: r.permissions,
|
|
21
|
+
})),
|
|
22
|
+
count: roles.length,
|
|
23
|
+
};
|
|
24
|
+
},
|
|
25
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { defineAgentTool } from '@zhin.js/tool';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
|
|
4
|
+
export default defineAgentTool<{ guild_id: string }>({
|
|
5
|
+
description: '获取 KOOK 服务器的角色列表',
|
|
6
|
+
inputSchema: z.object({
|
|
7
|
+
guild_id: z.string().describe('服务器 ID'),
|
|
8
|
+
}),
|
|
9
|
+
adapter: 'kook',
|
|
10
|
+
tags: ['kook'],
|
|
11
|
+
async execute({ guild_id }: { guild_id: string }, context) {
|
|
12
|
+
const client = context.$client;
|
|
13
|
+
const roles = await client.pickGuild(guild_id).getRoleList();
|
|
14
|
+
return {
|
|
15
|
+
roles: roles.map((r) => ({
|
|
16
|
+
id: String(r.role_id),
|
|
17
|
+
name: r.name,
|
|
18
|
+
color: r.color,
|
|
19
|
+
position: r.position,
|
|
20
|
+
permissions: r.permissions,
|
|
21
|
+
})),
|
|
22
|
+
count: roles.length,
|
|
23
|
+
};
|
|
24
|
+
},
|
|
25
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// Generated by build-plugin-runtime-entries.mjs. Do not edit.
|
|
2
|
+
import { defineAgentTool } from '@zhin.js/tool';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
import { platformPermission } from '@zhin.js/permission';
|
|
5
|
+
export default defineAgentTool({
|
|
6
|
+
description: '撤销用户的 KOOK 服务器角色',
|
|
7
|
+
inputSchema: z.object({
|
|
8
|
+
guild_id: z.string().describe('服务器 ID'),
|
|
9
|
+
user_id: z.string().describe('用户 ID'),
|
|
10
|
+
role_id: z.string().describe('角色 ID'),
|
|
11
|
+
}),
|
|
12
|
+
adapter: 'kook',
|
|
13
|
+
tags: ['kook'],
|
|
14
|
+
permissions: [platformPermission('kook', 'manage_roles')],
|
|
15
|
+
async execute({ guild_id, user_id, role_id }, context) {
|
|
16
|
+
const client = context.$client;
|
|
17
|
+
const success = await client.pickGuildMember(guild_id, user_id).revoke(role_id);
|
|
18
|
+
return { success, message: success ? `已撤销用户 ${user_id} 的角色 ${role_id}` : '撤销角色失败' };
|
|
19
|
+
},
|
|
20
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { defineAgentTool } from '@zhin.js/tool';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { platformPermission } from '@zhin.js/permission';
|
|
4
|
+
|
|
5
|
+
export default defineAgentTool<{ guild_id: string; user_id: string; role_id: string }>({
|
|
6
|
+
description: '撤销用户的 KOOK 服务器角色',
|
|
7
|
+
inputSchema: z.object({
|
|
8
|
+
guild_id: z.string().describe('服务器 ID'),
|
|
9
|
+
user_id: z.string().describe('用户 ID'),
|
|
10
|
+
role_id: z.string().describe('角色 ID'),
|
|
11
|
+
}),
|
|
12
|
+
adapter: 'kook',
|
|
13
|
+
tags: ['kook'],
|
|
14
|
+
permissions: [platformPermission('kook', 'manage_roles')],
|
|
15
|
+
async execute({ guild_id, user_id, role_id }: { guild_id: string; user_id: string; role_id: string }, context) {
|
|
16
|
+
const client = context.$client;
|
|
17
|
+
const success = await client.pickGuildMember(guild_id, user_id).revoke(role_id);
|
|
18
|
+
return { success, message: success ? `已撤销用户 ${user_id} 的角色 ${role_id}` : '撤销角色失败' };
|
|
19
|
+
},
|
|
20
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// Generated by build-plugin-runtime-entries.mjs. Do not edit.
|
|
2
|
+
/**
|
|
3
|
+
* `kook endpoint` 命令族:由 @zhin.js/adapter 的 createEndpointCommands 套件生成。
|
|
4
|
+
* commands/kook/endpoint/ 下的 list / add / remove 直接默认导出这三项。
|
|
5
|
+
*/
|
|
6
|
+
import { createEndpointCommands } from 'zhin.js/adapter';
|
|
7
|
+
import { defineCommand } from 'zhin.js/command';
|
|
8
|
+
import { kookRuntimeStateToken } from "../../../lib/kook-runtime-state.js";
|
|
9
|
+
export const kookEndpointCommands = createEndpointCommands({
|
|
10
|
+
adapterKey: 'kook',
|
|
11
|
+
adapterDisplayName: 'KOOK',
|
|
12
|
+
fields: [
|
|
13
|
+
{ key: 'token', required: true, env: true, description: 'KOOK bot token' },
|
|
14
|
+
{ key: 'encrypt_key', env: true, description: 'webhook 加密密钥(connection: webhook)' },
|
|
15
|
+
{ key: 'verify_token', env: true, description: 'webhook 验证 token(connection: webhook)' },
|
|
16
|
+
],
|
|
17
|
+
running: (use) => use(kookRuntimeStateToken).endpoints.values(),
|
|
18
|
+
describeEntry: (entry) => `token: ${String(entry.token)}`,
|
|
19
|
+
}, defineCommand);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `kook endpoint` 命令族:由 @zhin.js/adapter 的 createEndpointCommands 套件生成。
|
|
3
|
+
* commands/kook/endpoint/ 下的 list / add / remove 直接默认导出这三项。
|
|
4
|
+
*/
|
|
5
|
+
import { createEndpointCommands } from 'zhin.js/adapter';
|
|
6
|
+
import { defineCommand } from 'zhin.js/command';
|
|
7
|
+
import { kookRuntimeStateToken } from '../../../src/kook-runtime-state.js';
|
|
8
|
+
|
|
9
|
+
export const kookEndpointCommands = createEndpointCommands({
|
|
10
|
+
adapterKey: 'kook',
|
|
11
|
+
adapterDisplayName: 'KOOK',
|
|
12
|
+
fields: [
|
|
13
|
+
{ key: 'token', required: true, env: true, description: 'KOOK bot token' },
|
|
14
|
+
{ key: 'encrypt_key', env: true, description: 'webhook 加密密钥(connection: webhook)' },
|
|
15
|
+
{ key: 'verify_token', env: true, description: 'webhook 验证 token(connection: webhook)' },
|
|
16
|
+
],
|
|
17
|
+
running: (use) => use(kookRuntimeStateToken).endpoints.values(),
|
|
18
|
+
describeEntry: (entry) => `token: ${String(entry.token)}`,
|
|
19
|
+
}, defineCommand);
|
package/lib/client.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { KookClientTransport } from './ws.js';
|
|
2
|
+
export type KookClientEventMap = Record<string, unknown>;
|
|
3
|
+
declare module '@zhin.js/feature-kit' {
|
|
4
|
+
interface AdapterClientRegistry {
|
|
5
|
+
readonly kook: {
|
|
6
|
+
readonly client: KookClientTransport;
|
|
7
|
+
readonly events: KookClientEventMap;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
export declare const kookClient: import("@zhin.js/adapter").EndpointClientToken<KookClientTransport, KookClientEventMap>;
|
package/lib/client.js
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { Endpoint } from 'zhin.js/adapter';
|
|
2
|
+
import { type EndpointControl, type EndpointManagement, type EndpointSendRequest } from 'zhin.js/adapter';
|
|
3
|
+
import type { HttpHost } from '@zhin.js/host-http';
|
|
4
|
+
import type { CapabilityId } from 'zhin.js';
|
|
5
|
+
import { type KookInboundMessage, type KookWebhookEventData, type ResolvedKookWebhookConfig, type ResolvedKookWebsocketConfig } from './protocol.js';
|
|
6
|
+
import { type CreateKookClient, type KookClientTransport } from './ws.js';
|
|
7
|
+
export interface KookEndpointOptions {
|
|
8
|
+
readonly id: CapabilityId;
|
|
9
|
+
readonly config: ResolvedKookWebsocketConfig;
|
|
10
|
+
readonly createClient?: CreateKookClient;
|
|
11
|
+
}
|
|
12
|
+
export declare class KookWebsocketEndpoint extends Endpoint<KookClientTransport> {
|
|
13
|
+
#private;
|
|
14
|
+
readonly management: EndpointManagement;
|
|
15
|
+
readonly control: EndpointControl;
|
|
16
|
+
constructor(options: KookEndpointOptions);
|
|
17
|
+
get client(): KookClientTransport;
|
|
18
|
+
start(): Promise<void>;
|
|
19
|
+
open(): void;
|
|
20
|
+
close(): void;
|
|
21
|
+
stop(): Promise<void>;
|
|
22
|
+
send({ conversation, payload }: EndpointSendRequest): Promise<string>;
|
|
23
|
+
/** Test / internal: admit a normalized message when open. */
|
|
24
|
+
admit(msg: KookInboundMessage): void;
|
|
25
|
+
recallMessage(messageId: string): Promise<void>;
|
|
26
|
+
}
|
|
27
|
+
export interface KookWebhookEndpointOptions {
|
|
28
|
+
readonly id: CapabilityId;
|
|
29
|
+
readonly http: HttpHost;
|
|
30
|
+
readonly config: ResolvedKookWebhookConfig;
|
|
31
|
+
readonly createClient?: CreateKookClient;
|
|
32
|
+
}
|
|
33
|
+
export declare class KookWebhookEndpoint extends Endpoint<KookClientTransport> {
|
|
34
|
+
#private;
|
|
35
|
+
readonly management: EndpointManagement;
|
|
36
|
+
readonly control: EndpointControl;
|
|
37
|
+
constructor(options: KookWebhookEndpointOptions);
|
|
38
|
+
get client(): KookClientTransport;
|
|
39
|
+
/** Used by webhook handler. */
|
|
40
|
+
get isOpen(): boolean;
|
|
41
|
+
get config(): ResolvedKookWebhookConfig;
|
|
42
|
+
get selfId(): string | undefined;
|
|
43
|
+
start(): Promise<void>;
|
|
44
|
+
open(): void;
|
|
45
|
+
close(): void;
|
|
46
|
+
stop(): Promise<void>;
|
|
47
|
+
send({ conversation, payload }: EndpointSendRequest): Promise<string>;
|
|
48
|
+
admitEvent(event: KookWebhookEventData): void;
|
|
49
|
+
/** Test / internal: admit a message when open. */
|
|
50
|
+
admit(msg: KookInboundMessage): void;
|
|
51
|
+
recallMessage(messageId: string): Promise<void>;
|
|
52
|
+
checkAndRememberSn(sn: number): boolean;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* KOOK endpoint 的 EndpointManagement 语义端口(websocket / webhook 共用)。
|
|
56
|
+
* 数据走 kook-client 的 HTTP API 封装:/api/v3/guild/list、
|
|
57
|
+
* /api/v3/channel/list、/api/v3/guild/user-list(SDK 内部已做分页聚合)。
|
|
58
|
+
*/
|
|
59
|
+
export declare function createKookEndpointManagement(requireClient: () => KookClientTransport): EndpointManagement;
|