@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
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zhin.js/adapter-kook",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "Zhin.js adapter for
|
|
3
|
+
"version": "1.1.2",
|
|
4
|
+
"description": "Zhin.js KOOK adapter for Plugin Runtime (WebSocket gateway or Webhook)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./lib/index.js",
|
|
7
7
|
"types": "./lib/index.d.ts",
|
|
@@ -33,53 +33,97 @@
|
|
|
33
33
|
"directory": "plugins/adapters/kook"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"kook-client": "^1.0.4"
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
"@
|
|
40
|
-
"@
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"@zhin.js/
|
|
44
|
-
"@zhin.js/
|
|
45
|
-
"zhin.js": "1.
|
|
36
|
+
"kook-client": "^1.0.4",
|
|
37
|
+
"@zhin.js/adapter": "1.1.14",
|
|
38
|
+
"@zhin.js/agent-feature": "1.1.1",
|
|
39
|
+
"@zhin.js/core": "1.1.37",
|
|
40
|
+
"@zhin.js/feature-kit": "1.1.1",
|
|
41
|
+
"@zhin.js/host-http": "1.1.1",
|
|
42
|
+
"@zhin.js/im-contract": "1.1.1",
|
|
43
|
+
"@zhin.js/logger": "1.1.1",
|
|
44
|
+
"@zhin.js/permission": "1.1.1",
|
|
45
|
+
"@zhin.js/skill": "1.1.1",
|
|
46
|
+
"@zhin.js/tool": "1.1.1"
|
|
46
47
|
},
|
|
47
48
|
"peerDependencies": {
|
|
48
|
-
"
|
|
49
|
-
"@zhin.js/
|
|
50
|
-
"@zhin.js/
|
|
51
|
-
"@zhin.js/
|
|
52
|
-
"zhin.js": "1.
|
|
49
|
+
"zod": "^4.0.0",
|
|
50
|
+
"@zhin.js/adapter": "^1.1.14",
|
|
51
|
+
"@zhin.js/command": "^1.1.1",
|
|
52
|
+
"@zhin.js/core": "^1.1.37",
|
|
53
|
+
"zhin.js": "^1.1.2"
|
|
53
54
|
},
|
|
54
55
|
"peerDependenciesMeta": {
|
|
55
|
-
"@zhin.js/
|
|
56
|
+
"@zhin.js/command": {
|
|
56
57
|
"optional": true
|
|
57
58
|
},
|
|
58
|
-
"
|
|
59
|
+
"zhin.js": {
|
|
59
60
|
"optional": true
|
|
60
61
|
},
|
|
61
|
-
"
|
|
62
|
+
"zod": {
|
|
62
63
|
"optional": true
|
|
63
64
|
}
|
|
64
65
|
},
|
|
66
|
+
"devDependencies": {
|
|
67
|
+
"@types/node": "^26.1.2",
|
|
68
|
+
"typescript": "^6.0.3",
|
|
69
|
+
"vitest": "^4.1.10",
|
|
70
|
+
"zod": "^4.4.3",
|
|
71
|
+
"@zhin.js/host-http": "1.1.1",
|
|
72
|
+
"zhin.js": "1.1.2"
|
|
73
|
+
},
|
|
65
74
|
"files": [
|
|
75
|
+
"adapters",
|
|
76
|
+
"commands",
|
|
77
|
+
"plugin.js",
|
|
78
|
+
"schema.json",
|
|
66
79
|
"src",
|
|
67
80
|
"lib",
|
|
68
|
-
"
|
|
69
|
-
"
|
|
70
|
-
"skills",
|
|
71
|
-
"plugin.yml",
|
|
81
|
+
"tools",
|
|
82
|
+
"agents",
|
|
72
83
|
"README.md",
|
|
73
|
-
"
|
|
74
|
-
"
|
|
84
|
+
"CHANGELOG.md",
|
|
85
|
+
"PERMITS.md"
|
|
75
86
|
],
|
|
76
87
|
"publishConfig": {
|
|
77
88
|
"access": "public",
|
|
78
89
|
"registry": "https://registry.npmjs.org"
|
|
79
90
|
},
|
|
91
|
+
"engines": {
|
|
92
|
+
"node": "^20.19.0 || >=22.12.0"
|
|
93
|
+
},
|
|
94
|
+
"zhin": {
|
|
95
|
+
"protocol": 1,
|
|
96
|
+
"type": "plugin",
|
|
97
|
+
"entry": "./plugin.js",
|
|
98
|
+
"engine": "^1.0.0",
|
|
99
|
+
"runtime": "trusted",
|
|
100
|
+
"features": [
|
|
101
|
+
{
|
|
102
|
+
"package": "@zhin.js/adapter",
|
|
103
|
+
"api": "^1.0.0"
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
"package": "@zhin.js/command",
|
|
107
|
+
"api": "^1.0.0"
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
"package": "@zhin.js/tool",
|
|
111
|
+
"api": "^1.0.0"
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
"package": "@zhin.js/skill",
|
|
115
|
+
"api": "^1.0.0"
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
"package": "@zhin.js/agent-feature",
|
|
119
|
+
"api": "^1.0.0"
|
|
120
|
+
}
|
|
121
|
+
],
|
|
122
|
+
"plugins": []
|
|
123
|
+
},
|
|
80
124
|
"scripts": {
|
|
81
|
-
"build": "
|
|
82
|
-
"clean": "rimraf lib
|
|
83
|
-
"
|
|
125
|
+
"build": "tsc",
|
|
126
|
+
"clean": "rimraf lib",
|
|
127
|
+
"test": "NODE_OPTIONS=--experimental-strip-types vitest run --root ../../.. plugins/adapters/kook/tests"
|
|
84
128
|
}
|
|
85
129
|
}
|
package/plugin.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// Generated by build-plugin-runtime-entries.mjs. Do not edit.
|
|
2
|
+
import { createEndpointRuntimeState } from 'zhin.js/adapter';
|
|
3
|
+
import { definePlugin } from 'zhin.js';
|
|
4
|
+
import { permissionHostToken } from '@zhin.js/permission';
|
|
5
|
+
import { checkKookPlatformPermit } from "./lib/platform-permit.js";
|
|
6
|
+
import { kookRuntimeStateToken } from "./lib/kook-runtime-state.js";
|
|
7
|
+
export default definePlugin({
|
|
8
|
+
name: 'kook',
|
|
9
|
+
metadata: {
|
|
10
|
+
displayName: 'KOOK WebSocket Adapter',
|
|
11
|
+
},
|
|
12
|
+
setup(context) {
|
|
13
|
+
context.resources.provide(kookRuntimeStateToken, createEndpointRuntimeState());
|
|
14
|
+
if (context.resources.has(permissionHostToken)) {
|
|
15
|
+
const host = context.resources.use(permissionHostToken);
|
|
16
|
+
return host.registerPlatform('kook', checkKookPlatformPermit);
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
});
|
package/schema.json
ADDED
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"type": "object",
|
|
4
|
+
"additionalProperties": false,
|
|
5
|
+
"properties": {
|
|
6
|
+
"connection": {
|
|
7
|
+
"type": "string",
|
|
8
|
+
"enum": [
|
|
9
|
+
"websocket",
|
|
10
|
+
"webhook"
|
|
11
|
+
],
|
|
12
|
+
"default": "websocket",
|
|
13
|
+
"description": "WebSocket gateway (default). webhook requires httpHostToken, verify_token, and a public HTTPS callback URL."
|
|
14
|
+
},
|
|
15
|
+
"webhookPath": {
|
|
16
|
+
"type": "string",
|
|
17
|
+
"default": "/kook/webhook",
|
|
18
|
+
"description": "POST path registered via httpHostToken when connection is webhook."
|
|
19
|
+
},
|
|
20
|
+
"data_dir": {
|
|
21
|
+
"type": "string"
|
|
22
|
+
},
|
|
23
|
+
"timeout": {
|
|
24
|
+
"type": "number",
|
|
25
|
+
"default": 10000
|
|
26
|
+
},
|
|
27
|
+
"max_retry": {
|
|
28
|
+
"type": "number",
|
|
29
|
+
"default": 3
|
|
30
|
+
},
|
|
31
|
+
"ignore": {
|
|
32
|
+
"type": "string",
|
|
33
|
+
"enum": [
|
|
34
|
+
"bot",
|
|
35
|
+
"self"
|
|
36
|
+
],
|
|
37
|
+
"default": "bot"
|
|
38
|
+
},
|
|
39
|
+
"logLevel": {
|
|
40
|
+
"type": "string",
|
|
41
|
+
"enum": [
|
|
42
|
+
"trace",
|
|
43
|
+
"debug",
|
|
44
|
+
"info",
|
|
45
|
+
"warn",
|
|
46
|
+
"error",
|
|
47
|
+
"fatal",
|
|
48
|
+
"mark",
|
|
49
|
+
"off"
|
|
50
|
+
],
|
|
51
|
+
"default": "info"
|
|
52
|
+
},
|
|
53
|
+
"master": {
|
|
54
|
+
"type": [
|
|
55
|
+
"string",
|
|
56
|
+
"number"
|
|
57
|
+
],
|
|
58
|
+
"description": "框架 master(KOOK user id;AI/工具权限、endpoint 管理)。endpoints[i].master 可逐项覆盖"
|
|
59
|
+
},
|
|
60
|
+
"trusted": {
|
|
61
|
+
"type": "array",
|
|
62
|
+
"items": {
|
|
63
|
+
"type": [
|
|
64
|
+
"string",
|
|
65
|
+
"number"
|
|
66
|
+
],
|
|
67
|
+
"description": "Trusted KOOK user id"
|
|
68
|
+
},
|
|
69
|
+
"description": "框架 trusted 用户列表(弱于 master)。endpoints[i].trusted 可逐项追加"
|
|
70
|
+
},
|
|
71
|
+
"endpoints": {
|
|
72
|
+
"type": "array",
|
|
73
|
+
"minItems": 1,
|
|
74
|
+
"description": "多账号:每项定义一个 endpoint,id/token 必填,其余字段覆盖实例默认值",
|
|
75
|
+
"items": {
|
|
76
|
+
"type": "object",
|
|
77
|
+
"additionalProperties": false,
|
|
78
|
+
"properties": {
|
|
79
|
+
"master": {
|
|
80
|
+
"type": [
|
|
81
|
+
"string",
|
|
82
|
+
"number"
|
|
83
|
+
],
|
|
84
|
+
"description": "本 endpoint 的框架 master(KOOK user id);覆盖顶层 master"
|
|
85
|
+
},
|
|
86
|
+
"trusted": {
|
|
87
|
+
"type": "array",
|
|
88
|
+
"items": {
|
|
89
|
+
"type": [
|
|
90
|
+
"string",
|
|
91
|
+
"number"
|
|
92
|
+
],
|
|
93
|
+
"description": "Trusted KOOK user id"
|
|
94
|
+
},
|
|
95
|
+
"description": "本 endpoint 的 trusted 列表"
|
|
96
|
+
},
|
|
97
|
+
"token": {
|
|
98
|
+
"type": "string",
|
|
99
|
+
"description": "KOOK bot token"
|
|
100
|
+
},
|
|
101
|
+
"connection": {
|
|
102
|
+
"type": "string",
|
|
103
|
+
"enum": [
|
|
104
|
+
"websocket",
|
|
105
|
+
"webhook"
|
|
106
|
+
]
|
|
107
|
+
},
|
|
108
|
+
"webhookPath": {
|
|
109
|
+
"type": "string"
|
|
110
|
+
},
|
|
111
|
+
"verify_token": {
|
|
112
|
+
"type": "string",
|
|
113
|
+
"description": "KOOK developer console verify token (required for webhook mode)."
|
|
114
|
+
},
|
|
115
|
+
"encrypt_key": {
|
|
116
|
+
"type": "string",
|
|
117
|
+
"description": "Optional Encrypt Key when message encryption is enabled in KOOK console."
|
|
118
|
+
},
|
|
119
|
+
"data_dir": {
|
|
120
|
+
"type": "string"
|
|
121
|
+
},
|
|
122
|
+
"timeout": {
|
|
123
|
+
"type": "number"
|
|
124
|
+
},
|
|
125
|
+
"max_retry": {
|
|
126
|
+
"type": "number"
|
|
127
|
+
},
|
|
128
|
+
"ignore": {
|
|
129
|
+
"type": "string",
|
|
130
|
+
"enum": [
|
|
131
|
+
"bot",
|
|
132
|
+
"self"
|
|
133
|
+
]
|
|
134
|
+
},
|
|
135
|
+
"logLevel": {
|
|
136
|
+
"type": "string",
|
|
137
|
+
"enum": [
|
|
138
|
+
"trace",
|
|
139
|
+
"debug",
|
|
140
|
+
"info",
|
|
141
|
+
"warn",
|
|
142
|
+
"error",
|
|
143
|
+
"fatal",
|
|
144
|
+
"mark",
|
|
145
|
+
"off"
|
|
146
|
+
]
|
|
147
|
+
},
|
|
148
|
+
"commandPrefix": {
|
|
149
|
+
"type": "string"
|
|
150
|
+
},
|
|
151
|
+
"id": {
|
|
152
|
+
"type": "string",
|
|
153
|
+
"description": "KOOK bot name"
|
|
154
|
+
}
|
|
155
|
+
},
|
|
156
|
+
"required": [
|
|
157
|
+
"id",
|
|
158
|
+
"token"
|
|
159
|
+
]
|
|
160
|
+
}
|
|
161
|
+
},
|
|
162
|
+
"commandPrefix": {
|
|
163
|
+
"type": "string",
|
|
164
|
+
"default": "",
|
|
165
|
+
"description": "命令前缀(默认 '' 无前缀,任意文本按命令匹配;如 '/' 要求 / 开头)。endpoints[i] 可逐项覆盖"
|
|
166
|
+
}
|
|
167
|
+
},
|
|
168
|
+
"required": [
|
|
169
|
+
"endpoints"
|
|
170
|
+
]
|
|
171
|
+
}
|
package/src/client.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { defineEndpointClient } from 'zhin.js/adapter';
|
|
2
|
+
import type { KookClientTransport } from './ws.js';
|
|
3
|
+
|
|
4
|
+
export type KookClientEventMap = Record<string, unknown>;
|
|
5
|
+
|
|
6
|
+
declare module '@zhin.js/feature-kit' {
|
|
7
|
+
interface AdapterClientRegistry {
|
|
8
|
+
readonly kook: {
|
|
9
|
+
readonly client: KookClientTransport;
|
|
10
|
+
readonly events: KookClientEventMap;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export const kookClient = defineEndpointClient<KookClientTransport, KookClientEventMap>('kook');
|