@zhin.js/adapter-napcat 1.1.26 → 1.1.28

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 (90) hide show
  1. package/CHANGELOG.md +206 -0
  2. package/LICENSE +21 -0
  3. package/PERMITS.md +17 -3
  4. package/README.md +10 -6
  5. package/adapters/napcat/index.js +3 -0
  6. package/adapters/napcat/index.ts +3 -0
  7. package/agents/napcat/conversation.js +71 -0
  8. package/agents/napcat/conversation.ts +76 -0
  9. package/agents/napcat/media.js +49 -0
  10. package/agents/napcat/media.ts +44 -0
  11. package/agents/napcat/messages.js +32 -0
  12. package/agents/napcat/messages.ts +32 -0
  13. package/agents/napcat/skills/napcat-account/tools/delete_friend/index.js +1 -1
  14. package/agents/napcat/skills/napcat-account/tools/delete_friend/index.ts +1 -1
  15. package/agents/napcat/skills/napcat-account/tools/set_avatar/index.js +3 -1
  16. package/agents/napcat/skills/napcat-account/tools/set_avatar/index.ts +3 -1
  17. package/agents/napcat/skills/napcat-files-history/tools/download_file/index.js +3 -1
  18. package/agents/napcat/skills/napcat-files-history/tools/download_file/index.ts +3 -1
  19. package/agents/napcat/skills/napcat-group-content/tools/del_group_notice/index.js +5 -5
  20. package/agents/napcat/skills/napcat-group-content/tools/del_group_notice/index.ts +6 -6
  21. package/agents/napcat/skills/napcat-group-content/tools/delete_essence_msg/index.js +5 -3
  22. package/agents/napcat/skills/napcat-group-content/tools/delete_essence_msg/index.ts +6 -4
  23. package/agents/napcat/skills/napcat-group-content/tools/get_essence_list/index.js +5 -7
  24. package/agents/napcat/skills/napcat-group-content/tools/get_essence_list/index.ts +6 -8
  25. package/agents/napcat/skills/napcat-group-content/tools/get_group_notice/index.js +5 -7
  26. package/agents/napcat/skills/napcat-group-content/tools/get_group_notice/index.ts +6 -8
  27. package/agents/napcat/skills/napcat-group-content/tools/send_group_notice/index.js +9 -7
  28. package/agents/napcat/skills/napcat-group-content/tools/send_group_notice/index.ts +10 -9
  29. package/agents/napcat/skills/napcat-group-content/tools/set_essence_msg/index.js +5 -3
  30. package/agents/napcat/skills/napcat-group-content/tools/set_essence_msg/index.ts +6 -4
  31. package/agents/napcat/skills/napcat-group-files-history/tools/get_group_file_url/index.js +4 -5
  32. package/agents/napcat/skills/napcat-group-files-history/tools/get_group_file_url/index.ts +5 -6
  33. package/agents/napcat/skills/napcat-group-files-history/tools/get_group_msg_history/index.js +4 -5
  34. package/agents/napcat/skills/napcat-group-files-history/tools/get_group_msg_history/index.ts +5 -6
  35. package/agents/napcat/skills/napcat-group-files-history/tools/get_group_root_files/index.js +5 -7
  36. package/agents/napcat/skills/napcat-group-files-history/tools/get_group_root_files/index.ts +6 -8
  37. package/agents/napcat/skills/napcat-group-files-history/tools/upload_group_file/index.js +6 -5
  38. package/agents/napcat/skills/napcat-group-files-history/tools/upload_group_file/index.ts +8 -7
  39. package/agents/napcat/skills/napcat-group-media/tools/ai_tts/index.js +4 -5
  40. package/agents/napcat/skills/napcat-group-media/tools/ai_tts/index.ts +5 -6
  41. package/agents/napcat/skills/napcat-group-media/tools/get_ai_characters/index.js +5 -7
  42. package/agents/napcat/skills/napcat-group-media/tools/get_ai_characters/index.ts +6 -8
  43. package/agents/napcat/skills/napcat-group-settings/tools/get_group_info_ex/index.js +5 -7
  44. package/agents/napcat/skills/napcat-group-settings/tools/get_group_info_ex/index.ts +6 -8
  45. package/agents/napcat/skills/napcat-group-settings/tools/get_group_shut_list/index.js +5 -7
  46. package/agents/napcat/skills/napcat-group-settings/tools/get_group_shut_list/index.ts +6 -8
  47. package/agents/napcat/skills/napcat-group-settings/tools/group_sign/index.js +5 -7
  48. package/agents/napcat/skills/napcat-group-settings/tools/group_sign/index.ts +7 -9
  49. package/agents/napcat/skills/napcat-group-settings/tools/set_group_portrait/index.js +6 -5
  50. package/agents/napcat/skills/napcat-group-settings/tools/set_group_portrait/index.ts +7 -6
  51. package/agents/napcat/skills/napcat-group-settings/tools/set_title/index.js +5 -5
  52. package/agents/napcat/skills/napcat-group-settings/tools/set_title/index.ts +6 -6
  53. package/agents/napcat/skills/napcat-media/tools/ocr_image/index.js +4 -3
  54. package/agents/napcat/skills/napcat-media/tools/ocr_image/index.ts +5 -4
  55. package/agents/napcat/skills/napcat-messaging/tools/forward_single_msg/index.js +3 -1
  56. package/agents/napcat/skills/napcat-messaging/tools/forward_single_msg/index.ts +3 -1
  57. package/agents/napcat/skills/napcat-messaging/tools/send_forward_msg/index.js +12 -6
  58. package/agents/napcat/skills/napcat-messaging/tools/send_forward_msg/index.ts +13 -16
  59. package/agents/napcat/skills/napcat-messaging/tools/send_poke/index.js +10 -7
  60. package/agents/napcat/skills/napcat-messaging/tools/send_poke/index.ts +10 -8
  61. package/agents/napcat/skills/napcat-private-history/tools/get_friend_msg_history/index.js +4 -5
  62. package/agents/napcat/skills/napcat-private-history/tools/get_friend_msg_history/index.ts +5 -6
  63. package/lib/endpoint-management.js +37 -0
  64. package/lib/http-endpoint.d.ts +3 -0
  65. package/lib/http-endpoint.js +14 -20
  66. package/lib/index.d.ts +0 -1
  67. package/lib/index.js +0 -1
  68. package/lib/protocol.d.ts +6 -1
  69. package/lib/protocol.js +13 -0
  70. package/lib/ws-endpoint.js +3 -2
  71. package/lib/ws-types.d.ts +6 -0
  72. package/lib/ws-types.js +31 -0
  73. package/lib/wss-auth.d.ts +2 -2
  74. package/lib/wss-auth.js +3 -12
  75. package/lib/wss-endpoint.d.ts +1 -1
  76. package/lib/wss-endpoint.js +22 -21
  77. package/package.json +24 -28
  78. package/plugin.js +0 -5
  79. package/schema.json +0 -56
  80. package/src/endpoint-management.ts +33 -0
  81. package/src/http-endpoint.ts +11 -20
  82. package/src/index.ts +0 -2
  83. package/src/protocol.ts +14 -1
  84. package/src/ws-endpoint.ts +3 -1
  85. package/src/ws-types.ts +33 -0
  86. package/src/wss-auth.ts +4 -11
  87. package/src/wss-endpoint.ts +22 -22
  88. package/lib/webhook.d.ts +0 -2
  89. package/lib/webhook.js +0 -14
  90. package/src/webhook.ts +0 -16
@@ -1,6 +1,34 @@
1
1
  // Generated by build-plugin-runtime-entries.mjs. Do not edit.
2
2
  import { createMessages } from 'zhin.js/i18n';
3
3
  export const messages = createMessages({
4
+ "messageOutsideGroup": {
5
+ "zh-CN": "该消息不在当前群中",
6
+ "en": "The message is not in the current group"
7
+ },
8
+ "conversationRequired": {
9
+ "zh-CN": "此操作仅支持当前 QQ 群或私聊",
10
+ "en": "This operation requires the current QQ group or private chat"
11
+ },
12
+ "privateRequired": {
13
+ "zh-CN": "此操作仅支持当前私聊",
14
+ "en": "This operation requires the current private chat"
15
+ },
16
+ "messageOutsideConversation": {
17
+ "zh-CN": "该消息不在当前会话中",
18
+ "en": "The message is not in the current conversation"
19
+ },
20
+ "hostMediaRefused": {
21
+ "zh-CN": "{p0} 只能是 http(s) 链接、base64:// 数据或平台文件标识,不能是本机路径",
22
+ "en": "{p0} must be an http(s) URL, base64:// data or a platform file token, not a local path"
23
+ },
24
+ "forwardTooDeep": {
25
+ "zh-CN": "合并转发嵌套过深",
26
+ "en": "The merged forward is nested too deeply"
27
+ },
28
+ "groupRequired": {
29
+ "zh-CN": "此操作仅支持当前 QQ 群",
30
+ "en": "This operation requires the current QQ group"
31
+ },
4
32
  "likesSent": {
5
33
  "zh-CN": "已给 {p0} 点赞 {p1} 次",
6
34
  "en": "Sent {p1} likes to {p0}"
@@ -9,6 +37,10 @@ export const messages = createMessages({
9
37
  "zh-CN": "已设置 {p0} 头衔为 \"{p1}\"",
10
38
  "en": "Title for {p0} set to \"{p1}\""
11
39
  },
40
+ "pokeTargetRequired": {
41
+ "zh-CN": "群聊中请指定要戳的成员",
42
+ "en": "Name the group member to poke"
43
+ },
12
44
  "userPoked": {
13
45
  "zh-CN": "已戳 {p0}",
14
46
  "en": "Poked {p0}"
@@ -1,6 +1,34 @@
1
1
  import { createMessages } from 'zhin.js/i18n';
2
2
 
3
3
  export const messages = createMessages({
4
+ "messageOutsideGroup": {
5
+ "zh-CN": "该消息不在当前群中",
6
+ "en": "The message is not in the current group"
7
+ },
8
+ "conversationRequired": {
9
+ "zh-CN": "此操作仅支持当前 QQ 群或私聊",
10
+ "en": "This operation requires the current QQ group or private chat"
11
+ },
12
+ "privateRequired": {
13
+ "zh-CN": "此操作仅支持当前私聊",
14
+ "en": "This operation requires the current private chat"
15
+ },
16
+ "messageOutsideConversation": {
17
+ "zh-CN": "该消息不在当前会话中",
18
+ "en": "The message is not in the current conversation"
19
+ },
20
+ "hostMediaRefused": {
21
+ "zh-CN": "{p0} 只能是 http(s) 链接、base64:// 数据或平台文件标识,不能是本机路径",
22
+ "en": "{p0} must be an http(s) URL, base64:// data or a platform file token, not a local path"
23
+ },
24
+ "forwardTooDeep": {
25
+ "zh-CN": "合并转发嵌套过深",
26
+ "en": "The merged forward is nested too deeply"
27
+ },
28
+ "groupRequired": {
29
+ "zh-CN": "此操作仅支持当前 QQ 群",
30
+ "en": "This operation requires the current QQ group"
31
+ },
4
32
  "likesSent": {
5
33
  "zh-CN": "已给 {p0} 点赞 {p1} 次",
6
34
  "en": "Sent {p1} likes to {p0}"
@@ -9,6 +37,10 @@ export const messages = createMessages({
9
37
  "zh-CN": "已设置 {p0} 头衔为 \"{p1}\"",
10
38
  "en": "Title for {p0} set to \"{p1}\""
11
39
  },
40
+ "pokeTargetRequired": {
41
+ "zh-CN": "群聊中请指定要戳的成员",
42
+ "en": "Name the group member to poke"
43
+ },
12
44
  "userPoked": {
13
45
  "zh-CN": "已戳 {p0}",
14
46
  "en": "Poked {p0}"
@@ -9,7 +9,7 @@ export default defineAgentTool({
9
9
  adapter: 'napcat',
10
10
  tags: ['napcat', 'qq'],
11
11
  keywords: ['删除好友', 'delete friend', '删好友'],
12
- permissions: ['platform(napcat,scene_admin)'],
12
+ permissions: ['owner@endpoint'],
13
13
  async execute({ user_id }, context) {
14
14
  const endpoint = context.$client;
15
15
  await endpoint.deleteFriend(user_id);
@@ -9,7 +9,7 @@ export default defineAgentTool<{ user_id: number }>({
9
9
  adapter: 'napcat',
10
10
  tags: ['napcat', 'qq'],
11
11
  keywords: ['删除好友', 'delete friend', '删好友'],
12
- permissions: ['platform(napcat,scene_admin)'],
12
+ permissions: ['owner@endpoint'],
13
13
  async execute({ user_id }: { user_id: number }, context) {
14
14
  const endpoint = context.$client;
15
15
  await endpoint.deleteFriend(user_id);
@@ -2,13 +2,15 @@
2
2
  import { defineAgentTool } from '@zhin.js/tool';
3
3
  import { z } from 'zod';
4
4
  export default defineAgentTool({
5
- description: '修改 QQ 头像。',
5
+ description: '修改机器人账号的 QQ 头像(仅全局主人可用)。',
6
6
  inputSchema: z.object({
7
7
  file: z.string().describe('图片(URL 或 base64)'),
8
8
  }),
9
9
  adapter: 'napcat',
10
10
  tags: ['napcat', 'qq'],
11
11
  keywords: ['头像', 'avatar', '设置头像', '换头像'],
12
+ // `file` may be a host path (OneBot reads `file://`), and the avatar is the Bot account's identity.
13
+ permissions: ['owner@global'],
12
14
  async execute({ file }, context) {
13
15
  const endpoint = context.$client;
14
16
  await endpoint.setQQAvatar(file);
@@ -2,13 +2,15 @@ import { defineAgentTool } from '@zhin.js/tool';
2
2
  import { z } from 'zod';
3
3
 
4
4
  export default defineAgentTool<{ file: string }>({
5
- description: '修改 QQ 头像。',
5
+ description: '修改机器人账号的 QQ 头像(仅全局主人可用)。',
6
6
  inputSchema: z.object({
7
7
  file: z.string().describe('图片(URL 或 base64)'),
8
8
  }),
9
9
  adapter: 'napcat',
10
10
  tags: ['napcat', 'qq'],
11
11
  keywords: ['头像', 'avatar', '设置头像', '换头像'],
12
+ // `file` may be a host path (OneBot reads `file://`), and the avatar is the Bot account's identity.
13
+ permissions: ['owner@global'],
12
14
  async execute({ file }: { file: string }, context) {
13
15
  const endpoint = context.$client;
14
16
  await endpoint.setQQAvatar(file);
@@ -2,7 +2,7 @@
2
2
  import { defineAgentTool } from '@zhin.js/tool';
3
3
  import { z } from 'zod';
4
4
  export default defineAgentTool({
5
- description: '下载文件到 NapCat 缓存目录,返回本地路径。',
5
+ description: '下载文件到 NapCat 缓存目录,返回本地路径(写入宿主文件、由宿主发起网络请求,仅全局主人可用)。',
6
6
  inputSchema: z.object({
7
7
  url: z.string().describe('文件 URL'),
8
8
  thread_count: z.number().optional().describe('下载线程数(可选,默认 1)'),
@@ -10,6 +10,8 @@ export default defineAgentTool({
10
10
  adapter: 'napcat',
11
11
  tags: ['napcat', 'qq'],
12
12
  keywords: ['下载', 'download', '下载文件'],
13
+ // Fetches any URL from the host network and writes the host file system: host-global (ADR 0056 §2).
14
+ permissions: ['owner@global'],
13
15
  async execute({ url, thread_count }, context) {
14
16
  const endpoint = context.$client;
15
17
  return endpoint.downloadFile(url, thread_count || 1);
@@ -2,7 +2,7 @@ import { defineAgentTool } from '@zhin.js/tool';
2
2
  import { z } from 'zod';
3
3
 
4
4
  export default defineAgentTool<{ url: string; thread_count?: number }>({
5
- description: '下载文件到 NapCat 缓存目录,返回本地路径。',
5
+ description: '下载文件到 NapCat 缓存目录,返回本地路径(写入宿主文件、由宿主发起网络请求,仅全局主人可用)。',
6
6
  inputSchema: z.object({
7
7
  url: z.string().describe('文件 URL'),
8
8
  thread_count: z.number().optional().describe('下载线程数(可选,默认 1)'),
@@ -10,6 +10,8 @@ export default defineAgentTool<{ url: string; thread_count?: number }>({
10
10
  adapter: 'napcat',
11
11
  tags: ['napcat', 'qq'],
12
12
  keywords: ['下载', 'download', '下载文件'],
13
+ // Fetches any URL from the host network and writes the host file system: host-global (ADR 0056 §2).
14
+ permissions: ['owner@global'],
13
15
  async execute({ url, thread_count }: { url: string; thread_count?: number }, context) {
14
16
  const endpoint = context.$client;
15
17
  return endpoint.downloadFile(url, thread_count || 1);
@@ -1,20 +1,20 @@
1
1
  // Generated by build-plugin-runtime-entries.mjs. Do not edit.
2
+ import { currentGroup } from '../../../../conversation.js';
2
3
  import { defineAgentTool } from '@zhin.js/tool';
3
4
  import { z } from 'zod';
4
5
  export default defineAgentTool({
5
- description: '删除群公告。',
6
+ description: '删除当前群的群公告。',
6
7
  inputSchema: z.object({
7
- group_id: z.number().describe('群号'),
8
8
  notice_id: z.string().describe('公告 ID'),
9
9
  }),
10
10
  adapter: 'napcat',
11
11
  tags: ['napcat', 'qq'],
12
12
  keywords: ['删除公告', 'delete notice'],
13
- permissions: ['platform(napcat,scene_admin)'],
13
+ permissions: ['platform:admin', 'bot:admin'],
14
14
  scopes: ['group'],
15
- async execute({ group_id, notice_id }, context) {
15
+ async execute({ notice_id }, context) {
16
16
  const endpoint = context.$client;
17
- await endpoint.deleteGroupNotice(group_id, notice_id);
17
+ await endpoint.deleteGroupNotice(currentGroup(context), notice_id);
18
18
  return { success: true };
19
19
  },
20
20
  });
@@ -1,20 +1,20 @@
1
+ import { currentGroup } from '../../../../conversation.js';
1
2
  import { defineAgentTool } from '@zhin.js/tool';
2
3
  import { z } from 'zod';
3
4
 
4
- export default defineAgentTool<{ group_id: number; notice_id: string }>({
5
- description: '删除群公告。',
5
+ export default defineAgentTool<{ notice_id: string }>({
6
+ description: '删除当前群的群公告。',
6
7
  inputSchema: z.object({
7
- group_id: z.number().describe('群号'),
8
8
  notice_id: z.string().describe('公告 ID'),
9
9
  }),
10
10
  adapter: 'napcat',
11
11
  tags: ['napcat', 'qq'],
12
12
  keywords: ['删除公告', 'delete notice'],
13
- permissions: ['platform(napcat,scene_admin)'],
13
+ permissions: ['platform:admin', 'bot:admin'],
14
14
  scopes: ['group'],
15
- async execute({ group_id, notice_id }: { group_id: number; notice_id: string }, context) {
15
+ async execute({ notice_id }, context) {
16
16
  const endpoint = context.$client;
17
- await endpoint.deleteGroupNotice(group_id, notice_id);
17
+ await endpoint.deleteGroupNotice(currentGroup(context), notice_id);
18
18
  return { success: true };
19
19
  },
20
20
  });
@@ -1,18 +1,20 @@
1
1
  // Generated by build-plugin-runtime-entries.mjs. Do not edit.
2
+ import { currentGroup, requireMessageInGroup } from '../../../../conversation.js';
2
3
  import { defineAgentTool } from '@zhin.js/tool';
3
4
  import { z } from 'zod';
4
5
  export default defineAgentTool({
5
- description: '移除群精华消息。',
6
+ description: '移除当前群中的精华消息。',
6
7
  inputSchema: z.object({
7
- message_id: z.number().describe('消息 ID'),
8
+ message_id: z.number().describe('当前群中的消息 ID'),
8
9
  }),
9
10
  adapter: 'napcat',
10
11
  tags: ['napcat', 'qq'],
11
12
  keywords: ['取消精华', '移除精华', 'delete essence'],
12
- permissions: ['platform(napcat,scene_admin)'],
13
+ permissions: ['platform:admin', 'bot:admin'],
13
14
  scopes: ['group'],
14
15
  async execute({ message_id }, context) {
15
16
  const endpoint = context.$client;
17
+ await requireMessageInGroup(context, currentGroup(context), message_id);
16
18
  await endpoint.deleteEssenceMsg(message_id);
17
19
  return { success: true };
18
20
  },
@@ -1,18 +1,20 @@
1
+ import { currentGroup, requireMessageInGroup } from '../../../../conversation.js';
1
2
  import { defineAgentTool } from '@zhin.js/tool';
2
3
  import { z } from 'zod';
3
4
 
4
5
  export default defineAgentTool<{ message_id: number }>({
5
- description: '移除群精华消息。',
6
+ description: '移除当前群中的精华消息。',
6
7
  inputSchema: z.object({
7
- message_id: z.number().describe('消息 ID'),
8
+ message_id: z.number().describe('当前群中的消息 ID'),
8
9
  }),
9
10
  adapter: 'napcat',
10
11
  tags: ['napcat', 'qq'],
11
12
  keywords: ['取消精华', '移除精华', 'delete essence'],
12
- permissions: ['platform(napcat,scene_admin)'],
13
+ permissions: ['platform:admin', 'bot:admin'],
13
14
  scopes: ['group'],
14
- async execute({ message_id }: { message_id: number }, context) {
15
+ async execute({ message_id }, context) {
15
16
  const endpoint = context.$client;
17
+ await requireMessageInGroup(context, currentGroup(context), message_id);
16
18
  await endpoint.deleteEssenceMsg(message_id);
17
19
  return { success: true };
18
20
  },
@@ -1,17 +1,15 @@
1
1
  // Generated by build-plugin-runtime-entries.mjs. Do not edit.
2
+ import { currentGroup } from "../../../../conversation.js";
2
3
  import { defineAgentTool } from '@zhin.js/tool';
3
4
  import { z } from 'zod';
4
5
  export default defineAgentTool({
5
- description: '获取群精华消息列表。',
6
- inputSchema: z.object({
7
- group_id: z.number().describe('群号'),
8
- }),
6
+ description: '获取当前群的精华消息列表。',
7
+ inputSchema: z.object({}),
9
8
  adapter: 'napcat',
10
9
  tags: ['napcat', 'qq'],
11
10
  keywords: ['精华列表', 'essence list'],
12
11
  scopes: ['group'],
13
- async execute({ group_id }, context) {
14
- const endpoint = context.$client;
15
- return endpoint.getEssenceMsgList(group_id);
12
+ async execute(_input, context) {
13
+ return context.$client.getEssenceMsgList(currentGroup(context));
16
14
  },
17
15
  });
@@ -1,17 +1,15 @@
1
+ import { currentGroup } from "../../../../conversation.js";
1
2
  import { defineAgentTool } from '@zhin.js/tool';
2
3
  import { z } from 'zod';
3
4
 
4
- export default defineAgentTool<{ group_id: number }>({
5
- description: '获取群精华消息列表。',
6
- inputSchema: z.object({
7
- group_id: z.number().describe('群号'),
8
- }),
5
+ export default defineAgentTool<Record<string, never>>({
6
+ description: '获取当前群的精华消息列表。',
7
+ inputSchema: z.object({}),
9
8
  adapter: 'napcat',
10
9
  tags: ['napcat', 'qq'],
11
10
  keywords: ['精华列表', 'essence list'],
12
11
  scopes: ['group'],
13
- async execute({ group_id }: { group_id: number }, context) {
14
- const endpoint = context.$client;
15
- return endpoint.getEssenceMsgList(group_id);
12
+ async execute(_input, context) {
13
+ return context.$client.getEssenceMsgList(currentGroup(context));
16
14
  },
17
15
  });
@@ -1,17 +1,15 @@
1
1
  // Generated by build-plugin-runtime-entries.mjs. Do not edit.
2
+ import { currentGroup } from "../../../../conversation.js";
2
3
  import { defineAgentTool } from '@zhin.js/tool';
3
4
  import { z } from 'zod';
4
5
  export default defineAgentTool({
5
- description: '获取群公告列表。',
6
- inputSchema: z.object({
7
- group_id: z.number().describe('群号'),
8
- }),
6
+ description: '获取当前群的公告列表。',
7
+ inputSchema: z.object({}),
9
8
  adapter: 'napcat',
10
9
  tags: ['napcat', 'qq'],
11
10
  keywords: ['群公告', '获取公告', 'get notice'],
12
11
  scopes: ['group'],
13
- async execute({ group_id }, context) {
14
- const endpoint = context.$client;
15
- return endpoint.getGroupNotice(group_id);
12
+ async execute(_input, context) {
13
+ return context.$client.getGroupNotice(currentGroup(context));
16
14
  },
17
15
  });
@@ -1,17 +1,15 @@
1
+ import { currentGroup } from "../../../../conversation.js";
1
2
  import { defineAgentTool } from '@zhin.js/tool';
2
3
  import { z } from 'zod';
3
4
 
4
- export default defineAgentTool<{ group_id: number }>({
5
- description: '获取群公告列表。',
6
- inputSchema: z.object({
7
- group_id: z.number().describe('群号'),
8
- }),
5
+ export default defineAgentTool<Record<string, never>>({
6
+ description: '获取当前群的公告列表。',
7
+ inputSchema: z.object({}),
9
8
  adapter: 'napcat',
10
9
  tags: ['napcat', 'qq'],
11
10
  keywords: ['群公告', '获取公告', 'get notice'],
12
11
  scopes: ['group'],
13
- async execute({ group_id }: { group_id: number }, context) {
14
- const endpoint = context.$client;
15
- return endpoint.getGroupNotice(group_id);
12
+ async execute(_input, context) {
13
+ return context.$client.getGroupNotice(currentGroup(context));
16
14
  },
17
15
  });
@@ -1,21 +1,23 @@
1
1
  // Generated by build-plugin-runtime-entries.mjs. Do not edit.
2
+ import { currentGroup } from '../../../../conversation.js';
3
+ import { requireRemoteMedia } from "../../../../media.js";
2
4
  import { defineAgentTool } from '@zhin.js/tool';
3
5
  import { z } from 'zod';
4
6
  export default defineAgentTool({
5
- description: '发送群公告。',
7
+ description: '在当前群发送群公告。',
6
8
  inputSchema: z.object({
7
- group_id: z.number().describe('群号'),
8
9
  content: z.string().describe('公告内容'),
9
- image: z.string().optional().describe('图片(URL 或 base64,可选)'),
10
+ image: z.string().optional().describe('图片(http(s) 链接或 base64://,可选;不接受本机路径)'),
10
11
  }),
11
12
  adapter: 'napcat',
12
13
  tags: ['napcat', 'qq'],
13
14
  keywords: ['群公告', 'notice', '公告', '发公告'],
14
- permissions: ['platform(napcat,scene_admin)'],
15
+ permissions: ['platform:admin', 'bot:admin'],
15
16
  scopes: ['group'],
16
- async execute({ group_id, content, image }, context) {
17
- const endpoint = context.$client;
18
- await endpoint.sendGroupNotice(group_id, content, image);
17
+ async execute({ content, image }, context) {
18
+ if (image)
19
+ requireRemoteMedia(context, image, 'image');
20
+ await context.$client.sendGroupNotice(currentGroup(context), content, image);
19
21
  return { success: true };
20
22
  },
21
23
  });
@@ -1,21 +1,22 @@
1
+ import { currentGroup } from '../../../../conversation.js';
2
+ import { requireRemoteMedia } from "../../../../media.js";
1
3
  import { defineAgentTool } from '@zhin.js/tool';
2
4
  import { z } from 'zod';
3
5
 
4
- export default defineAgentTool<{ group_id: number; content: string; image?: string }>({
5
- description: '发送群公告。',
6
+ export default defineAgentTool<{ content: string; image?: string }>({
7
+ description: '在当前群发送群公告。',
6
8
  inputSchema: z.object({
7
- group_id: z.number().describe('群号'),
8
9
  content: z.string().describe('公告内容'),
9
- image: z.string().optional().describe('图片(URL 或 base64,可选)'),
10
+ image: z.string().optional().describe('图片(http(s) 链接或 base64://,可选;不接受本机路径)'),
10
11
  }),
11
12
  adapter: 'napcat',
12
13
  tags: ['napcat', 'qq'],
13
14
  keywords: ['群公告', 'notice', '公告', '发公告'],
14
- permissions: ['platform(napcat,scene_admin)'],
15
+ permissions: ['platform:admin', 'bot:admin'],
15
16
  scopes: ['group'],
16
- async execute({ group_id, content, image }: { group_id: number; content: string; image?: string }, context) {
17
- const endpoint = context.$client;
18
- await endpoint.sendGroupNotice(group_id, content, image);
19
- return { success: true };
17
+ async execute({ content, image }, context) {
18
+ if (image) requireRemoteMedia(context, image, 'image');
19
+ await context.$client.sendGroupNotice(currentGroup(context), content, image);
20
+ return { success: true };
20
21
  },
21
22
  });
@@ -1,18 +1,20 @@
1
1
  // Generated by build-plugin-runtime-entries.mjs. Do not edit.
2
+ import { currentGroup, requireMessageInGroup } from '../../../../conversation.js';
2
3
  import { defineAgentTool } from '@zhin.js/tool';
3
4
  import { z } from 'zod';
4
5
  export default defineAgentTool({
5
- description: '设置群精华消息。',
6
+ description: '把当前群中的消息设为精华。',
6
7
  inputSchema: z.object({
7
- message_id: z.number().describe('消息 ID'),
8
+ message_id: z.number().describe('当前群中的消息 ID'),
8
9
  }),
9
10
  adapter: 'napcat',
10
11
  tags: ['napcat', 'qq'],
11
12
  keywords: ['精华', 'essence', '设精', '加精'],
12
- permissions: ['platform(napcat,scene_admin)'],
13
+ permissions: ['platform:admin', 'bot:admin'],
13
14
  scopes: ['group'],
14
15
  async execute({ message_id }, context) {
15
16
  const endpoint = context.$client;
17
+ await requireMessageInGroup(context, currentGroup(context), message_id);
16
18
  await endpoint.setEssenceMsg(message_id);
17
19
  return { success: true };
18
20
  },
@@ -1,18 +1,20 @@
1
+ import { currentGroup, requireMessageInGroup } from '../../../../conversation.js';
1
2
  import { defineAgentTool } from '@zhin.js/tool';
2
3
  import { z } from 'zod';
3
4
 
4
5
  export default defineAgentTool<{ message_id: number }>({
5
- description: '设置群精华消息。',
6
+ description: '把当前群中的消息设为精华。',
6
7
  inputSchema: z.object({
7
- message_id: z.number().describe('消息 ID'),
8
+ message_id: z.number().describe('当前群中的消息 ID'),
8
9
  }),
9
10
  adapter: 'napcat',
10
11
  tags: ['napcat', 'qq'],
11
12
  keywords: ['精华', 'essence', '设精', '加精'],
12
- permissions: ['platform(napcat,scene_admin)'],
13
+ permissions: ['platform:admin', 'bot:admin'],
13
14
  scopes: ['group'],
14
- async execute({ message_id }: { message_id: number }, context) {
15
+ async execute({ message_id }, context) {
15
16
  const endpoint = context.$client;
17
+ await requireMessageInGroup(context, currentGroup(context), message_id);
16
18
  await endpoint.setEssenceMsg(message_id);
17
19
  return { success: true };
18
20
  },
@@ -1,10 +1,10 @@
1
1
  // Generated by build-plugin-runtime-entries.mjs. Do not edit.
2
+ import { currentGroup } from "../../../../conversation.js";
2
3
  import { defineAgentTool } from '@zhin.js/tool';
3
4
  import { z } from 'zod';
4
5
  export default defineAgentTool({
5
- description: '获取群文件下载链接。',
6
+ description: '获取当前群的群文件下载链接。',
6
7
  inputSchema: z.object({
7
- group_id: z.number().describe('群号'),
8
8
  file_id: z.string().describe('文件 ID'),
9
9
  busid: z.number().describe('文件类型 ID'),
10
10
  }),
@@ -12,8 +12,7 @@ export default defineAgentTool({
12
12
  tags: ['napcat', 'qq'],
13
13
  keywords: ['文件链接', 'file url', '下载文件'],
14
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);
15
+ async execute({ file_id, busid }, context) {
16
+ return context.$client.getGroupFileUrl(currentGroup(context), file_id, busid);
18
17
  },
19
18
  });
@@ -1,10 +1,10 @@
1
+ import { currentGroup } from "../../../../conversation.js";
1
2
  import { defineAgentTool } from '@zhin.js/tool';
2
3
  import { z } from 'zod';
3
4
 
4
- export default defineAgentTool<{ group_id: number; file_id: string; busid: number }>({
5
- description: '获取群文件下载链接。',
5
+ export default defineAgentTool<{ file_id: string; busid: number }>({
6
+ description: '获取当前群的群文件下载链接。',
6
7
  inputSchema: z.object({
7
- group_id: z.number().describe('群号'),
8
8
  file_id: z.string().describe('文件 ID'),
9
9
  busid: z.number().describe('文件类型 ID'),
10
10
  }),
@@ -12,8 +12,7 @@ export default defineAgentTool<{ group_id: number; file_id: string; busid: numbe
12
12
  tags: ['napcat', 'qq'],
13
13
  keywords: ['文件链接', 'file url', '下载文件'],
14
14
  scopes: ['group'],
15
- async execute({ group_id, file_id, busid }: { group_id: number; file_id: string; busid: number }, context) {
16
- const endpoint = context.$client;
17
- return endpoint.getGroupFileUrl(group_id, file_id, busid);
15
+ async execute({ file_id, busid }, context) {
16
+ return context.$client.getGroupFileUrl(currentGroup(context), file_id, busid);
18
17
  },
19
18
  });
@@ -1,10 +1,10 @@
1
1
  // Generated by build-plugin-runtime-entries.mjs. Do not edit.
2
+ import { currentGroup } from "../../../../conversation.js";
2
3
  import { defineAgentTool } from '@zhin.js/tool';
3
4
  import { z } from 'zod';
4
5
  export default defineAgentTool({
5
- description: '获取群消息历史记录。',
6
+ description: '获取当前群的消息历史记录。',
6
7
  inputSchema: z.object({
7
- group_id: z.number().describe('群号'),
8
8
  message_seq: z.number().optional().describe('起始消息序号(可选,不传从最新开始)'),
9
9
  count: z.number().optional().describe('获取条数(可选)'),
10
10
  }),
@@ -12,8 +12,7 @@ export default defineAgentTool({
12
12
  tags: ['napcat', 'qq'],
13
13
  keywords: ['群消息历史', '聊天记录', 'message history'],
14
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);
15
+ async execute({ message_seq, count }, context) {
16
+ return context.$client.getGroupMsgHistory(currentGroup(context), message_seq, count);
18
17
  },
19
18
  });
@@ -1,10 +1,10 @@
1
+ import { currentGroup } from "../../../../conversation.js";
1
2
  import { defineAgentTool } from '@zhin.js/tool';
2
3
  import { z } from 'zod';
3
4
 
4
- export default defineAgentTool<{ group_id: number; message_seq?: number; count?: number }>({
5
- description: '获取群消息历史记录。',
5
+ export default defineAgentTool<{ message_seq?: number; count?: number }>({
6
+ description: '获取当前群的消息历史记录。',
6
7
  inputSchema: z.object({
7
- group_id: z.number().describe('群号'),
8
8
  message_seq: z.number().optional().describe('起始消息序号(可选,不传从最新开始)'),
9
9
  count: z.number().optional().describe('获取条数(可选)'),
10
10
  }),
@@ -12,8 +12,7 @@ export default defineAgentTool<{ group_id: number; message_seq?: number; count?:
12
12
  tags: ['napcat', 'qq'],
13
13
  keywords: ['群消息历史', '聊天记录', 'message history'],
14
14
  scopes: ['group'],
15
- async execute({ group_id, message_seq, count }: { group_id: number; message_seq?: number; count?: number }, context) {
16
- const endpoint = context.$client;
17
- return endpoint.getGroupMsgHistory(group_id, message_seq, count);
15
+ async execute({ message_seq, count }, context) {
16
+ return context.$client.getGroupMsgHistory(currentGroup(context), message_seq, count);
18
17
  },
19
18
  });
@@ -1,17 +1,15 @@
1
1
  // Generated by build-plugin-runtime-entries.mjs. Do not edit.
2
+ import { currentGroup } from "../../../../conversation.js";
2
3
  import { defineAgentTool } from '@zhin.js/tool';
3
4
  import { z } from 'zod';
4
5
  export default defineAgentTool({
5
- description: '获取群根目录文件列表。',
6
- inputSchema: z.object({
7
- group_id: z.number().describe('群号'),
8
- }),
6
+ description: '获取当前群的根目录文件列表。',
7
+ inputSchema: z.object({}),
9
8
  adapter: 'napcat',
10
9
  tags: ['napcat', 'qq'],
11
10
  keywords: ['群文件列表', 'group files'],
12
11
  scopes: ['group'],
13
- async execute({ group_id }, context) {
14
- const endpoint = context.$client;
15
- return endpoint.getGroupRootFiles(group_id);
12
+ async execute(_input, context) {
13
+ return context.$client.getGroupRootFiles(currentGroup(context));
16
14
  },
17
15
  });