@zhin.js/adapter-napcat 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 (108) hide show
  1. package/CHANGELOG.md +96 -0
  2. package/README.md +11 -8
  3. package/adapters/{napcat.js → napcat/index.js} +10 -10
  4. package/adapters/{napcat.ts → napcat/index.ts} +13 -13
  5. package/agents/napcat/agent.json +20 -0
  6. package/agents/napcat/boundaries.md +3 -0
  7. package/agents/napcat/conventions.md +3 -0
  8. package/agents/napcat/skills/napcat-account/SKILL.md +25 -0
  9. package/agents/napcat/skills/napcat-account/tools/delete_friend/index.js +18 -0
  10. package/{agent/tools/delete_friend.ts → agents/napcat/skills/napcat-account/tools/delete_friend/index.ts} +1 -1
  11. package/agents/napcat/skills/napcat-account/tools/get_user_status/index.js +16 -0
  12. package/{agent/tools/get_user_status.ts → agents/napcat/skills/napcat-account/tools/get_user_status/index.ts} +1 -1
  13. package/agents/napcat/skills/napcat-account/tools/send_like/index.js +18 -0
  14. package/{agent/tools/send_like.ts → agents/napcat/skills/napcat-account/tools/send_like/index.ts} +1 -1
  15. package/agents/napcat/skills/napcat-account/tools/set_avatar/index.js +17 -0
  16. package/{agent/tools/set_avatar.ts → agents/napcat/skills/napcat-account/tools/set_avatar/index.ts} +1 -1
  17. package/agents/napcat/skills/napcat-account/tools/set_online_status/index.js +18 -0
  18. package/{agent/tools/set_online_status.ts → agents/napcat/skills/napcat-account/tools/set_online_status/index.ts} +1 -1
  19. package/agents/napcat/skills/napcat-account/tools/set_profile/index.js +21 -0
  20. package/{agent/tools/set_profile.ts → agents/napcat/skills/napcat-account/tools/set_profile/index.ts} +1 -1
  21. package/agents/napcat/skills/napcat-account/tools/set_signature/index.js +17 -0
  22. package/{agent/tools/set_signature.ts → agents/napcat/skills/napcat-account/tools/set_signature/index.ts} +1 -1
  23. package/agents/napcat/skills/napcat-files-history/SKILL.md +22 -0
  24. package/agents/napcat/skills/napcat-files-history/tools/download_file/index.js +17 -0
  25. package/{agent/tools/download_file.ts → agents/napcat/skills/napcat-files-history/tools/download_file/index.ts} +1 -1
  26. package/agents/napcat/skills/napcat-files-history/tools/get_friend_msg_history/index.js +18 -0
  27. package/{agent/tools/get_friend_msg_history.ts → agents/napcat/skills/napcat-files-history/tools/get_friend_msg_history/index.ts} +1 -1
  28. package/agents/napcat/skills/napcat-files-history/tools/get_group_file_url/index.js +19 -0
  29. package/{agent/tools/get_group_file_url.ts → agents/napcat/skills/napcat-files-history/tools/get_group_file_url/index.ts} +1 -1
  30. package/agents/napcat/skills/napcat-files-history/tools/get_group_msg_history/index.js +19 -0
  31. package/{agent/tools/get_group_msg_history.ts → agents/napcat/skills/napcat-files-history/tools/get_group_msg_history/index.ts} +1 -1
  32. package/agents/napcat/skills/napcat-files-history/tools/get_group_root_files/index.js +17 -0
  33. package/{agent/tools/get_group_root_files.ts → agents/napcat/skills/napcat-files-history/tools/get_group_root_files/index.ts} +1 -1
  34. package/agents/napcat/skills/napcat-files-history/tools/upload_group_file/index.js +21 -0
  35. package/{agent/tools/upload_group_file.ts → agents/napcat/skills/napcat-files-history/tools/upload_group_file/index.ts} +1 -1
  36. package/agents/napcat/skills/napcat-group-content/SKILL.md +21 -0
  37. package/agents/napcat/skills/napcat-group-content/tools/del_group_notice/index.js +20 -0
  38. package/{agent/tools/del_group_notice.ts → agents/napcat/skills/napcat-group-content/tools/del_group_notice/index.ts} +1 -1
  39. package/agents/napcat/skills/napcat-group-content/tools/delete_essence_msg/index.js +19 -0
  40. package/{agent/tools/delete_essence_msg.ts → agents/napcat/skills/napcat-group-content/tools/delete_essence_msg/index.ts} +1 -1
  41. package/agents/napcat/skills/napcat-group-content/tools/get_essence_list/index.js +17 -0
  42. package/{agent/tools/get_essence_list.ts → agents/napcat/skills/napcat-group-content/tools/get_essence_list/index.ts} +1 -1
  43. package/agents/napcat/skills/napcat-group-content/tools/get_group_notice/index.js +17 -0
  44. package/{agent/tools/get_group_notice.ts → agents/napcat/skills/napcat-group-content/tools/get_group_notice/index.ts} +1 -1
  45. package/agents/napcat/skills/napcat-group-content/tools/send_group_notice/index.js +21 -0
  46. package/{agent/tools/send_group_notice.ts → agents/napcat/skills/napcat-group-content/tools/send_group_notice/index.ts} +1 -1
  47. package/agents/napcat/skills/napcat-group-content/tools/set_essence_msg/index.js +19 -0
  48. package/{agent/tools/set_essence_msg.ts → agents/napcat/skills/napcat-group-content/tools/set_essence_msg/index.ts} +1 -1
  49. package/agents/napcat/skills/napcat-group-settings/SKILL.md +23 -0
  50. package/agents/napcat/skills/napcat-group-settings/tools/get_group_info_ex/index.js +17 -0
  51. package/{agent/tools/get_group_info_ex.ts → agents/napcat/skills/napcat-group-settings/tools/get_group_info_ex/index.ts} +1 -1
  52. package/agents/napcat/skills/napcat-group-settings/tools/get_group_shut_list/index.js +17 -0
  53. package/{agent/tools/get_group_shut_list.ts → agents/napcat/skills/napcat-group-settings/tools/get_group_shut_list/index.ts} +1 -1
  54. package/agents/napcat/skills/napcat-group-settings/tools/group_sign/index.js +18 -0
  55. package/{agent/tools/group_sign.ts → agents/napcat/skills/napcat-group-settings/tools/group_sign/index.ts} +1 -1
  56. package/agents/napcat/skills/napcat-group-settings/tools/set_group_portrait/index.js +20 -0
  57. package/{agent/tools/set_group_portrait.ts → agents/napcat/skills/napcat-group-settings/tools/set_group_portrait/index.ts} +1 -1
  58. package/agents/napcat/skills/napcat-group-settings/tools/set_title/index.js +21 -0
  59. package/{agent/tools/set_title.ts → agents/napcat/skills/napcat-group-settings/tools/set_title/index.ts} +1 -1
  60. package/agents/napcat/skills/napcat-media/SKILL.md +23 -0
  61. package/agents/napcat/skills/napcat-media/tools/ai_tts/index.js +19 -0
  62. package/{agent/tools/ai_tts.ts → agents/napcat/skills/napcat-media/tools/ai_tts/index.ts} +1 -1
  63. package/agents/napcat/skills/napcat-media/tools/get_ai_characters/index.js +17 -0
  64. package/{agent/tools/get_ai_characters.ts → agents/napcat/skills/napcat-media/tools/get_ai_characters/index.ts} +1 -1
  65. package/agents/napcat/skills/napcat-media/tools/get_mini_app_ark/index.js +20 -0
  66. package/{agent/tools/get_mini_app_ark.ts → agents/napcat/skills/napcat-media/tools/get_mini_app_ark/index.ts} +1 -1
  67. package/agents/napcat/skills/napcat-media/tools/ocr_image/index.js +16 -0
  68. package/{agent/tools/ocr_image.ts → agents/napcat/skills/napcat-media/tools/ocr_image/index.ts} +1 -1
  69. package/agents/napcat/skills/napcat-media/tools/translate/index.js +16 -0
  70. package/{agent/tools/translate.ts → agents/napcat/skills/napcat-media/tools/translate/index.ts} +1 -1
  71. package/agents/napcat/skills/napcat-messaging/SKILL.md +22 -0
  72. package/agents/napcat/skills/napcat-messaging/tools/forward_single_msg/index.js +22 -0
  73. package/{agent/tools/forward_single_msg.ts → agents/napcat/skills/napcat-messaging/tools/forward_single_msg/index.ts} +1 -1
  74. package/agents/napcat/skills/napcat-messaging/tools/mark_msg_as_read/index.js +17 -0
  75. package/{agent/tools/mark_msg_as_read.ts → agents/napcat/skills/napcat-messaging/tools/mark_msg_as_read/index.ts} +1 -1
  76. package/agents/napcat/skills/napcat-messaging/tools/send_forward_msg/index.js +19 -0
  77. package/{agent/tools/send_forward_msg.ts → agents/napcat/skills/napcat-messaging/tools/send_forward_msg/index.ts} +1 -1
  78. package/agents/napcat/skills/napcat-messaging/tools/send_poke/index.js +18 -0
  79. package/{agent/tools/send_poke.ts → agents/napcat/skills/napcat-messaging/tools/send_poke/index.ts} +1 -1
  80. package/agents/napcat/skills/napcat-messaging/tools/set_emoji_reaction/index.js +18 -0
  81. package/{agent/tools/set_emoji_reaction.ts → agents/napcat/skills/napcat-messaging/tools/set_emoji_reaction/index.ts} +1 -1
  82. package/agents/napcat/system.md +3 -0
  83. package/commands/{endpoint/add/[id].js → napcat/endpoint/add/[id]/index.js} +1 -1
  84. package/commands/napcat/endpoint/add/[id]/index.ts +3 -0
  85. package/{lib/napcat-endpoint-commands.js → commands/napcat/endpoint/definition.js} +4 -3
  86. package/{src/napcat-endpoint-commands.ts → commands/napcat/endpoint/definition.ts} +3 -3
  87. package/commands/{endpoint/list.js → napcat/endpoint/list/index.js} +1 -1
  88. package/commands/napcat/endpoint/list/index.ts +3 -0
  89. package/commands/{endpoint/remove/[id].js → napcat/endpoint/remove/[id]/index.js} +1 -1
  90. package/commands/napcat/endpoint/remove/[id]/index.ts +3 -0
  91. package/lib/index.d.ts +1 -1
  92. package/lib/napcat-runtime-state.js +1 -1
  93. package/lib/protocol.d.ts +5 -23
  94. package/lib/protocol.js +40 -27
  95. package/lib/wss-endpoint.d.ts +3 -0
  96. package/lib/wss-endpoint.js +51 -42
  97. package/package.json +33 -21
  98. package/schema.json +22 -1
  99. package/src/index.ts +0 -1
  100. package/src/napcat-runtime-state.ts +1 -1
  101. package/src/protocol.ts +47 -50
  102. package/src/wss-endpoint.ts +48 -43
  103. package/agent/skills/napcat.md +0 -311
  104. package/commands/endpoint/add/[id].ts +0 -3
  105. package/commands/endpoint/list.ts +0 -3
  106. package/commands/endpoint/remove/[id].ts +0 -3
  107. package/lib/napcat-endpoint-commands.d.ts +0 -1
  108. /package/{agent/PERMITS.md → PERMITS.md} +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,101 @@
1
1
  # @zhin.js/adapter-napcat
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
+ - 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.
20
+ - 40d2c8f: Reduce the default Agent Tool surface by moving process diagnostics into a Skill and splitting broad platform Skills into focused task domains. Restore ICQQ friend and group directory tools with `on-risk` approval and explicit owner, administrator, master, or trusted access.
21
+ - 4380cf9: Colocate adapter command definitions and Agent Skill handlers with their owning capabilities, and provide a shared validated platform permission constructor.
22
+ - e54ab63: Require one canonical expanded NapCat endpoint configuration. The protocol no longer reinterprets nested `endpoints` or reads endpoint identity from `process.env`, and reverse WebSocket connection heartbeat/cleanup now uses the shared endpoint lifecycle.
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
+ - Updated dependencies [c861789]
26
+ - Updated dependencies [1414ccb]
27
+ - Updated dependencies [743d470]
28
+ - Updated dependencies [62dee52]
29
+ - Updated dependencies [cd54131]
30
+ - Updated dependencies [244e475]
31
+ - Updated dependencies [a9e4a40]
32
+ - Updated dependencies [5855db7]
33
+ - Updated dependencies [ec921d2]
34
+ - Updated dependencies [8740059]
35
+ - Updated dependencies [63d1f7a]
36
+ - Updated dependencies [25a845a]
37
+ - Updated dependencies [103f2c3]
38
+ - Updated dependencies [9110ab8]
39
+ - Updated dependencies [cd2a888]
40
+ - Updated dependencies [eb3227a]
41
+ - Updated dependencies [b853dba]
42
+ - Updated dependencies [e561309]
43
+ - Updated dependencies [d4c6175]
44
+ - Updated dependencies [7a0e1ca]
45
+ - Updated dependencies [103b5d3]
46
+ - Updated dependencies [5a7a7f7]
47
+ - Updated dependencies [b076eae]
48
+ - Updated dependencies [535fed1]
49
+ - Updated dependencies [73a24b7]
50
+ - Updated dependencies [4380cf9]
51
+ - Updated dependencies [2dbbc15]
52
+ - Updated dependencies [1cb1163]
53
+ - Updated dependencies [be3061e]
54
+ - Updated dependencies [75f8332]
55
+ - Updated dependencies [81935e2]
56
+ - Updated dependencies [f9ed01b]
57
+ - Updated dependencies [ac0ab50]
58
+ - Updated dependencies [5140ce1]
59
+ - Updated dependencies [522d75f]
60
+ - Updated dependencies [a7611b3]
61
+ - Updated dependencies [8823044]
62
+ - Updated dependencies [379439b]
63
+ - Updated dependencies [11c9352]
64
+ - Updated dependencies [6b70e46]
65
+ - Updated dependencies [135ac91]
66
+ - Updated dependencies [140cf0f]
67
+ - Updated dependencies [251e4d2]
68
+ - Updated dependencies [203ad34]
69
+ - Updated dependencies [e6c5113]
70
+ - Updated dependencies [e0f6478]
71
+ - Updated dependencies [baef56b]
72
+ - Updated dependencies [698f16f]
73
+ - Updated dependencies [da0a8e3]
74
+ - Updated dependencies [2fd8017]
75
+ - Updated dependencies [5c3858e]
76
+ - Updated dependencies [33ea736]
77
+ - Updated dependencies [507d602]
78
+ - Updated dependencies [df9f76b]
79
+ - @zhin.js/core@1.1.37
80
+ - @zhin.js/tool@1.1.1
81
+ - @zhin.js/host-http@1.1.1
82
+ - @zhin.js/adapter@1.1.14
83
+ - @zhin.js/feature-kit@1.1.1
84
+ - @zhin.js/agent-feature@1.1.1
85
+ - @zhin.js/skill@1.1.1
86
+ - @zhin.js/logger@1.1.1
87
+ - @zhin.js/im-contract@1.1.1
88
+ - @zhin.js/permission@1.1.1
89
+
90
+ ## 1.1.1
91
+
92
+ ### Patch Changes
93
+
94
+ - 33b1582: Update vulnerable dependencies and replace unsafe HTML and protocol-text regular expressions with bounded scanners.
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
@@ -9,7 +9,7 @@ Zhin.js [NapCatQQ](https://github.com/NapNeko/NapCatQQ) 适配器(Plugin Runti
9
9
  - **正向 WebSocket**(`connection: ws`):应用连 NapCat WS
10
10
  - `access_token` 鉴权(Bearer + query)
11
11
  - 入站经 `Endpoint.emit(...)`(去重 + 自发过滤);出站 `send({ conversation, payload })`
12
- - 41 个 AI 工具(`agent/tools/`)
12
+ - 41 个 AI 工具(`tools/`)
13
13
 
14
14
  ## 安装
15
15
 
@@ -19,7 +19,7 @@ pnpm add @zhin.js/adapter-napcat
19
19
 
20
20
  ## Plugin Runtime
21
21
 
22
- - `@zhin.js/adapter` — 约定式 `adapters/napcat.ts`(`defineAdapter`)
22
+ - `@zhin.js/adapter` — 约定式 `adapters/napcat/index.ts`(`defineAdapter`)
23
23
  - `@zhin.js/core` — `Endpoint.emit(...)` 入站、`outboundMessageToken` 出站
24
24
  - `zhin.js` — `plugin.ts`(`definePlugin`)
25
25
  - 配置经插件 `schema.json` 落到 `plugins.<instanceKey>`
@@ -43,11 +43,14 @@ plugins:
43
43
  reconnect_interval: 5000
44
44
  heartbeat_interval: 30000
45
45
  endpoints:
46
- - name: my-bot
46
+ - id: my-bot
47
47
  url: "ws://127.0.0.1:3001"
48
48
  access_token: "${NAPCAT_TOKEN}"
49
49
  ```
50
50
 
51
+ AdapterIndex 会把实例级连接默认值合并进每个 endpoint;协议实现只接收一份展开后的
52
+ endpoint 配置,不会从环境变量推断 endpoint id。
53
+
51
54
  根插件 `zhin.plugins`(或项目图)需引用 `@zhin.js/adapter-napcat`(`instanceKey: napcat`)。
52
55
 
53
56
  ## 连接方式
@@ -67,15 +70,15 @@ plugins:
67
70
 
68
71
  | 类别 | 路径 |
69
72
  |------|------|
70
- | Permit 词汇 | `agent/PERMITS.md` |
71
- | 平台工具 | `agent/tools/*.ts` |
72
- | 技能说明 | `agent/skills/napcat.md` |
73
+ | Permit 词汇 | `PERMITS.md` |
74
+ | 平台工具 | `tools/<name>/index.ts` |
75
+ | 技能说明 | `agents/napcat/skills/napcat-*/SKILL.md`(按消息、群内容、群设置、文件历史、媒体和账号拆分) |
73
76
 
74
77
  ## 迁移说明(Plugin Runtime)
75
78
 
76
79
  - **notice / request / meta 侧事件**:经 the unified `Endpoint.emit(...)` ingress 归一后分发到 `handlers`(`notice.receive` / `request.receive` / `system.receive`),请求带 `$approve` / `$reject`。消息仍走 `outboundMessageToken`。
77
- - **群管工具暂未迁移**:旧 Adapter 经 `createSceneManagementTools` 注册踢人 / 禁言 / 群名片等成套 agent 工具;迁移后 `agent/tools/` 仅覆盖 NapCat 扩展 API,其余群管能力可通过 `callApi`(如 `set_group_kick`、`set_group_ban`)作为逃生舱调用。
78
- - **平台权限门禁**:`plugin.ts` setup 已注册 `registerDefaultScenePlatformPermitChecker('napcat')`,`scene_admin` / `scene_owner` 依据入站 metadata 中的 sender `role`(owner / admin)判定。
80
+ - **群管工具暂未迁移**:旧 Adapter 经 `createSceneManagementTools` 注册踢人 / 禁言 / 群名片等成套 agent 工具;迁移后 `tools/` 仅覆盖 NapCat 扩展 API,其余群管能力可通过 `callApi`(如 `set_group_kick`、`set_group_ban`)作为逃生舱调用。
81
+ - **平台权限门禁**:`plugin.ts` setup 通过 generation-owned `permissionHostToken` 调用 `host.registerPlatform('napcat', createSceneRolePlatformChecker())`,`scene_admin` / `scene_owner` 依据入站 metadata 中的 sender `role`(owner / admin)判定。
79
82
 
80
83
  ## 文档链接
81
84
 
@@ -1,17 +1,17 @@
1
1
  // Generated by build-plugin-runtime-entries.mjs. Do not edit.
2
2
  /**
3
- * Convention entry: discover `adapters/napcat.ts` → defineAdapter.
3
+ * Convention entry: discover `adapters/napcat/index.ts` → defineAdapter.
4
4
  */
5
5
  import { defineAdapter } from 'zhin.js/adapter';
6
6
  import { httpHostToken } from '@zhin.js/host-http';
7
- import { NapCatHttpEndpoint } from "../lib/http-endpoint.js";
8
- import { resolveNapCatConfig } from "../lib/protocol.js";
9
- import { NapCatWsEndpoint } from "../lib/ws-endpoint.js";
10
- import { NapCatWssEndpoint } from "../lib/wss-endpoint.js";
11
- import { napcatRuntimeStateToken } from "../lib/napcat-runtime-state.js";
12
- export { NapCatHttpEndpoint, } from "../lib/http-endpoint.js";
13
- export { NapCatWsEndpoint, } from "../lib/ws-endpoint.js";
14
- export { NapCatWssEndpoint, } from "../lib/wss-endpoint.js";
7
+ import { NapCatHttpEndpoint } from "../../lib/http-endpoint.js";
8
+ import { resolveNapCatConfig } from "../../lib/protocol.js";
9
+ import { NapCatWsEndpoint } from "../../lib/ws-endpoint.js";
10
+ import { NapCatWssEndpoint } from "../../lib/wss-endpoint.js";
11
+ import { napcatRuntimeStateToken } from "../../lib/napcat-runtime-state.js";
12
+ export { NapCatHttpEndpoint, } from "../../lib/http-endpoint.js";
13
+ export { NapCatWsEndpoint, } from "../../lib/ws-endpoint.js";
14
+ export { NapCatWssEndpoint, } from "../../lib/wss-endpoint.js";
15
15
  export default defineAdapter({
16
16
  capabilities: ['inbound', 'outbound'],
17
17
  operations: ['recall'],
@@ -23,7 +23,7 @@ export default defineAdapter({
23
23
  },
24
24
  create(context) {
25
25
  const config = resolveNapCatConfig(context.config);
26
- // 注册到插件运行时状态(napcat.endpoint list 的"运行中"数据源)
26
+ // 注册到插件运行时状态(napcat endpoint list 的"运行中"数据源)
27
27
  context.use(napcatRuntimeStateToken).endpoints.set(config.id, {
28
28
  id: config.id,
29
29
  mode: config.connection,
@@ -1,35 +1,35 @@
1
1
  /**
2
- * Convention entry: discover `adapters/napcat.ts` → defineAdapter.
2
+ * Convention entry: discover `adapters/napcat/index.ts` → defineAdapter.
3
3
  */
4
4
  import { defineAdapter } from 'zhin.js/adapter';
5
5
  import { httpHostToken } from '@zhin.js/host-http';
6
- import { NapCatHttpEndpoint } from '../src/http-endpoint.js';
7
- import { resolveNapCatConfig, type NapCatAdapterConfig } from '../src/protocol.js';
8
- import { NapCatWsEndpoint } from '../src/ws-endpoint.js';
9
- import { NapCatWssEndpoint } from '../src/wss-endpoint.js';
10
- import { napcatRuntimeStateToken } from '../src/napcat-runtime-state.js';
6
+ import { NapCatHttpEndpoint } from '../../src/http-endpoint.js';
7
+ import { resolveNapCatConfig, type NapCatEndpointConfig } from '../../src/protocol.js';
8
+ import { NapCatWsEndpoint } from '../../src/ws-endpoint.js';
9
+ import { NapCatWssEndpoint } from '../../src/wss-endpoint.js';
10
+ import { napcatRuntimeStateToken } from '../../src/napcat-runtime-state.js';
11
11
 
12
12
  export {
13
13
  NapCatHttpEndpoint,
14
14
  type NapCatHttpEndpointOptions,
15
- } from '../src/http-endpoint.js';
15
+ } from '../../src/http-endpoint.js';
16
16
  export {
17
17
  NapCatWsEndpoint,
18
18
  type NapCatWsEndpointOptions,
19
- } from '../src/ws-endpoint.js';
19
+ } from '../../src/ws-endpoint.js';
20
20
  export {
21
21
  NapCatWssEndpoint,
22
22
  type NapCatWssEndpointOptions,
23
- } from '../src/wss-endpoint.js';
24
- export type { NapCatWsSocket, NapCatWsCreateOptions } from '../src/ws-types.js';
23
+ } from '../../src/wss-endpoint.js';
24
+ export type { NapCatWsSocket, NapCatWsCreateOptions } from '../../src/ws-types.js';
25
25
 
26
26
  declare module '@zhin.js/core' {
27
27
  interface AdapterEndpoints {
28
- napcat: import('../src/ws-endpoint.js').NapCatWsEndpoint;
28
+ napcat: import('../../src/ws-endpoint.js').NapCatWsEndpoint;
29
29
  }
30
30
  }
31
31
 
32
- export default defineAdapter<NapCatAdapterConfig>({
32
+ export default defineAdapter<NapCatEndpointConfig>({
33
33
  capabilities: ['inbound', 'outbound'],
34
34
  operations: ['recall'],
35
35
  // OneBot file 参数原生消费 url / base64:// 媒体,file:// 本地路径由 NapCat 侧读盘;
@@ -40,7 +40,7 @@ export default defineAdapter<NapCatAdapterConfig>({
40
40
  },
41
41
  create(context) {
42
42
  const config = resolveNapCatConfig(context.config);
43
- // 注册到插件运行时状态(napcat.endpoint list 的"运行中"数据源)
43
+ // 注册到插件运行时状态(napcat endpoint list 的"运行中"数据源)
44
44
  context.use(napcatRuntimeStateToken).endpoints.set(config.id, {
45
45
  id: config.id,
46
46
  mode: config.connection,
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "NAPCAT Platform Agent",
3
+ "version": "1.0.0",
4
+ "description": "Handles napcat platform-specific operations and progressively loads only the required platform Skill.",
5
+ "trigger_rules": {
6
+ "file_patterns": [],
7
+ "keywords": [
8
+ "napcat",
9
+ "adapter:napcat"
10
+ ]
11
+ },
12
+ "entry_points": [
13
+ "system.md",
14
+ "boundaries.md",
15
+ "conventions.md"
16
+ ],
17
+ "platforms": [
18
+ "napcat"
19
+ ]
20
+ }
@@ -0,0 +1,3 @@
1
+ # Boundaries
2
+
3
+ Operate only on the active napcat 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,25 @@
1
+ ---
2
+ name: napcat-account
3
+ platforms:
4
+ - napcat
5
+ description: NapCatQQ 账号状态、资料、头像、签名、点赞与好友关系能力。
6
+ keywords:
7
+ - "napcat"
8
+ - "账号"
9
+ - "资料"
10
+ - "头像"
11
+ - "签名"
12
+ - "好友"
13
+ tools:
14
+ - "send_like"
15
+ - "get_user_status"
16
+ - "set_profile"
17
+ - "set_avatar"
18
+ - "set_online_status"
19
+ - "set_signature"
20
+ - "delete_friend"
21
+ ---
22
+
23
+ # napcat-account
24
+
25
+ 账号资料和好友关系属于高影响状态。先查询目标,修改与删除操作必须遵守审批策略。
@@ -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
+ export default defineAgentTool({
5
+ description: '删除好友。',
6
+ inputSchema: z.object({
7
+ user_id: z.number().describe('好友 QQ 号'),
8
+ }),
9
+ adapter: 'napcat',
10
+ tags: ['napcat', 'qq'],
11
+ keywords: ['删除好友', 'delete friend', '删好友'],
12
+ permissions: ['platform(napcat,scene_admin)'],
13
+ async execute({ user_id }, context) {
14
+ const endpoint = context.$client;
15
+ await endpoint.deleteFriend(user_id);
16
+ return { success: true };
17
+ },
18
+ });
@@ -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<{ user_id: number }>({
@@ -0,0 +1,16 @@
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: '获取用户在线状态。',
6
+ inputSchema: z.object({
7
+ user_id: z.number().describe('目标 QQ 号'),
8
+ }),
9
+ adapter: 'napcat',
10
+ tags: ['napcat', 'qq'],
11
+ keywords: ['在线状态', '用户状态', 'online status'],
12
+ async execute({ user_id }, context) {
13
+ const endpoint = context.$client;
14
+ return endpoint.ncGetUserStatus(user_id);
15
+ },
16
+ });
@@ -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<{ user_id: number }>({
@@ -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
+ export default defineAgentTool({
5
+ description: '给好友点赞(每人每天最多 10 次)。',
6
+ inputSchema: z.object({
7
+ user_id: z.number().describe('目标 QQ 号'),
8
+ times: z.number().optional().describe('点赞次数(1-10)'),
9
+ }),
10
+ adapter: 'napcat',
11
+ tags: ['napcat', 'qq'],
12
+ keywords: ['点赞', 'like', '赞', '好友赞'],
13
+ async execute({ user_id, times }, context) {
14
+ const endpoint = context.$client;
15
+ await endpoint.sendLike(user_id, times || 1);
16
+ return { success: true, message: `已给 ${user_id} 点赞 ${times || 1} 次` };
17
+ },
18
+ });
@@ -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<{ user_id: number; times?: number }>({
@@ -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
+ export default defineAgentTool({
5
+ description: '修改 QQ 头像。',
6
+ inputSchema: z.object({
7
+ file: z.string().describe('图片(URL 或 base64)'),
8
+ }),
9
+ adapter: 'napcat',
10
+ tags: ['napcat', 'qq'],
11
+ keywords: ['头像', 'avatar', '设置头像', '换头像'],
12
+ async execute({ file }, context) {
13
+ const endpoint = context.$client;
14
+ await endpoint.setQQAvatar(file);
15
+ return { success: true };
16
+ },
17
+ });
@@ -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<{ file: string }>({
@@ -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
+ export default defineAgentTool({
5
+ description: '设置在线状态(在线、隐身、忙碌等)。',
6
+ inputSchema: z.object({
7
+ status: z.number().describe('状态码(11=在线, 21=离开, 31=隐身, 41=忙碌, 50=请勿打扰, 60=Q我吧)'),
8
+ ext_status: z.number().optional().describe('扩展状态码'),
9
+ }),
10
+ adapter: 'napcat',
11
+ tags: ['napcat', 'qq'],
12
+ keywords: ['在线状态', '隐身', '忙碌', 'online', 'status'],
13
+ async execute({ status, ext_status }, context) {
14
+ const endpoint = context.$client;
15
+ await endpoint.setOnlineStatus(status, ext_status || 0);
16
+ return { success: true };
17
+ },
18
+ });
@@ -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<{ status: number; ext_status?: number }>({
@@ -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
+ export default defineAgentTool({
5
+ description: '修改 QQ 资料(昵称等)。',
6
+ inputSchema: z.object({
7
+ nickname: z.string().describe('昵称'),
8
+ company: z.string().optional().describe('公司(可选)'),
9
+ email: z.string().optional().describe('邮箱(可选)'),
10
+ college: z.string().optional().describe('学校(可选)'),
11
+ personal_note: z.string().optional().describe('个人说明(可选)'),
12
+ }),
13
+ adapter: 'napcat',
14
+ tags: ['napcat', 'qq'],
15
+ keywords: ['修改资料', '设置昵称', 'profile', 'set profile'],
16
+ async execute({ nickname, company, email, college, personal_note }, context) {
17
+ const endpoint = context.$client;
18
+ await endpoint.setQQProfile(nickname, company, email, college, personal_note);
19
+ return { success: true };
20
+ },
21
+ });
@@ -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<{ nickname: string; company?: string; email?: string; college?: string; personal_note?: string }>({
@@ -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
+ export default defineAgentTool({
5
+ description: '设置个人签名(个性签名)。',
6
+ inputSchema: z.object({
7
+ signature: z.string().describe('签名内容'),
8
+ }),
9
+ adapter: 'napcat',
10
+ tags: ['napcat', 'qq'],
11
+ keywords: ['签名', '个性签名', 'signature', 'longnick'],
12
+ async execute({ signature }, context) {
13
+ const endpoint = context.$client;
14
+ await endpoint.setSelfLongnick(signature);
15
+ return { success: true };
16
+ },
17
+ });
@@ -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<{ signature: string }>({
@@ -0,0 +1,22 @@
1
+ ---
2
+ name: napcat-files-history
3
+ platforms:
4
+ - napcat
5
+ description: NapCatQQ 群文件、下载地址和消息历史能力。
6
+ keywords:
7
+ - "napcat"
8
+ - "群文件"
9
+ - "下载"
10
+ - "消息历史"
11
+ tools:
12
+ - "upload_group_file"
13
+ - "get_group_file_url"
14
+ - "get_group_root_files"
15
+ - "download_file"
16
+ - "get_group_msg_history"
17
+ - "get_friend_msg_history"
18
+ ---
19
+
20
+ # napcat-files-history
21
+
22
+ 文件和历史记录可能包含敏感内容,只读取完成任务所需范围;上传前确认目标群和文件。
@@ -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
+ export default defineAgentTool({
5
+ description: '下载文件到 NapCat 缓存目录,返回本地路径。',
6
+ inputSchema: z.object({
7
+ url: z.string().describe('文件 URL'),
8
+ thread_count: z.number().optional().describe('下载线程数(可选,默认 1)'),
9
+ }),
10
+ adapter: 'napcat',
11
+ tags: ['napcat', 'qq'],
12
+ keywords: ['下载', 'download', '下载文件'],
13
+ async execute({ url, thread_count }, context) {
14
+ const endpoint = context.$client;
15
+ return endpoint.downloadFile(url, thread_count || 1);
16
+ },
17
+ });
@@ -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<{ url: string; thread_count?: number }>({
@@ -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
+ export default defineAgentTool({
5
+ description: '获取私聊消息历史记录。',
6
+ inputSchema: z.object({
7
+ user_id: z.number().describe('QQ 号'),
8
+ message_seq: z.number().optional().describe('起始消息序号(可选)'),
9
+ count: z.number().optional().describe('获取条数(可选)'),
10
+ }),
11
+ adapter: 'napcat',
12
+ tags: ['napcat', 'qq'],
13
+ keywords: ['私聊记录', '好友聊天记录', 'friend history'],
14
+ async execute({ user_id, message_seq, count }, context) {
15
+ const endpoint = context.$client;
16
+ return endpoint.getFriendMsgHistory(user_id, message_seq, count);
17
+ },
18
+ });
@@ -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<{ user_id: number; message_seq?: number; count?: number }>({
@@ -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
+ export default defineAgentTool({
5
+ description: '获取群文件下载链接。',
6
+ inputSchema: z.object({
7
+ group_id: z.number().describe('群号'),
8
+ file_id: z.string().describe('文件 ID'),
9
+ busid: z.number().describe('文件类型 ID'),
10
+ }),
11
+ adapter: 'napcat',
12
+ tags: ['napcat', 'qq'],
13
+ keywords: ['文件链接', 'file url', '下载文件'],
14
+ scopes: ['group'],
15
+ async execute({ group_id, file_id, busid }, context) {
16
+ const endpoint = context.$client;
17
+ return endpoint.getGroupFileUrl(group_id, file_id, busid);
18
+ },
19
+ });
@@ -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<{ group_id: number; file_id: string; busid: number }>({
@@ -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
+ export default defineAgentTool({
5
+ description: '获取群消息历史记录。',
6
+ inputSchema: z.object({
7
+ group_id: z.number().describe('群号'),
8
+ message_seq: z.number().optional().describe('起始消息序号(可选,不传从最新开始)'),
9
+ count: z.number().optional().describe('获取条数(可选)'),
10
+ }),
11
+ adapter: 'napcat',
12
+ tags: ['napcat', 'qq'],
13
+ keywords: ['群消息历史', '聊天记录', 'message history'],
14
+ scopes: ['group'],
15
+ async execute({ group_id, message_seq, count }, context) {
16
+ const endpoint = context.$client;
17
+ return endpoint.getGroupMsgHistory(group_id, message_seq, count);
18
+ },
19
+ });
@@ -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<{ group_id: number; message_seq?: number; count?: number }>({