@zhin.js/adapter-qq 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 +940 -17
- package/PERMITS.md +25 -0
- package/README.md +135 -233
- package/adapters/qq/index.js +50 -0
- package/adapters/qq/index.ts +71 -0
- package/agents/qq/agent.json +20 -0
- package/agents/qq/boundaries.md +3 -0
- package/agents/qq/conventions.md +3 -0
- package/agents/qq/skills/qq/SKILL.md +22 -0
- package/agents/qq/skills/qq/tools/add_role/index.js +21 -0
- package/agents/qq/skills/qq/tools/add_role/index.ts +21 -0
- package/agents/qq/skills/qq/tools/channel_info/index.js +17 -0
- package/agents/qq/skills/qq/tools/channel_info/index.ts +17 -0
- package/agents/qq/skills/qq/tools/create_role/index.js +20 -0
- package/agents/qq/skills/qq/tools/create_role/index.ts +20 -0
- package/agents/qq/skills/qq/tools/list_channels/index.js +18 -0
- package/agents/qq/skills/qq/tools/list_channels/index.ts +18 -0
- package/agents/qq/skills/qq/tools/list_guilds/index.js +14 -0
- package/agents/qq/skills/qq/tools/list_guilds/index.ts +14 -0
- package/agents/qq/skills/qq/tools/list_roles/index.js +18 -0
- package/agents/qq/skills/qq/tools/list_roles/index.ts +18 -0
- package/agents/qq/skills/qq/tools/member_detail/index.js +18 -0
- package/agents/qq/skills/qq/tools/member_detail/index.ts +18 -0
- package/agents/qq/skills/qq/tools/remove_role/index.js +21 -0
- package/agents/qq/skills/qq/tools/remove_role/index.ts +21 -0
- package/agents/qq/system.md +3 -0
- package/commands/qq/endpoint/add/[[id]]/index.js +3 -0
- package/commands/qq/endpoint/add/[[id]]/index.ts +3 -0
- package/commands/qq/endpoint/cancel/index.js +11 -0
- package/commands/qq/endpoint/cancel/index.ts +15 -0
- package/commands/qq/endpoint/definition.js +188 -0
- package/commands/qq/endpoint/definition.ts +263 -0
- package/commands/qq/endpoint/list/index.js +3 -0
- package/commands/qq/endpoint/list/index.ts +3 -0
- package/commands/qq/endpoint/remove/[id]/index.js +3 -0
- package/commands/qq/endpoint/remove/[id]/index.ts +3 -0
- package/lib/client.d.ts +12 -0
- package/lib/client.js +2 -0
- package/lib/endpoint.d.ts +56 -0
- package/lib/endpoint.js +456 -0
- package/lib/index.d.ts +8 -18
- package/lib/index.js +8 -338
- package/lib/outbound.d.ts +17 -0
- package/lib/outbound.js +234 -0
- package/lib/platform-permit.d.ts +15 -0
- package/lib/platform-permit.js +41 -0
- package/lib/protocol.d.ts +90 -0
- package/lib/protocol.js +161 -0
- package/lib/qq-bind-api.d.ts +36 -0
- package/lib/qq-bind-api.js +89 -0
- package/lib/qq-bind-flow.d.ts +19 -0
- package/lib/qq-bind-flow.js +85 -0
- package/lib/qq-bot-kind-prompt.d.ts +9 -0
- package/lib/qq-bot-kind-prompt.js +37 -0
- package/lib/qq-intents.d.ts +27 -0
- package/lib/qq-intents.js +51 -0
- package/lib/qq-runtime-state.d.ts +30 -0
- package/lib/qq-runtime-state.js +14 -0
- package/lib/side-event-dispatch.d.ts +10 -0
- package/lib/side-event-dispatch.js +114 -0
- package/lib/webhook.d.ts +18 -0
- package/lib/webhook.js +103 -0
- package/lib/ws.d.ts +55 -0
- package/lib/ws.js +234 -0
- package/middlewares/bot-kind-reply/index.js +47 -0
- package/middlewares/bot-kind-reply/index.ts +65 -0
- package/package.json +82 -29
- package/plugin.js +18 -0
- package/schema.json +158 -0
- package/src/client.ts +16 -0
- package/src/endpoint.ts +534 -0
- package/src/index.ts +66 -326
- package/src/outbound.ts +255 -0
- package/src/platform-permit.ts +56 -0
- package/src/protocol.ts +249 -0
- package/src/qq-bind-api.ts +145 -0
- package/src/qq-bind-flow.ts +127 -0
- package/src/qq-bot-kind-prompt.ts +47 -0
- package/src/qq-intents.ts +77 -0
- package/src/qq-runtime-state.ts +51 -0
- package/src/side-event-dispatch.ts +140 -0
- package/src/webhook.ts +132 -0
- package/src/ws.ts +331 -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 -17
- package/dist/index.js +0 -30
- package/lib/adapter.d.ts +0 -17
- package/lib/adapter.d.ts.map +0 -1
- package/lib/adapter.js +0 -49
- package/lib/adapter.js.map +0 -1
- package/lib/bot.d.ts +0 -102
- package/lib/bot.d.ts.map +0 -1
- package/lib/bot.js +0 -337
- 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 -16
- 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/skills/qq/SKILL.md +0 -97
- package/src/adapter.ts +0 -58
- package/src/bot.ts +0 -347
- package/src/types.ts +0 -24
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zhin.js/adapter-qq",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "Zhin.js adapter for
|
|
3
|
+
"version": "1.1.2",
|
|
4
|
+
"description": "Zhin.js QQ Official adapter for Plugin Runtime (WebSocket gateway)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./lib/index.js",
|
|
7
7
|
"types": "./lib/index.d.ts",
|
|
@@ -34,53 +34,106 @@
|
|
|
34
34
|
"directory": "plugins/adapters/qq"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"qq-official-bot": "^1.
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
"@
|
|
41
|
-
"@
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"@zhin.js/
|
|
45
|
-
"@zhin.js/
|
|
46
|
-
"zhin.js": "1.
|
|
37
|
+
"qq-official-bot": "^1.3.0",
|
|
38
|
+
"@zhin.js/adapter": "1.1.14",
|
|
39
|
+
"@zhin.js/agent-feature": "1.1.1",
|
|
40
|
+
"@zhin.js/core": "1.1.37",
|
|
41
|
+
"@zhin.js/feature-kit": "1.1.1",
|
|
42
|
+
"@zhin.js/host-http": "1.1.1",
|
|
43
|
+
"@zhin.js/im-contract": "1.1.1",
|
|
44
|
+
"@zhin.js/logger": "1.1.1",
|
|
45
|
+
"@zhin.js/permission": "1.1.1",
|
|
46
|
+
"@zhin.js/skill": "1.1.1",
|
|
47
|
+
"@zhin.js/tool": "1.1.1"
|
|
47
48
|
},
|
|
48
49
|
"peerDependencies": {
|
|
49
|
-
"
|
|
50
|
-
"@zhin.js/
|
|
51
|
-
"@zhin.js/
|
|
52
|
-
"@zhin.js/
|
|
53
|
-
"zhin.js": "1.
|
|
50
|
+
"zod": "^4.0.0",
|
|
51
|
+
"@zhin.js/adapter": "^1.1.14",
|
|
52
|
+
"@zhin.js/command": "^1.1.1",
|
|
53
|
+
"@zhin.js/core": "^1.1.37",
|
|
54
|
+
"@zhin.js/middleware": "^1.1.1",
|
|
55
|
+
"zhin.js": "^1.1.2"
|
|
54
56
|
},
|
|
55
57
|
"peerDependenciesMeta": {
|
|
56
|
-
"@zhin.js/
|
|
58
|
+
"@zhin.js/command": {
|
|
59
|
+
"optional": true
|
|
60
|
+
},
|
|
61
|
+
"@zhin.js/middleware": {
|
|
57
62
|
"optional": true
|
|
58
63
|
},
|
|
59
|
-
"
|
|
64
|
+
"zhin.js": {
|
|
60
65
|
"optional": true
|
|
61
66
|
},
|
|
62
|
-
"
|
|
67
|
+
"zod": {
|
|
63
68
|
"optional": true
|
|
64
69
|
}
|
|
65
70
|
},
|
|
71
|
+
"devDependencies": {
|
|
72
|
+
"@types/node": "^26.1.2",
|
|
73
|
+
"typescript": "^6.0.3",
|
|
74
|
+
"vitest": "^4.1.10",
|
|
75
|
+
"zod": "^4.4.3",
|
|
76
|
+
"@zhin.js/host-http": "1.1.1",
|
|
77
|
+
"zhin.js": "1.1.2"
|
|
78
|
+
},
|
|
66
79
|
"files": [
|
|
80
|
+
"adapters",
|
|
81
|
+
"commands",
|
|
82
|
+
"middlewares",
|
|
83
|
+
"plugin.js",
|
|
84
|
+
"schema.json",
|
|
67
85
|
"src",
|
|
68
86
|
"lib",
|
|
69
|
-
"
|
|
70
|
-
"
|
|
71
|
-
"skills",
|
|
72
|
-
"plugin.yml",
|
|
87
|
+
"tools",
|
|
88
|
+
"agents",
|
|
73
89
|
"README.md",
|
|
74
|
-
"
|
|
75
|
-
"
|
|
90
|
+
"CHANGELOG.md",
|
|
91
|
+
"PERMITS.md"
|
|
76
92
|
],
|
|
77
93
|
"publishConfig": {
|
|
78
94
|
"access": "public",
|
|
79
95
|
"registry": "https://registry.npmjs.org"
|
|
80
96
|
},
|
|
97
|
+
"engines": {
|
|
98
|
+
"node": "^20.19.0 || >=22.12.0"
|
|
99
|
+
},
|
|
100
|
+
"zhin": {
|
|
101
|
+
"protocol": 1,
|
|
102
|
+
"type": "plugin",
|
|
103
|
+
"entry": "./plugin.js",
|
|
104
|
+
"engine": "^1.0.0",
|
|
105
|
+
"runtime": "trusted",
|
|
106
|
+
"features": [
|
|
107
|
+
{
|
|
108
|
+
"package": "@zhin.js/adapter",
|
|
109
|
+
"api": "^1.0.0"
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
"package": "@zhin.js/command",
|
|
113
|
+
"api": "^1.0.0"
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
"package": "@zhin.js/middleware",
|
|
117
|
+
"api": "^1.0.0"
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
"package": "@zhin.js/tool",
|
|
121
|
+
"api": "^1.0.0"
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
"package": "@zhin.js/skill",
|
|
125
|
+
"api": "^1.0.0"
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
"package": "@zhin.js/agent-feature",
|
|
129
|
+
"api": "^1.0.0"
|
|
130
|
+
}
|
|
131
|
+
],
|
|
132
|
+
"plugins": []
|
|
133
|
+
},
|
|
81
134
|
"scripts": {
|
|
82
|
-
"build": "
|
|
83
|
-
"clean": "rimraf lib
|
|
84
|
-
"
|
|
135
|
+
"build": "tsc",
|
|
136
|
+
"clean": "rimraf lib",
|
|
137
|
+
"test": "NODE_OPTIONS=--experimental-strip-types vitest run --root ../../.. plugins/adapters/qq/tests"
|
|
85
138
|
}
|
|
86
139
|
}
|
package/plugin.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// Generated by build-plugin-runtime-entries.mjs. Do not edit.
|
|
2
|
+
import { definePlugin } from 'zhin.js';
|
|
3
|
+
import { permissionHostToken } from '@zhin.js/permission';
|
|
4
|
+
import { checkQqPlatformPermit } from "./lib/platform-permit.js";
|
|
5
|
+
import { createQqRuntimeState, qqRuntimeStateToken } from "./lib/qq-runtime-state.js";
|
|
6
|
+
export default definePlugin({
|
|
7
|
+
name: 'qq',
|
|
8
|
+
metadata: {
|
|
9
|
+
displayName: 'QQ Official WebSocket Adapter',
|
|
10
|
+
},
|
|
11
|
+
setup(context) {
|
|
12
|
+
context.resources.provide(qqRuntimeStateToken, createQqRuntimeState());
|
|
13
|
+
if (context.resources.has(permissionHostToken)) {
|
|
14
|
+
const host = context.resources.use(permissionHostToken);
|
|
15
|
+
return host.registerPlatform('qq', checkQqPlatformPermit);
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
});
|
package/schema.json
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"type": "object",
|
|
4
|
+
"additionalProperties": false,
|
|
5
|
+
"properties": {
|
|
6
|
+
"mode": {
|
|
7
|
+
"type": "string",
|
|
8
|
+
"enum": [
|
|
9
|
+
"websocket",
|
|
10
|
+
"webhook",
|
|
11
|
+
"middleware"
|
|
12
|
+
],
|
|
13
|
+
"default": "websocket",
|
|
14
|
+
"description": "WebSocket gateway (default). webhook/middleware use httpHostToken POST."
|
|
15
|
+
},
|
|
16
|
+
"sandbox": {
|
|
17
|
+
"type": "boolean",
|
|
18
|
+
"default": false
|
|
19
|
+
},
|
|
20
|
+
"botKind": {
|
|
21
|
+
"type": "string",
|
|
22
|
+
"enum": [
|
|
23
|
+
"public",
|
|
24
|
+
"private"
|
|
25
|
+
],
|
|
26
|
+
"default": "public",
|
|
27
|
+
"description": "公域/私域:均含 GROUP_AND_C2C_EVENT;频道消息分别为 PUBLIC_GUILD_MESSAGES / GUILD_MESSAGES。未显式配置 intents 时按此展开"
|
|
28
|
+
},
|
|
29
|
+
"master": {
|
|
30
|
+
"type": [
|
|
31
|
+
"string",
|
|
32
|
+
"number"
|
|
33
|
+
],
|
|
34
|
+
"description": "框架 master(endpoint 管理命令、AI/工具权限);openid。endpoints[i].master 可逐项覆盖"
|
|
35
|
+
},
|
|
36
|
+
"trusted": {
|
|
37
|
+
"type": "array",
|
|
38
|
+
"items": {
|
|
39
|
+
"type": [
|
|
40
|
+
"string",
|
|
41
|
+
"number"
|
|
42
|
+
],
|
|
43
|
+
"description": "Trusted openid"
|
|
44
|
+
},
|
|
45
|
+
"description": "框架 trusted 用户列表(弱于 master)。endpoints[i].trusted 可逐项追加"
|
|
46
|
+
},
|
|
47
|
+
"intents": {
|
|
48
|
+
"type": "array",
|
|
49
|
+
"items": {
|
|
50
|
+
"type": "string"
|
|
51
|
+
},
|
|
52
|
+
"description": "WebSocket Identify intents;省略时按 botKind 自动生成(public→含 PUBLIC_GUILD_MESSAGES)"
|
|
53
|
+
},
|
|
54
|
+
"accessTokenUrl": {
|
|
55
|
+
"type": "string"
|
|
56
|
+
},
|
|
57
|
+
"gatewayUrl": {
|
|
58
|
+
"type": "string"
|
|
59
|
+
},
|
|
60
|
+
"webhookPath": {
|
|
61
|
+
"type": "string",
|
|
62
|
+
"default": "/qq/webhook",
|
|
63
|
+
"description": "POST path on httpHostToken for webhook/middleware modes."
|
|
64
|
+
},
|
|
65
|
+
"endpoints": {
|
|
66
|
+
"type": "array",
|
|
67
|
+
"minItems": 1,
|
|
68
|
+
"description": "多账号:每项定义一个 endpoint,id/appid/secret 必填,其余字段覆盖实例默认值",
|
|
69
|
+
"items": {
|
|
70
|
+
"type": "object",
|
|
71
|
+
"additionalProperties": false,
|
|
72
|
+
"properties": {
|
|
73
|
+
"appid": {
|
|
74
|
+
"type": "string",
|
|
75
|
+
"description": "QQ official bot app ID"
|
|
76
|
+
},
|
|
77
|
+
"secret": {
|
|
78
|
+
"type": "string",
|
|
79
|
+
"description": "QQ official bot secret"
|
|
80
|
+
},
|
|
81
|
+
"mode": {
|
|
82
|
+
"type": "string",
|
|
83
|
+
"enum": [
|
|
84
|
+
"websocket",
|
|
85
|
+
"webhook",
|
|
86
|
+
"middleware"
|
|
87
|
+
]
|
|
88
|
+
},
|
|
89
|
+
"sandbox": {
|
|
90
|
+
"type": "boolean"
|
|
91
|
+
},
|
|
92
|
+
"master": {
|
|
93
|
+
"type": [
|
|
94
|
+
"string",
|
|
95
|
+
"number"
|
|
96
|
+
],
|
|
97
|
+
"description": "本 endpoint 的框架 master(openid);覆盖顶层 master"
|
|
98
|
+
},
|
|
99
|
+
"trusted": {
|
|
100
|
+
"type": "array",
|
|
101
|
+
"items": {
|
|
102
|
+
"type": [
|
|
103
|
+
"string",
|
|
104
|
+
"number"
|
|
105
|
+
],
|
|
106
|
+
"description": "Trusted openid"
|
|
107
|
+
},
|
|
108
|
+
"description": "本 endpoint 的 trusted 列表"
|
|
109
|
+
},
|
|
110
|
+
"botKind": {
|
|
111
|
+
"type": "string",
|
|
112
|
+
"enum": [
|
|
113
|
+
"public",
|
|
114
|
+
"private"
|
|
115
|
+
],
|
|
116
|
+
"description": "覆盖顶层 botKind(公域/私域),用于按 endpoint 生成 intents"
|
|
117
|
+
},
|
|
118
|
+
"intents": {
|
|
119
|
+
"type": "array",
|
|
120
|
+
"items": {
|
|
121
|
+
"type": "string"
|
|
122
|
+
},
|
|
123
|
+
"description": "覆盖顶层 intents"
|
|
124
|
+
},
|
|
125
|
+
"accessTokenUrl": {
|
|
126
|
+
"type": "string"
|
|
127
|
+
},
|
|
128
|
+
"gatewayUrl": {
|
|
129
|
+
"type": "string"
|
|
130
|
+
},
|
|
131
|
+
"webhookPath": {
|
|
132
|
+
"type": "string"
|
|
133
|
+
},
|
|
134
|
+
"commandPrefix": {
|
|
135
|
+
"type": "string"
|
|
136
|
+
},
|
|
137
|
+
"id": {
|
|
138
|
+
"type": "string",
|
|
139
|
+
"description": "QQ bot name"
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
"required": [
|
|
143
|
+
"id",
|
|
144
|
+
"appid",
|
|
145
|
+
"secret"
|
|
146
|
+
]
|
|
147
|
+
}
|
|
148
|
+
},
|
|
149
|
+
"commandPrefix": {
|
|
150
|
+
"type": "string",
|
|
151
|
+
"default": "",
|
|
152
|
+
"description": "命令前缀(默认 '' 无前缀,任意文本按命令匹配;如 '/' 要求 / 开头)。endpoints[i] 可逐项覆盖"
|
|
153
|
+
}
|
|
154
|
+
},
|
|
155
|
+
"required": [
|
|
156
|
+
"endpoints"
|
|
157
|
+
]
|
|
158
|
+
}
|
package/src/client.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { defineEndpointClient } from 'zhin.js/adapter';
|
|
2
|
+
import type { QqInboundMessage } from './protocol.js';
|
|
3
|
+
import type { QqBotTransport } from './ws.js';
|
|
4
|
+
|
|
5
|
+
export type QqClientEventMap = Record<string, QqInboundMessage | unknown>;
|
|
6
|
+
|
|
7
|
+
declare module '@zhin.js/feature-kit' {
|
|
8
|
+
interface AdapterClientRegistry {
|
|
9
|
+
readonly qq: {
|
|
10
|
+
readonly client: QqBotTransport;
|
|
11
|
+
readonly events: QqClientEventMap;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const qqClient = defineEndpointClient<QqBotTransport, QqClientEventMap>('qq');
|