@zhin.js/adapter-qq 1.1.0 → 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.
Files changed (61) hide show
  1. package/CHANGELOG.md +96 -0
  2. package/README.md +18 -19
  3. package/adapters/{qq.js → qq/index.js} +7 -7
  4. package/adapters/{qq.ts → qq/index.ts} +11 -11
  5. package/agents/qq/agent.json +20 -0
  6. package/agents/qq/boundaries.md +3 -0
  7. package/agents/qq/conventions.md +3 -0
  8. package/agents/qq/skills/qq/SKILL.md +22 -0
  9. package/agents/qq/skills/qq/tools/add_role/index.js +21 -0
  10. package/{agent/tools/add_role.ts → agents/qq/skills/qq/tools/add_role/index.ts} +3 -3
  11. package/agents/qq/skills/qq/tools/channel_info/index.js +17 -0
  12. package/{agent/tools/channel_info.ts → agents/qq/skills/qq/tools/channel_info/index.ts} +3 -3
  13. package/agents/qq/skills/qq/tools/create_role/index.js +20 -0
  14. package/{agent/tools/create_role.ts → agents/qq/skills/qq/tools/create_role/index.ts} +3 -3
  15. package/agents/qq/skills/qq/tools/list_channels/index.js +18 -0
  16. package/{agent/tools/list_channels.ts → agents/qq/skills/qq/tools/list_channels/index.ts} +3 -3
  17. package/agents/qq/skills/qq/tools/list_guilds/index.js +14 -0
  18. package/{agent/tools/list_guilds.ts → agents/qq/skills/qq/tools/list_guilds/index.ts} +1 -1
  19. package/agents/qq/skills/qq/tools/list_roles/index.js +18 -0
  20. package/{agent/tools/list_roles.ts → agents/qq/skills/qq/tools/list_roles/index.ts} +3 -3
  21. package/agents/qq/skills/qq/tools/member_detail/index.js +18 -0
  22. package/{agent/tools/member_detail.ts → agents/qq/skills/qq/tools/member_detail/index.ts} +3 -3
  23. package/agents/qq/skills/qq/tools/remove_role/index.js +21 -0
  24. package/{agent/tools/remove_role.ts → agents/qq/skills/qq/tools/remove_role/index.ts} +3 -3
  25. package/agents/qq/system.md +3 -0
  26. package/commands/{endpoint/add/[[id]].js → qq/endpoint/add/[[id]]/index.js} +1 -1
  27. package/commands/qq/endpoint/add/[[id]]/index.ts +3 -0
  28. package/commands/{endpoint/cancel.js → qq/endpoint/cancel/index.js} +1 -2
  29. package/commands/{endpoint/cancel.ts → qq/endpoint/cancel/index.ts} +2 -2
  30. package/{lib/qq-endpoint-commands.js → commands/qq/endpoint/definition.js} +44 -36
  31. package/{src/qq-endpoint-commands.ts → commands/qq/endpoint/definition.ts} +57 -45
  32. package/commands/{endpoint/list.js → qq/endpoint/list/index.js} +1 -1
  33. package/commands/qq/endpoint/list/index.ts +3 -0
  34. package/commands/{endpoint/remove/[id].js → qq/endpoint/remove/[id]/index.js} +1 -1
  35. package/commands/qq/endpoint/remove/[id]/index.ts +3 -0
  36. package/lib/index.d.ts +1 -1
  37. package/lib/outbound.js +1 -1
  38. package/lib/protocol.d.ts +7 -28
  39. package/lib/protocol.js +19 -24
  40. package/lib/qq-bot-kind-prompt.js +1 -1
  41. package/middlewares/{bot-kind-reply.js → bot-kind-reply/index.js} +7 -6
  42. package/middlewares/{bot-kind-reply.ts → bot-kind-reply/index.ts} +11 -6
  43. package/package.json +34 -22
  44. package/schema.json +26 -10
  45. package/src/index.ts +1 -1
  46. package/src/outbound.ts +1 -1
  47. package/src/protocol.ts +25 -49
  48. package/src/qq-bot-kind-prompt.ts +1 -1
  49. package/src/ws.ts +1 -1
  50. package/agent/skills/qq.md +0 -97
  51. package/commands/endpoint/add/[[id]].ts +0 -3
  52. package/commands/endpoint/list.ts +0 -3
  53. package/commands/endpoint/remove/[id].ts +0 -3
  54. package/lib/qq-bind-persist.d.ts +0 -12
  55. package/lib/qq-bind-persist.js +0 -22
  56. package/lib/qq-endpoint-commands.d.ts +0 -45
  57. package/lib/qq-endpoint-config.d.ts +0 -17
  58. package/lib/qq-endpoint-config.js +0 -22
  59. package/src/qq-bind-persist.ts +0 -44
  60. package/src/qq-endpoint-config.ts +0 -44
  61. /package/{agent/PERMITS.md → PERMITS.md} +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,101 @@
1
1
  # @zhin.js/adapter-qq
2
2
 
3
+ ## 1.1.2
4
+
5
+ ### Patch Changes
6
+
7
+ - a9e4a40: Derive Command user routes only from explicit `commands/**/*/index.ts(x)` entry paths instead of prepending the plugin owner. Child plugins can now publish top-level static or dynamic commands, while duplicate routes across owners fail during generation construction. Adapter endpoint commands move to explicit paths such as `commands/qq/endpoint/list/index.ts` and are invoked as `qq endpoint list`.
8
+ - 8740059: Standardize TypeScript capabilities on named module directories such as `commands/foo/index.ts`, `middlewares/audit/index.ts`, `handlers/message-receive/index.ts`, `pages/workroom/index.tsx`, and `mcps/filesystem/index.ts`. Only the fixed `index` entry is discovered; sibling files remain private helpers.
9
+
10
+ Command route segments come from directories, while `[name]`, `[[name]]`, `[...name]`, and `[[...name]]` directories declare dynamic parameters. Plugin owners do not enter the route unless their config explicitly sets `commandNamespace`; Endpoint `commandPrefix` remains platform-owned and defaults to an empty string.
11
+
12
+ Migrate the built-in adapters, plugins, examples, generators, migration tooling, hot reload classification, Agent authoring surfaces, documentation, and release artifacts to the explicit entry convention.
13
+
14
+ Make Tool ownership and progressive disclosure explicit across all four supported locations: plugin-public `tools/`, Agent-private `agents/<name>/tools/`, Skill-private `skills/<name>/tools/`, and Agent-Skill-private `agents/<name>/skills/<name>/tools/`. Move adapter and group-suite operations that require domain instructions into their owning Skills so `load_skill` is the only path that unlocks their schemas.
15
+
16
+ Remove the package-root `agent/` convention. Public capabilities now use named package-root directories, schedules use `schedules/<name>/index.ts` or `plugin.ts` injection, MCP connections use `mcps/<name>/index.ts`, Prompt Sections use `prompt-sections/<name>/index.ts`, Agent definitions use `agents/<name>/`, and permission vocabulary is published as `PERMITS.md`.
17
+
18
+ - 25a845a: Unify Skills on `skills/<name>/SKILL.md`, support Agent-private Skills and nested Skill-private Tools, publish and mount existing plugin Skills, add governed Skill metadata and Turn access filtering, unlock only already-admitted same-owner Tools, and make `on-risk` and `once` approval behavior precise.
19
+ - eb3227a: Move Endpoint project-configuration persistence behind the root-owned `EndpointConfigurationStore` resource. The Adapter package now owns only command semantics and no longer imports Node filesystem, path, or YAML APIs; CLI owns canonical YAML and `.env` persistence, while QQ and ICQQ special binding flows use the same injected boundary. Remove the old direct persistence helpers and reject legacy `plugins` arrays instead of promoting them at runtime.
20
+ - ddbb92e: Isolate adapter Skills under platform-specific Agents and automatically select the matching platform Agent for IM ingress, preventing unrelated adapter Skills from entering another platform's prompt surface.
21
+ - 4380cf9: Colocate adapter command definitions and Agent Skill handlers with their owning capabilities, and provide a shared validated platform permission constructor.
22
+ - 018b9b6: Require the canonical expanded QQ endpoint configuration. The QQ protocol no longer reinterprets a nested `endpoints` array, reads credentials or identity directly from `process.env`, or accepts unused standalone webhook `port` and `path` fields. The public endpoint config type is now `QqEndpointConfig`, and each schema entry uses `id` as its identity.
23
+ - 5c3858e: Make `@zhin.js/im-contract` the explicit zero-dependency owner of transport identities, canonical segments, media guards, conversation facts, stores, and delivery contracts. Platform adapters now read media contracts from that foundation instead of reaching through Core.
24
+ - 33ea736: Use `tools/<name>/index.ts` and `defineAgentTool` from `@zhin.js/tool` as the sole Agent Tool authoring model. Remove the duplicate `@zhin.js/tools` definition, context, bridge, export, and discovery path; migrate plugin manifests, examples, scaffolding, HMR, and prepack compilation to the generation-owned Tool Feature.
25
+ - df9f76b: Make Endpoint configuration persistence asynchronous and route it through the canonical transactional Root configuration port. Endpoint management now supports both YAML and JSON, materializes a missing Root config safely, serializes concurrent mutations, restores `.env` when the config commit fails, and restarts the development process after environment-file changes.
26
+ - Updated dependencies [c861789]
27
+ - Updated dependencies [1414ccb]
28
+ - Updated dependencies [743d470]
29
+ - Updated dependencies [62dee52]
30
+ - Updated dependencies [cd54131]
31
+ - Updated dependencies [244e475]
32
+ - Updated dependencies [a9e4a40]
33
+ - Updated dependencies [5855db7]
34
+ - Updated dependencies [ec921d2]
35
+ - Updated dependencies [8740059]
36
+ - Updated dependencies [63d1f7a]
37
+ - Updated dependencies [25a845a]
38
+ - Updated dependencies [103f2c3]
39
+ - Updated dependencies [9110ab8]
40
+ - Updated dependencies [cd2a888]
41
+ - Updated dependencies [eb3227a]
42
+ - Updated dependencies [b853dba]
43
+ - Updated dependencies [e561309]
44
+ - Updated dependencies [d4c6175]
45
+ - Updated dependencies [7a0e1ca]
46
+ - Updated dependencies [103b5d3]
47
+ - Updated dependencies [5a7a7f7]
48
+ - Updated dependencies [b076eae]
49
+ - Updated dependencies [535fed1]
50
+ - Updated dependencies [73a24b7]
51
+ - Updated dependencies [4380cf9]
52
+ - Updated dependencies [2dbbc15]
53
+ - Updated dependencies [1cb1163]
54
+ - Updated dependencies [be3061e]
55
+ - Updated dependencies [75f8332]
56
+ - Updated dependencies [81935e2]
57
+ - Updated dependencies [f9ed01b]
58
+ - Updated dependencies [ac0ab50]
59
+ - Updated dependencies [5140ce1]
60
+ - Updated dependencies [522d75f]
61
+ - Updated dependencies [a7611b3]
62
+ - Updated dependencies [8823044]
63
+ - Updated dependencies [379439b]
64
+ - Updated dependencies [11c9352]
65
+ - Updated dependencies [6b70e46]
66
+ - Updated dependencies [135ac91]
67
+ - Updated dependencies [140cf0f]
68
+ - Updated dependencies [251e4d2]
69
+ - Updated dependencies [203ad34]
70
+ - Updated dependencies [e6c5113]
71
+ - Updated dependencies [e0f6478]
72
+ - Updated dependencies [baef56b]
73
+ - Updated dependencies [698f16f]
74
+ - Updated dependencies [da0a8e3]
75
+ - Updated dependencies [2fd8017]
76
+ - Updated dependencies [5c3858e]
77
+ - Updated dependencies [33ea736]
78
+ - Updated dependencies [507d602]
79
+ - Updated dependencies [df9f76b]
80
+ - @zhin.js/core@1.1.37
81
+ - @zhin.js/tool@1.1.1
82
+ - @zhin.js/host-http@1.1.1
83
+ - @zhin.js/adapter@1.1.14
84
+ - @zhin.js/feature-kit@1.1.1
85
+ - @zhin.js/agent-feature@1.1.1
86
+ - @zhin.js/skill@1.1.1
87
+ - @zhin.js/logger@1.1.1
88
+ - @zhin.js/im-contract@1.1.1
89
+ - @zhin.js/permission@1.1.1
90
+
91
+ ## 1.1.1
92
+
93
+ ### Patch Changes
94
+
95
+ - Updated dependencies [769e67f]
96
+ - @zhin.js/adapter@1.1.13
97
+ - @zhin.js/core@1.1.36
98
+
3
99
  ## 1.1.0
4
100
 
5
101
  ### Minor Changes
package/README.md CHANGED
@@ -21,7 +21,7 @@ pnpm add @zhin.js/adapter-qq
21
21
 
22
22
  ## Plugin Runtime
23
23
 
24
- - `@zhin.js/adapter` — 约定式 `adapters/qq.ts`(`defineAdapter`)
24
+ - `@zhin.js/adapter` — 约定式 `adapters/qq/index.ts`(`defineAdapter`)
25
25
  - `@zhin.js/core` — `Endpoint.emit(...)` 入站、`outboundMessageToken` 出站
26
26
  - `zhin.js` — `plugin.ts`(`definePlugin`)
27
27
  - 配置经插件 `schema.json` 落到 `plugins.<instanceKey>`
@@ -38,7 +38,7 @@ pnpm add @zhin.js/adapter-qq
38
38
  | **WebSocket(默认)** | `qq-official-bot` 正向连接;无需公网回调 |
39
39
  | **host-http** | WebSocket **不需要**;Webhook / middleware 模式需要(经 `httpHostToken`) |
40
40
 
41
- 必填字段(`endpoints[i]`):`name`、`appid`、`secret`。
41
+ 必填字段(`endpoints[i]`):`id`、`appid`、`secret`。
42
42
 
43
43
  ## 最小配置
44
44
 
@@ -48,10 +48,10 @@ plugins:
48
48
  qq:
49
49
  # mode: websocket # 默认
50
50
  endpoints:
51
- - name: my-qq-bot
51
+ - id: my-qq-bot
52
52
  appid: ${QQ_APPID}
53
53
  secret: ${QQ_SECRET}
54
- # botKind / intents 可由向导写入;`qq.endpoint add` 扫码后会追问公域/私域再写入
54
+ # botKind / intents 可由向导写入;`qq endpoint add` 扫码后会追问公域/私域再写入
55
55
  ```
56
56
 
57
57
  ### botKind 与 intents
@@ -65,16 +65,16 @@ WebSocket Identify 的 `intents` **必须与开放平台已开通的权限一致
65
65
  | `private`(私域) | `GUILD_MESSAGES`(频道全量) | 同上 |
66
66
 
67
67
  公域机器人订阅 `GUILD_MESSAGES` 会 Identify 失败断连。显式配置 `intents` 时优先于 `botKind`。
68
- `create-zhin` / `zhin setup` 会询问公/私域并写入;`qq.endpoint add` 扫码成功后在同一会话追问 `public`/`private`(或 `公域`/`私域`),确认后一次性写 `.env` 与 yaml。
68
+ `create-zhin` / `zhin setup` 会询问公/私域并写入;`qq endpoint add` 扫码成功后在同一会话追问 `public`/`private`(或 `公域`/`私域`),确认后一次性写 `.env` 与 yaml。
69
69
 
70
- 多账号:一个插件实例挂多个 endpoint(`endpoints` 数组逐项覆盖顶层字段,`name` 必填):
70
+ 多账号:一个插件实例挂多个 endpoint(`endpoints` 数组逐项覆盖顶层字段,`id` 必填):
71
71
 
72
72
  ```yaml
73
73
  plugins:
74
74
  qq:
75
75
  mode: websocket
76
76
  endpoints:
77
- - name: main-bot
77
+ - id: main-bot
78
78
  appid: ${QQ_APPID}
79
79
  secret: ${QQ_SECRET}
80
80
  botKind: public
@@ -85,7 +85,7 @@ plugins:
85
85
  - GUILD_MEMBERS
86
86
  - DIRECT_MESSAGE
87
87
  - PUBLIC_GUILD_MESSAGES
88
- - name: private-bot
88
+ - id: private-bot
89
89
  appid: ${QQ_APPID_2}
90
90
  secret: ${QQ_SECRET_2}
91
91
  botKind: private
@@ -102,14 +102,14 @@ plugins:
102
102
 
103
103
  ## Endpoint 管理命令
104
104
 
105
- 适配器自带 `qq.endpoint` 命令组(聊天内直接使用,默认无前缀;受 `commandPrefix` 影响):
105
+ 适配器自带 `qq endpoint` 命令组(聊天内直接使用,默认无前缀;受 `commandPrefix` 影响):
106
106
 
107
107
  | 命令 | 说明 |
108
108
  |------|------|
109
- | `qq.endpoint add [name]` | 手机 QQ 扫码绑定 → **追问公域/私域** → 一次性写入 `.env` + `plugins.qq.endpoints`(重启生效) |
110
- | `qq.endpoint cancel` | 取消进行中的扫码绑定或待确认的公域/私域选择 |
111
- | `qq.endpoint list` | 列出运行中与配置中的 endpoints |
112
- | `qq.endpoint remove <name>` | 从配置移除 endpoint(`.env` 键保留,可手动清理) |
109
+ | `qq endpoint add [name]` | 手机 QQ 扫码绑定 → **追问公域/私域** → 一次性写入 `.env` + `plugins.qq.endpoints`(重启生效) |
110
+ | `qq endpoint cancel` | 取消进行中的扫码绑定或待确认的公域/私域选择 |
111
+ | `qq endpoint list` | 列出运行中与配置中的 endpoints |
112
+ | `qq endpoint remove <name>` | 从配置移除 endpoint(`.env` 键保留,可手动清理) |
113
113
 
114
114
  add/cancel/remove 受 `master` 限制:实例配置声明了 `master`(顶层或 `endpoints[i].master`)时仅
115
115
  master 可执行;未配置则放行(首个扫码绑定者会写入该 endpoint 的 `master`)。二维码当前以链接文本下发
@@ -119,9 +119,8 @@ master 可执行;未配置则放行(首个扫码绑定者会写入该 endpoi
119
119
 
120
120
  | 变量 | 说明 |
121
121
  |------|------|
122
- | `QQ_APPID` / `QQ_BOT_APPID` | 应用 AppID |
123
- | `QQ_SECRET` / `QQ_BOT_SECRET` | 应用 Secret |
124
- | `QQ_BOT_NAME` | 可选,默认 endpoint 名 |
122
+ | `QQ_APPID` | YAML 示例中 `appid` 引用的应用 AppID |
123
+ | `QQ_SECRET` | YAML 示例中 `secret` 引用的应用 Secret |
125
124
 
126
125
  ## Webhook / middleware
127
126
 
@@ -131,9 +130,9 @@ master 可执行;未配置则放行(首个扫码绑定者会写入该 endpoi
131
130
 
132
131
  | 类别 | 路径 |
133
132
  |------|------|
134
- | Permit 词汇 | `agent/PERMITS.md` |
135
- | 平台工具 | `agent/tools/`(频道、角色等) |
136
- | 技能说明 | `agent/skills/qq.md` |
133
+ | Permit 词汇 | `PERMITS.md` |
134
+ | 平台工具 | `tools/`(频道、角色等) |
135
+ | 技能说明 | `agents/qq/skills/qq/SKILL.md` |
137
136
 
138
137
  ## 平台 Client 与 QQ API
139
138
 
@@ -1,13 +1,13 @@
1
1
  // Generated by build-plugin-runtime-entries.mjs. Do not edit.
2
2
  /**
3
- * Convention entry: discover `adapters/qq.ts` → defineAdapter.
3
+ * Convention entry: discover `adapters/qq/index.ts` → defineAdapter.
4
4
  */
5
5
  import { defineAdapter } from 'zhin.js/adapter';
6
6
  import { httpHostToken } from '@zhin.js/host-http';
7
- import { QqHttpEndpoint, QqWebsocketEndpoint } from "../lib/endpoint.js";
8
- import { resolveQqConfig, } from "../lib/protocol.js";
9
- import { qqRuntimeStateToken } from "../lib/qq-runtime-state.js";
10
- export { QqHttpEndpoint, QqWebsocketEndpoint, } from "../lib/endpoint.js";
7
+ import { QqHttpEndpoint, QqWebsocketEndpoint } from "../../lib/endpoint.js";
8
+ import { resolveQqConfig, } from "../../lib/protocol.js";
9
+ import { qqRuntimeStateToken } from "../../lib/qq-runtime-state.js";
10
+ export { QqHttpEndpoint, QqWebsocketEndpoint, } from "../../lib/endpoint.js";
11
11
  export default defineAdapter({
12
12
  capabilities: ['inbound', 'outbound'],
13
13
  operations: ['recall'],
@@ -21,7 +21,7 @@ export default defineAdapter({
21
21
  },
22
22
  create(context) {
23
23
  const config = resolveQqConfig(context.config);
24
- // 注册到插件运行时状态(qq.endpoint list 的"运行中"数据源)
24
+ // 注册到插件运行时状态(qq endpoint list 的"运行中"数据源)
25
25
  const state = context.use(qqRuntimeStateToken);
26
26
  state.endpoints.set(config.id, {
27
27
  id: config.id,
@@ -39,7 +39,7 @@ export default defineAdapter({
39
39
  http: context.use(httpHostToken),
40
40
  config,
41
41
  });
42
- // 运行状态表只增不减:stop 时同步摘除,避免 stop 后 qq.endpoint list 仍显示运行中。
42
+ // 运行状态表只增不减:stop 时同步摘除,避免 stop 后 qq endpoint list 仍显示运行中。
43
43
  const stopEndpoint = endpoint.stop.bind(endpoint);
44
44
  endpoint.stop = async () => {
45
45
  state.endpoints.delete(config.id);
@@ -1,19 +1,19 @@
1
1
  /**
2
- * Convention entry: discover `adapters/qq.ts` → defineAdapter.
2
+ * Convention entry: discover `adapters/qq/index.ts` → defineAdapter.
3
3
  */
4
4
  import { defineAdapter } from 'zhin.js/adapter';
5
5
  import { httpHostToken } from '@zhin.js/host-http';
6
- import { QqHttpEndpoint, QqWebsocketEndpoint } from '../src/endpoint.js';
6
+ import { QqHttpEndpoint, QqWebsocketEndpoint } from '../../src/endpoint.js';
7
7
  import {
8
8
  resolveQqConfig,
9
- type QqAdapterConfig,
10
- } from '../src/protocol.js';
11
- import { qqRuntimeStateToken } from '../src/qq-runtime-state.js';
9
+ type QqEndpointConfig,
10
+ } from '../../src/protocol.js';
11
+ import { qqRuntimeStateToken } from '../../src/qq-runtime-state.js';
12
12
 
13
13
  export {
14
14
  QqHttpEndpoint,
15
15
  QqWebsocketEndpoint,
16
- } from '../src/endpoint.js';
16
+ } from '../../src/endpoint.js';
17
17
  export type {
18
18
  CreateQqBot,
19
19
  CreateQqHttpBot,
@@ -21,15 +21,15 @@ export type {
21
21
  QqEndpointOptions,
22
22
  QqHttpBotTransport,
23
23
  QqHttpEndpointOptions,
24
- } from '../src/endpoint.js';
24
+ } from '../../src/endpoint.js';
25
25
 
26
26
  declare module '@zhin.js/core' {
27
27
  interface AdapterEndpoints {
28
- qq: import('../src/endpoint.js').QqWebsocketEndpoint;
28
+ qq: import('../../src/endpoint.js').QqWebsocketEndpoint;
29
29
  }
30
30
  }
31
31
 
32
- export default defineAdapter<QqAdapterConfig>({
32
+ export default defineAdapter<QqEndpointConfig>({
33
33
  capabilities: ['inbound', 'outbound'],
34
34
  operations: ['recall'],
35
35
  // 媒体 url 直发,base64/path 由 SDK formatMediaData 物化走 /files 上传;
@@ -42,7 +42,7 @@ export default defineAdapter<QqAdapterConfig>({
42
42
  },
43
43
  create(context) {
44
44
  const config = resolveQqConfig(context.config);
45
- // 注册到插件运行时状态(qq.endpoint list 的"运行中"数据源)
45
+ // 注册到插件运行时状态(qq endpoint list 的"运行中"数据源)
46
46
  const state = context.use(qqRuntimeStateToken);
47
47
  state.endpoints.set(config.id, {
48
48
  id: config.id,
@@ -60,7 +60,7 @@ export default defineAdapter<QqAdapterConfig>({
60
60
  http: context.use(httpHostToken),
61
61
  config,
62
62
  });
63
- // 运行状态表只增不减:stop 时同步摘除,避免 stop 后 qq.endpoint list 仍显示运行中。
63
+ // 运行状态表只增不减:stop 时同步摘除,避免 stop 后 qq endpoint list 仍显示运行中。
64
64
  const stopEndpoint = endpoint.stop.bind(endpoint);
65
65
  endpoint.stop = async () => {
66
66
  state.endpoints.delete(config.id);
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "QQ Platform Agent",
3
+ "version": "1.0.0",
4
+ "description": "Handles qq platform-specific operations and progressively loads only the required platform Skill.",
5
+ "trigger_rules": {
6
+ "file_patterns": [],
7
+ "keywords": [
8
+ "qq",
9
+ "adapter:qq"
10
+ ]
11
+ },
12
+ "entry_points": [
13
+ "system.md",
14
+ "boundaries.md",
15
+ "conventions.md"
16
+ ],
17
+ "platforms": [
18
+ "qq"
19
+ ]
20
+ }
@@ -0,0 +1,3 @@
1
+ # Boundaries
2
+
3
+ Operate only on the active qq endpoint and authenticated conversation context. Respect every Tool permission and approval policy. Do not infer identifiers, roles, or authorization from display names.
@@ -0,0 +1,3 @@
1
+ # Conventions
2
+
3
+ Use stable platform identifiers from the current turn or directory queries. Load one task-specific Skill at a time, and use the unified reply and outbound message path.
@@ -0,0 +1,22 @@
1
+ ---
2
+ name: qq
3
+ platforms: [qq]
4
+ description: QQ 官方机器人频道、角色和成员详情能力。
5
+ keywords: [qq, guild, channel, role, member]
6
+ tags: [adapter, community]
7
+ tools:
8
+ - list_guilds
9
+ - list_channels
10
+ - list_roles
11
+ - create_role
12
+ - add_role
13
+ - remove_role
14
+ - channel_info
15
+ - member_detail
16
+ ---
17
+
18
+ # QQ 官方机器人
19
+
20
+ 先用 `list_guilds` 和 `list_channels` 确认频道上下文。角色操作前用 `list_roles` 获取角色 ID;成员操作前用 `member_detail` 确认目标。创建、授予和移除角色属于写操作,应遵守对应 Tool 的审批策略。
21
+
22
+ 当前 Agent Tool 不提供群踢人、禁言或成员列表能力。
@@ -0,0 +1,21 @@
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: '给成员添加 QQ 频道角色',
7
+ inputSchema: z.object({
8
+ guild_id: z.string().describe('频道 ID'),
9
+ channel_id: z.string().describe('子频道 ID'),
10
+ user_id: z.string().describe('用户 ID'),
11
+ role_id: z.string().describe('角色 ID'),
12
+ }),
13
+ adapter: 'qq',
14
+ tags: ['qq'],
15
+ permissions: [platformPermission('qq', 'manage_roles')],
16
+ async execute({ guild_id, channel_id, user_id, role_id }, context) {
17
+ const client = context.$client;
18
+ const success = await client.addMemberRole(guild_id, channel_id, user_id, role_id);
19
+ return { success, message: success ? '已给成员添加角色' : '操作失败' };
20
+ },
21
+ });
@@ -1,6 +1,6 @@
1
- import { defineAgentTool } from '@zhin.js/agent/tools';
1
+ import { defineAgentTool } from '@zhin.js/tool';
2
2
  import { z } from 'zod';
3
- import { platformPermit } from '../../src/platform-permit.js';
3
+ import { platformPermission } from '@zhin.js/permission';
4
4
 
5
5
  export default defineAgentTool<{ guild_id: string; channel_id: string; user_id: string; role_id: string }>({
6
6
  description: '给成员添加 QQ 频道角色',
@@ -12,7 +12,7 @@ export default defineAgentTool<{ guild_id: string; channel_id: string; user_id:
12
12
  }),
13
13
  adapter: 'qq',
14
14
  tags: ['qq'],
15
- permissions: [platformPermit('manage_roles')],
15
+ permissions: [platformPermission('qq', 'manage_roles')],
16
16
  async execute({ guild_id, channel_id, user_id, role_id }: { guild_id: string; channel_id: string; user_id: string; role_id: string }, context) {
17
17
  const client = context.$client;
18
18
  const success = await client.addMemberRole(guild_id, channel_id, user_id, role_id);
@@ -0,0 +1,17 @@
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: '获取 QQ 频道中指定子频道的详细信息',
7
+ inputSchema: z.object({
8
+ channel_id: z.string().describe('子频道 ID'),
9
+ }),
10
+ adapter: 'qq',
11
+ tags: ['qq'],
12
+ permissions: [platformPermission('qq', 'guild_admin')],
13
+ async execute({ channel_id }, context) {
14
+ const client = context.$client;
15
+ return client.getChannelInfo(channel_id);
16
+ },
17
+ });
@@ -1,6 +1,6 @@
1
- import { defineAgentTool } from '@zhin.js/agent/tools';
1
+ import { defineAgentTool } from '@zhin.js/tool';
2
2
  import { z } from 'zod';
3
- import { platformPermit } from '../../src/platform-permit.js';
3
+ import { platformPermission } from '@zhin.js/permission';
4
4
 
5
5
  export default defineAgentTool<{ channel_id: string }>({
6
6
  description: '获取 QQ 频道中指定子频道的详细信息',
@@ -9,7 +9,7 @@ export default defineAgentTool<{ channel_id: string }>({
9
9
  }),
10
10
  adapter: 'qq',
11
11
  tags: ['qq'],
12
- permissions: [platformPermit('guild_admin')],
12
+ permissions: [platformPermission('qq', 'guild_admin')],
13
13
  async execute({ channel_id }: { channel_id: string }, context) {
14
14
  const client = context.$client;
15
15
  return client.getChannelInfo(channel_id);
@@ -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: '创建 QQ 频道角色',
7
+ inputSchema: z.object({
8
+ guild_id: z.string().describe('频道 ID'),
9
+ name: z.string().describe('角色名称'),
10
+ color: z.number().optional().describe('颜色(RGB 十进制数值)'),
11
+ }),
12
+ adapter: 'qq',
13
+ tags: ['qq'],
14
+ permissions: [platformPermission('qq', 'guild_owner')],
15
+ async execute({ guild_id, name, color }, context) {
16
+ const client = context.$client;
17
+ const role = await client.createGuildRole(guild_id, name, color);
18
+ return { success: !!role, role, message: role ? `角色 "${name}" 创建成功` : '创建失败' };
19
+ },
20
+ });
@@ -1,6 +1,6 @@
1
- import { defineAgentTool } from '@zhin.js/agent/tools';
1
+ import { defineAgentTool } from '@zhin.js/tool';
2
2
  import { z } from 'zod';
3
- import { platformPermit } from '../../src/platform-permit.js';
3
+ import { platformPermission } from '@zhin.js/permission';
4
4
 
5
5
  export default defineAgentTool<{ guild_id: string; name: string; color?: number }>({
6
6
  description: '创建 QQ 频道角色',
@@ -11,7 +11,7 @@ export default defineAgentTool<{ guild_id: string; name: string; color?: number
11
11
  }),
12
12
  adapter: 'qq',
13
13
  tags: ['qq'],
14
- permissions: [platformPermit('guild_owner')],
14
+ permissions: [platformPermission('qq', 'guild_owner')],
15
15
  async execute({ guild_id, name, color }: { guild_id: string; name: string; color?: number }, context) {
16
16
  const client = context.$client;
17
17
  const role = await client.createGuildRole(guild_id, name, color);
@@ -0,0 +1,18 @@
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: '获取 QQ 频道下的子频道列表',
7
+ inputSchema: z.object({
8
+ guild_id: z.string().describe('频道 ID'),
9
+ }),
10
+ adapter: 'qq',
11
+ tags: ['qq'],
12
+ permissions: [platformPermission('qq', 'manage_channels')],
13
+ async execute({ guild_id }, context) {
14
+ const client = context.$client;
15
+ const channels = await client.getChannels(guild_id);
16
+ return { channels, count: channels.length };
17
+ },
18
+ });
@@ -1,6 +1,6 @@
1
- import { defineAgentTool } from '@zhin.js/agent/tools';
1
+ import { defineAgentTool } from '@zhin.js/tool';
2
2
  import { z } from 'zod';
3
- import { platformPermit } from '../../src/platform-permit.js';
3
+ import { platformPermission } from '@zhin.js/permission';
4
4
 
5
5
  export default defineAgentTool<{ guild_id: string }>({
6
6
  description: '获取 QQ 频道下的子频道列表',
@@ -9,7 +9,7 @@ export default defineAgentTool<{ guild_id: string }>({
9
9
  }),
10
10
  adapter: 'qq',
11
11
  tags: ['qq'],
12
- permissions: [platformPermit('manage_channels')],
12
+ permissions: [platformPermission('qq', 'manage_channels')],
13
13
  async execute({ guild_id }: { guild_id: string }, context) {
14
14
  const client = context.$client;
15
15
  const channels = await client.getChannels(guild_id);
@@ -0,0 +1,14 @@
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: '获取 QQ 频道列表',
6
+ inputSchema: z.object({}),
7
+ adapter: 'qq',
8
+ tags: ['qq'],
9
+ async execute(_input, context) {
10
+ const client = context.$client;
11
+ const guilds = await client.getGuilds();
12
+ return { guilds, count: guilds.length };
13
+ },
14
+ });
@@ -1,4 +1,4 @@
1
- import { defineAgentTool } from '@zhin.js/agent/tools';
1
+ import { defineAgentTool } from '@zhin.js/tool';
2
2
  import { z } from 'zod';
3
3
 
4
4
  export default defineAgentTool<Record<string, never>>({
@@ -0,0 +1,18 @@
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: '获取 QQ 频道角色列表',
7
+ inputSchema: z.object({
8
+ guild_id: z.string().describe('频道 ID'),
9
+ }),
10
+ adapter: 'qq',
11
+ tags: ['qq'],
12
+ permissions: [platformPermission('qq', 'manage_roles')],
13
+ async execute({ guild_id }, context) {
14
+ const client = context.$client;
15
+ const roles = await client.getGuildRoles(guild_id);
16
+ return { roles, count: roles.length };
17
+ },
18
+ });
@@ -1,6 +1,6 @@
1
- import { defineAgentTool } from '@zhin.js/agent/tools';
1
+ import { defineAgentTool } from '@zhin.js/tool';
2
2
  import { z } from 'zod';
3
- import { platformPermit } from '../../src/platform-permit.js';
3
+ import { platformPermission } from '@zhin.js/permission';
4
4
 
5
5
  export default defineAgentTool<{ guild_id: string }>({
6
6
  description: '获取 QQ 频道角色列表',
@@ -9,7 +9,7 @@ export default defineAgentTool<{ guild_id: string }>({
9
9
  }),
10
10
  adapter: 'qq',
11
11
  tags: ['qq'],
12
- permissions: [platformPermit('manage_roles')],
12
+ permissions: [platformPermission('qq', 'manage_roles')],
13
13
  async execute({ guild_id }: { guild_id: string }, context) {
14
14
  const client = context.$client;
15
15
  const roles = await client.getGuildRoles(guild_id);
@@ -0,0 +1,18 @@
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: '获取 QQ 频道中指定成员的详细信息',
7
+ inputSchema: z.object({
8
+ guild_id: z.string().describe('频道 ID'),
9
+ user_id: z.string().describe('用户 ID'),
10
+ }),
11
+ adapter: 'qq',
12
+ tags: ['qq'],
13
+ permissions: [platformPermission('qq', 'guild_admin')],
14
+ async execute({ guild_id, user_id }, context) {
15
+ const client = context.$client;
16
+ return client.getGuildMember(guild_id, user_id);
17
+ },
18
+ });
@@ -1,6 +1,6 @@
1
- import { defineAgentTool } from '@zhin.js/agent/tools';
1
+ import { defineAgentTool } from '@zhin.js/tool';
2
2
  import { z } from 'zod';
3
- import { platformPermit } from '../../src/platform-permit.js';
3
+ import { platformPermission } from '@zhin.js/permission';
4
4
 
5
5
  export default defineAgentTool<{ guild_id: string; user_id: string }>({
6
6
  description: '获取 QQ 频道中指定成员的详细信息',
@@ -10,7 +10,7 @@ export default defineAgentTool<{ guild_id: string; user_id: string }>({
10
10
  }),
11
11
  adapter: 'qq',
12
12
  tags: ['qq'],
13
- permissions: [platformPermit('guild_admin')],
13
+ permissions: [platformPermission('qq', 'guild_admin')],
14
14
  async execute({ guild_id, user_id }: { guild_id: string; user_id: string }, context) {
15
15
  const client = context.$client;
16
16
  return client.getGuildMember(guild_id, user_id);
@@ -0,0 +1,21 @@
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: '移除成员的 QQ 频道角色',
7
+ inputSchema: z.object({
8
+ guild_id: z.string().describe('频道 ID'),
9
+ channel_id: z.string().describe('子频道 ID'),
10
+ user_id: z.string().describe('用户 ID'),
11
+ role_id: z.string().describe('角色 ID'),
12
+ }),
13
+ adapter: 'qq',
14
+ tags: ['qq'],
15
+ permissions: [platformPermission('qq', 'manage_roles')],
16
+ async execute({ guild_id, channel_id, user_id, role_id }, context) {
17
+ const client = context.$client;
18
+ const success = await client.removeMemberRole(guild_id, channel_id, user_id, role_id);
19
+ return { success, message: success ? '已移除成员的角色' : '操作失败' };
20
+ },
21
+ });