@zhin.js/adapter-icqq 8.0.8 → 8.0.10

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 (87) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/README.md +36 -28
  3. package/adapters/icqq.js +4 -9
  4. package/adapters/icqq.ts +5 -14
  5. package/agent/PERMITS.md +2 -0
  6. package/lib/agent-prompt.js +17 -22
  7. package/lib/cq-message.d.ts +2 -2
  8. package/lib/cq-message.js +7 -2
  9. package/lib/endpoint.d.ts +4 -74
  10. package/lib/endpoint.js +348 -507
  11. package/lib/forward-msg.d.ts +7 -8
  12. package/lib/forward-msg.js +11 -24
  13. package/lib/icqq-agent-deps.d.ts +3 -15
  14. package/lib/icqq-agent-deps.js +0 -5
  15. package/lib/icqq-endpoint-commands.js +4 -13
  16. package/lib/icqq-guild.d.ts +15 -11
  17. package/lib/icqq-guild.js +9 -17
  18. package/lib/icqq-inbound.d.ts +20 -20
  19. package/lib/icqq-inbound.js +9 -9
  20. package/lib/icqq-inbox.d.ts +2 -10
  21. package/lib/index.d.ts +2 -3
  22. package/lib/index.js +2 -3
  23. package/lib/outbound-media.d.ts +3 -8
  24. package/lib/outbound-media.js +3 -8
  25. package/lib/protocol.d.ts +38 -57
  26. package/lib/protocol.js +67 -21
  27. package/lib/types.d.ts +4 -40
  28. package/lib/types.js +0 -5
  29. package/package.json +26 -14
  30. package/plugin.js +6 -1
  31. package/schema.json +119 -61
  32. package/src/agent-prompt.ts +17 -22
  33. package/src/cq-message.ts +7 -2
  34. package/src/endpoint.ts +359 -600
  35. package/src/forward-msg.ts +12 -26
  36. package/src/icqq-agent-deps.ts +3 -17
  37. package/src/icqq-endpoint-commands.ts +4 -13
  38. package/src/icqq-guild.ts +16 -25
  39. package/src/icqq-inbound.ts +26 -26
  40. package/src/icqq-inbox.ts +2 -10
  41. package/src/icqqjs-icqq.d.ts +88 -0
  42. package/src/index.ts +2 -9
  43. package/src/outbound-media.ts +4 -9
  44. package/src/protocol.ts +108 -66
  45. package/src/types.ts +4 -41
  46. package/tools/announce.js +19 -0
  47. package/tools/announce.ts +18 -0
  48. package/tools/essence.js +24 -0
  49. package/{agent/tools → tools}/essence.ts +8 -8
  50. package/tools/friend_list.js +20 -0
  51. package/{agent/tools → tools}/friend_list.ts +7 -7
  52. package/tools/group_files.js +25 -0
  53. package/tools/group_files.ts +23 -0
  54. package/tools/group_invite.js +25 -0
  55. package/tools/group_invite.ts +22 -0
  56. package/tools/group_kick.js +28 -0
  57. package/tools/group_kick.ts +24 -0
  58. package/tools/group_list.js +21 -0
  59. package/{agent/tools → tools}/group_list.ts +7 -7
  60. package/tools/group_sign.js +21 -0
  61. package/tools/group_sign.ts +19 -0
  62. package/tools/list_muted.js +20 -0
  63. package/tools/list_muted.ts +19 -0
  64. package/tools/poke.js +19 -0
  65. package/tools/poke.ts +18 -0
  66. package/tools/send_user_like.js +28 -0
  67. package/tools/send_user_like.ts +25 -0
  68. package/tools/set_anonymous.js +23 -0
  69. package/tools/set_anonymous.ts +21 -0
  70. package/tools/set_mute.js +26 -0
  71. package/tools/set_mute.ts +23 -0
  72. package/tools/set_title.js +27 -0
  73. package/tools/set_title.ts +24 -0
  74. package/tools/user_info.js +17 -0
  75. package/tools/user_info.ts +16 -0
  76. package/agent/tools/announce.ts +0 -21
  77. package/agent/tools/group_files.ts +0 -27
  78. package/agent/tools/group_invite.ts +0 -20
  79. package/agent/tools/group_sign.ts +0 -19
  80. package/agent/tools/list_muted.ts +0 -22
  81. package/agent/tools/poke.ts +0 -20
  82. package/agent/tools/send_user_like.ts +0 -22
  83. package/agent/tools/set_anonymous.ts +0 -22
  84. package/agent/tools/set_title.ts +0 -25
  85. package/lib/ipc-client.d.ts +0 -73
  86. package/lib/ipc-client.js +0 -358
  87. package/src/ipc-client.ts +0 -417
@@ -1,20 +1,20 @@
1
- import { defineAgentTool } from '@zhin.js/agent/tools';
1
+ import { defineAgentTool } from '@zhin.js/tool';
2
2
  import { z } from 'zod';
3
- import { getIcqqAgentDeps } from '../../src/icqq-agent-deps.js';
3
+ import { getIcqqAgentDeps } from '../src/icqq-agent-deps.js';
4
4
  export default defineAgentTool<{ endpoint_id: string }>({
5
5
  description: '获取 Endpoint 的 QQ 群列表',
6
6
  inputSchema: z.object({
7
7
  endpoint_id: z.string().describe('Endpoint 名称'),
8
8
  }),
9
9
  platforms: ['icqq'],
10
- tags: ['icqq'],
11
- async execute({ endpoint_id }: { endpoint_id: string }) {
10
+ approval: 'never',
11
+ async execute({ endpoint_id }: { endpoint_id: string }) {
12
12
  const endpoint = getIcqqAgentDeps().getEndpoint(endpoint_id);
13
- const groups = Array.from(endpoint.groups.values()).map((g) => ({
13
+ const gl = endpoint.gl;
14
+ const groups = Array.from(gl.values()).map((g) => ({
14
15
  group_id: g.group_id, group_name: g.group_name,
15
16
  member_count: g.member_count, max_member_count: g.max_member_count,
16
17
  }));
17
- return { groups: groups.slice(0, 50), count: endpoint.groups.size };
18
+ return { groups: groups.slice(0, 50), count: gl.size };
18
19
  },
19
20
  });
20
-
@@ -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 { getIcqqAgentDeps } from "../lib/icqq-agent-deps.js";
5
+ export default defineAgentTool({
6
+ description: 'QQ 群签到/打卡',
7
+ inputSchema: z.object({
8
+ endpoint_id: z.string().describe('Endpoint QQ号'),
9
+ group_id: z.number().describe('目标群号'),
10
+ }),
11
+ platforms: ['icqq'],
12
+ approval: 'never',
13
+ async execute({ endpoint_id, group_id }) {
14
+ const endpoint = getIcqqAgentDeps().getEndpoint(endpoint_id);
15
+ const groupInfo = endpoint.pickGroup(group_id);
16
+ if (!groupInfo)
17
+ return { success: false, message: '目标群不存在' };
18
+ await endpoint.sendGroupSign(group_id);
19
+ return { success: true, message: '群签到成功' };
20
+ },
21
+ });
@@ -0,0 +1,19 @@
1
+ import { defineAgentTool } from '@zhin.js/tool';
2
+ import { z } from 'zod';
3
+ import { getIcqqAgentDeps } from '../src/icqq-agent-deps.js';
4
+ export default defineAgentTool<{ endpoint_id: string; group_id: number }>({
5
+ description: 'QQ 群签到/打卡',
6
+ inputSchema: z.object({
7
+ endpoint_id: z.string().describe('Endpoint QQ号'),
8
+ group_id: z.number().describe('目标群号'),
9
+ }),
10
+ platforms: ['icqq'],
11
+ approval: 'never',
12
+ async execute({ endpoint_id, group_id }: { endpoint_id: string; group_id: number }) {
13
+ const endpoint = getIcqqAgentDeps().getEndpoint(endpoint_id);
14
+ const groupInfo= endpoint.pickGroup(group_id);
15
+ if(!groupInfo) return { success: false, message: '目标群不存在' };
16
+ await endpoint.sendGroupSign(group_id);
17
+ return { success: true, message: '群签到成功' };
18
+ },
19
+ });
@@ -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 { getIcqqAgentDeps } from "../lib/icqq-agent-deps.js";
5
+ export default defineAgentTool({
6
+ description: '查询 QQ 群中当前被禁言的成员列表',
7
+ inputSchema: z.object({
8
+ endpoint_id: z.string().describe('Endpoint QQ号'),
9
+ group_id: z.number().describe('目标群号'),
10
+ }),
11
+ platforms: ['icqq'],
12
+ permissions: ['role(master,admin)'],
13
+ async execute({ endpoint_id, group_id }) {
14
+ const endpoint = getIcqqAgentDeps().getEndpoint(endpoint_id);
15
+ const members = await endpoint.getGroupMemberList(group_id);
16
+ const now = Math.floor(Date.now() / 1000);
17
+ const muted = Array.from(members.values()).filter((m) => m.shutup_time > now);
18
+ return { muted_members: muted, count: muted.length };
19
+ },
20
+ });
@@ -0,0 +1,19 @@
1
+ import { defineAgentTool } from '@zhin.js/tool';
2
+ import { z } from 'zod';
3
+ import { getIcqqAgentDeps } from '../src/icqq-agent-deps.js';
4
+ export default defineAgentTool<{ endpoint_id: string; group_id: number }>({
5
+ description: '查询 QQ 群中当前被禁言的成员列表',
6
+ inputSchema: z.object({
7
+ endpoint_id: z.string().describe('Endpoint QQ号'),
8
+ group_id: z.number().describe('目标群号'),
9
+ }),
10
+ platforms: ['icqq'],
11
+ permissions: ['role(master,admin)'],
12
+ async execute({ endpoint_id, group_id }: { endpoint_id: string; group_id: number }) {
13
+ const endpoint = getIcqqAgentDeps().getEndpoint(endpoint_id);
14
+ const members = await endpoint.getGroupMemberList(group_id);
15
+ const now = Math.floor(Date.now() / 1000);
16
+ const muted = Array.from(members.values()).filter((m) => m.shutup_time > now);
17
+ return { muted_members: muted, count: muted.length };
18
+ },
19
+ });
package/tools/poke.js ADDED
@@ -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
+ import { getIcqqAgentDeps } from "../lib/icqq-agent-deps.js";
5
+ export default defineAgentTool({
6
+ description: '在 QQ 群中对某个成员执行戳一戳互动操作',
7
+ inputSchema: z.object({
8
+ endpoint_id: z.string().describe('Endpoint QQ号'),
9
+ group_id: z.number().describe('目标群号'),
10
+ user_id: z.number().describe('要戳的目标成员 QQ号'),
11
+ }),
12
+ platforms: ['icqq'],
13
+ approval: 'never',
14
+ async execute({ endpoint_id, group_id, user_id }) {
15
+ const endpoint = getIcqqAgentDeps().getEndpoint(endpoint_id);
16
+ await endpoint.sendGroupPoke(group_id, user_id);
17
+ return { success: true, message: `已戳了戳 ${user_id}` };
18
+ },
19
+ });
package/tools/poke.ts ADDED
@@ -0,0 +1,18 @@
1
+ import { defineAgentTool } from '@zhin.js/tool';
2
+ import { z } from 'zod';
3
+ import { getIcqqAgentDeps } from '../src/icqq-agent-deps.js';
4
+ export default defineAgentTool<{ endpoint_id: string; group_id: number; user_id: number }>({
5
+ description: '在 QQ 群中对某个成员执行戳一戳互动操作',
6
+ inputSchema: z.object({
7
+ endpoint_id: z.string().describe('Endpoint QQ号'),
8
+ group_id: z.number().describe('目标群号'),
9
+ user_id: z.number().describe('要戳的目标成员 QQ号'),
10
+ }),
11
+ platforms: ['icqq'],
12
+ approval: 'never',
13
+ async execute({ endpoint_id, group_id, user_id }: { endpoint_id: string; group_id: number; user_id: number }) {
14
+ const endpoint = getIcqqAgentDeps().getEndpoint(endpoint_id);
15
+ await endpoint.sendGroupPoke(group_id, user_id);
16
+ return { success: true, message: `已戳了戳 ${user_id}` };
17
+ },
18
+ });
@@ -0,0 +1,28 @@
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 { getIcqqAgentDeps } from "../lib/icqq-agent-deps.js";
5
+ export default defineAgentTool({
6
+ description: '尝试给用户点尽量多的赞',
7
+ inputSchema: z.object({
8
+ endpoint_id: z.string().describe('Endpoint QQ号'),
9
+ user_id: z.number().describe('要点赞的目标用户 QQ号'),
10
+ }),
11
+ platforms: ['icqq'],
12
+ approval: 'never',
13
+ async execute({ endpoint_id, user_id }) {
14
+ const endpoint = getIcqqAgentDeps().getEndpoint(endpoint_id);
15
+ const successArray = [];
16
+ await Promise.all([20, 20, 10].map(async (times) => {
17
+ try {
18
+ await endpoint.sendLike(user_id, times);
19
+ successArray.push(times);
20
+ }
21
+ catch { /* ignore */ }
22
+ }));
23
+ const successTimes = successArray.reduce((a, b) => a + b, 0);
24
+ if (!successTimes)
25
+ return { success: false, message: '点赞失败' };
26
+ return { success: true, message: `已给 ${user_id} 点赞 ${successTimes} 次` };
27
+ },
28
+ });
@@ -0,0 +1,25 @@
1
+ import { defineAgentTool } from '@zhin.js/tool';
2
+ import { z } from 'zod';
3
+ import { getIcqqAgentDeps } from '../src/icqq-agent-deps.js';
4
+ export default defineAgentTool<{ endpoint_id: string; user_id: number; times?: number }>({
5
+ description: '尝试给用户点尽量多的赞',
6
+ inputSchema: z.object({
7
+ endpoint_id: z.string().describe('Endpoint QQ号'),
8
+ user_id: z.number().describe('要点赞的目标用户 QQ号'),
9
+ }),
10
+ platforms: ['icqq'],
11
+ approval: 'never',
12
+ async execute({ endpoint_id, user_id }: { endpoint_id: string; user_id: number }) {
13
+ const endpoint = getIcqqAgentDeps().getEndpoint(endpoint_id);
14
+ const successArray: number[] = [];
15
+ await Promise.all([20, 20, 10].map(async (times) => {
16
+ try {
17
+ await endpoint.sendLike(user_id, times);
18
+ successArray.push(times);
19
+ } catch { /* ignore */ }
20
+ }));
21
+ const successTimes = successArray.reduce((a, b) => a + b, 0);
22
+ if (!successTimes) return { success: false, message: '点赞失败' };
23
+ return { success: true, message: `已给 ${user_id} 点赞 ${successTimes} 次` };
24
+ },
25
+ });
@@ -0,0 +1,23 @@
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 { getIcqqAgentDeps } from "../lib/icqq-agent-deps.js";
5
+ export default defineAgentTool({
6
+ description: '开启或关闭 QQ 群的匿名聊天功能',
7
+ inputSchema: z.object({
8
+ endpoint_id: z.string().describe('Endpoint QQ号'),
9
+ group_id: z.number().describe('目标群号'),
10
+ enable: z.boolean().optional().describe('true=开启,false=关闭,默认 true'),
11
+ }),
12
+ platforms: ['icqq'],
13
+ permissions: ['role(master,trusted,owner,admin)'],
14
+ async execute({ endpoint_id, group_id, enable }) {
15
+ const endpoint = getIcqqAgentDeps().getEndpoint(endpoint_id);
16
+ const on = enable ?? true;
17
+ const selfInfo = endpoint.pickMember(group_id, endpoint.uin);
18
+ if (!selfInfo.is_admin && !selfInfo.is_owner)
19
+ return { success: false, message: '我不是群主或管理员,无法开启或关闭匿名聊天' };
20
+ await endpoint.setGroupAnonymous(group_id, on);
21
+ return { success: true, message: on ? '已开启匿名聊天' : '已关闭匿名聊天' };
22
+ },
23
+ });
@@ -0,0 +1,21 @@
1
+ import { defineAgentTool } from '@zhin.js/tool';
2
+ import { z } from 'zod';
3
+ import { getIcqqAgentDeps } from '../src/icqq-agent-deps.js';
4
+ export default defineAgentTool<{ endpoint_id: string; group_id: number; enable?: boolean }>({
5
+ description: '开启或关闭 QQ 群的匿名聊天功能',
6
+ inputSchema: z.object({
7
+ endpoint_id: z.string().describe('Endpoint QQ号'),
8
+ group_id: z.number().describe('目标群号'),
9
+ enable: z.boolean().optional().describe('true=开启,false=关闭,默认 true'),
10
+ }),
11
+ platforms: ['icqq'],
12
+ permissions: ['role(master,trusted,owner,admin)'],
13
+ async execute({ endpoint_id, group_id, enable }: { endpoint_id: string; group_id: number; enable?: boolean }) {
14
+ const endpoint = getIcqqAgentDeps().getEndpoint(endpoint_id);
15
+ const on = enable ?? true;
16
+ const selfInfo= endpoint.pickMember(group_id,endpoint.uin);
17
+ if(!selfInfo.is_admin && !selfInfo.is_owner) return { success: false, message: '我不是群主或管理员,无法开启或关闭匿名聊天' };
18
+ await endpoint.setGroupAnonymous(group_id, on);
19
+ return { success: true, message: on ? '已开启匿名聊天' : '已关闭匿名聊天' };
20
+ },
21
+ });
@@ -0,0 +1,26 @@
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 { getIcqqAgentDeps } from "../lib/icqq-agent-deps.js";
5
+ export default defineAgentTool({
6
+ description: '禁言/解除禁言指定成员',
7
+ inputSchema: z.object({
8
+ endpoint_id: z.string().describe('Endpoint QQ号'),
9
+ group_id: z.number().describe('目标群号'),
10
+ user_id: z.number().describe('目标成员 QQ号'),
11
+ duration: z.number().describe('禁言时间(秒),0=解除禁言').default(0),
12
+ }),
13
+ platforms: ['icqq'],
14
+ permissions: ['role(master,trusted,admin,owner)'],
15
+ async execute({ endpoint_id, group_id, user_id, duration }) {
16
+ const endpoint = getIcqqAgentDeps().getEndpoint(endpoint_id);
17
+ const selfInfo = endpoint.pickMember(group_id, endpoint.uin);
18
+ if (!selfInfo.is_admin && !selfInfo.is_owner)
19
+ return { success: false, message: '我不是群主或管理员,无法禁言/解除禁言成员' };
20
+ const memberInfo = endpoint.pickMember(group_id, user_id);
21
+ if (!memberInfo)
22
+ return { success: false, message: '目标成员不存在' };
23
+ await endpoint.setGroupBan(group_id, user_id, duration === 0 ? 0 : duration);
24
+ return { success: true, message: `已${duration === 0 ? '解除' : ''}禁言 ${user_id} 成员${duration === 0 ? '' : `(${duration}秒)`}` };
25
+ },
26
+ });
@@ -0,0 +1,23 @@
1
+ import { defineAgentTool } from '@zhin.js/tool';
2
+ import { z } from 'zod';
3
+ import { getIcqqAgentDeps } from '../src/icqq-agent-deps.js';
4
+ export default defineAgentTool<{ endpoint_id: string; group_id: number; user_id: number; duration?: number }>({
5
+ description: '禁言/解除禁言指定成员',
6
+ inputSchema: z.object({
7
+ endpoint_id: z.string().describe('Endpoint QQ号'),
8
+ group_id: z.number().describe('目标群号'),
9
+ user_id: z.number().describe('目标成员 QQ号'),
10
+ duration: z.number().describe('禁言时间(秒),0=解除禁言').default(0),
11
+ }),
12
+ platforms: ['icqq'],
13
+ permissions: ['role(master,trusted,admin,owner)'],
14
+ async execute({ endpoint_id, group_id, user_id, duration }: { endpoint_id: string; group_id: number; user_id: number; duration?: number }) {
15
+ const endpoint = getIcqqAgentDeps().getEndpoint(endpoint_id);
16
+ const selfInfo= endpoint.pickMember(group_id,endpoint.uin);
17
+ if(!selfInfo.is_admin && !selfInfo.is_owner) return { success: false, message: '我不是群主或管理员,无法禁言/解除禁言成员' };
18
+ const memberInfo= endpoint.pickMember(group_id,user_id);
19
+ if(!memberInfo) return { success: false, message: '目标成员不存在' };
20
+ await endpoint.setGroupBan(group_id, user_id, duration === 0 ? 0 : duration);
21
+ return { success: true, message: `已${duration === 0 ? '解除' : ''}禁言 ${user_id} 成员${duration === 0 ? '' : `(${duration}秒)`}` };
22
+ },
23
+ });
@@ -0,0 +1,27 @@
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 { getIcqqAgentDeps } from "../lib/icqq-agent-deps.js";
5
+ export default defineAgentTool({
6
+ description: '设置 QQ 群成员的专属头衔',
7
+ inputSchema: z.object({
8
+ endpoint_id: z.string().describe('Endpoint QQ号'),
9
+ group_id: z.number().describe('目标群号'),
10
+ user_id: z.number().describe('目标成员 QQ号'),
11
+ title: z.string().describe('头衔文字'),
12
+ duration: z.number().optional().describe('持续时间(秒),-1永久').default(-1),
13
+ }),
14
+ platforms: ['icqq'],
15
+ permissions: ['role(master,trusted)'],
16
+ async execute({ endpoint_id, group_id, user_id, title, duration }) {
17
+ const endpoint = getIcqqAgentDeps().getEndpoint(endpoint_id);
18
+ const selfInfo = endpoint.pickMember(group_id, endpoint.uin);
19
+ if (!selfInfo.is_admin && !selfInfo.is_owner)
20
+ return { success: false, message: '我不是群主或管理员,无法设置头衔' };
21
+ const memberInfo = endpoint.pickMember(group_id, user_id);
22
+ if (!memberInfo)
23
+ return { success: false, message: '目标成员不存在' };
24
+ await endpoint.setGroupSpecialTitle(group_id, user_id, title, duration ?? -1);
25
+ return { success: true, message: `已将 ${user_id} 的头衔设为 "${title}"` };
26
+ },
27
+ });
@@ -0,0 +1,24 @@
1
+ import { defineAgentTool } from '@zhin.js/tool';
2
+ import { z } from 'zod';
3
+ import { getIcqqAgentDeps } from '../src/icqq-agent-deps.js';
4
+ export default defineAgentTool<{ endpoint_id: string; group_id: number; user_id: number; title: string; duration?: number }>({
5
+ description: '设置 QQ 群成员的专属头衔',
6
+ inputSchema: z.object({
7
+ endpoint_id: z.string().describe('Endpoint QQ号'),
8
+ group_id: z.number().describe('目标群号'),
9
+ user_id: z.number().describe('目标成员 QQ号'),
10
+ title: z.string().describe('头衔文字'),
11
+ duration: z.number().optional().describe('持续时间(秒),-1永久').default(-1),
12
+ }),
13
+ platforms: ['icqq'],
14
+ permissions: ['role(master,trusted)'],
15
+ async execute({ endpoint_id, group_id, user_id, title, duration }: { endpoint_id: string; group_id: number; user_id: number; title: string; duration?: number }) {
16
+ const endpoint = getIcqqAgentDeps().getEndpoint(endpoint_id);
17
+ const selfInfo= endpoint.pickMember(group_id,endpoint.uin);
18
+ if(!selfInfo.is_admin && !selfInfo.is_owner) return { success: false, message: '我不是群主或管理员,无法设置头衔' };
19
+ const memberInfo= endpoint.pickMember(group_id,user_id);
20
+ if(!memberInfo) return { success: false, message: '目标成员不存在' };
21
+ await endpoint.setGroupSpecialTitle(group_id, user_id, title, duration ?? -1);
22
+ return { success: true, message: `已将 ${user_id} 的头衔设为 "${title}"` };
23
+ },
24
+ });
@@ -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 { getIcqqAgentDeps } from "../lib/icqq-agent-deps.js";
5
+ export default defineAgentTool({
6
+ description: '获取指定QQ号的用户信息/资料/详情',
7
+ inputSchema: z.object({
8
+ endpoint_id: z.string().describe('Endpoint QQ号'),
9
+ user_id: z.number().describe('目标成员 QQ号'),
10
+ }),
11
+ platforms: ['icqq'],
12
+ async execute({ endpoint_id, user_id }) {
13
+ const endpoint = getIcqqAgentDeps().getEndpoint(endpoint_id);
14
+ const profile = await endpoint.getProfile(user_id);
15
+ return { success: true, message: `已获取 ${user_id} 的用户信息:${JSON.stringify(profile, null, 2)}` };
16
+ },
17
+ });
@@ -0,0 +1,16 @@
1
+ import { defineAgentTool } from '@zhin.js/tool';
2
+ import { z } from 'zod';
3
+ import { getIcqqAgentDeps } from '../src/icqq-agent-deps.js';
4
+ export default defineAgentTool<{ endpoint_id: string; user_id: number }>({
5
+ description: '获取指定QQ号的用户信息/资料/详情',
6
+ inputSchema: z.object({
7
+ endpoint_id: z.string().describe('Endpoint QQ号'),
8
+ user_id: z.number().describe('目标成员 QQ号'),
9
+ }),
10
+ platforms: ['icqq'],
11
+ async execute({ endpoint_id, user_id }: { endpoint_id: string; user_id: number }) {
12
+ const endpoint = getIcqqAgentDeps().getEndpoint(endpoint_id);
13
+ const profile = await endpoint.getProfile(user_id);
14
+ return { success: true, message: `已获取 ${user_id} 的用户信息:${JSON.stringify(profile,null,2)}` };
15
+ },
16
+ });
@@ -1,21 +0,0 @@
1
- import { defineAgentTool } from '@zhin.js/agent/tools';
2
- import { z } from 'zod';
3
- import { getIcqqAgentDeps } from '../../src/icqq-agent-deps.js';
4
- export default defineAgentTool<{ endpoint_id: string; group_id: number; content: string }>({
5
- description: '发送 QQ 群公告(需要管理员权限)',
6
- inputSchema: z.object({
7
- endpoint_id: z.string().describe('Endpoint QQ号'),
8
- group_id: z.number().describe('目标群号'),
9
- content: z.string().describe('公告内容'),
10
- }),
11
- platforms: ['icqq'],
12
- tags: ['icqq'],
13
- permissions: ['platform(icqq,scene_admin)'],
14
- async execute({ endpoint_id, group_id, content }: { endpoint_id: string; group_id: number; content: string }) {
15
- const { Actions } = await import('../../src/protocol.js');
16
- const endpoint = getIcqqAgentDeps().getEndpoint(endpoint_id);
17
- const resp = await endpoint.ipc.request(Actions.GROUP_ANNOUNCE, { group_id, content });
18
- return { success: resp.ok, message: resp.ok ? '群公告已发送' : (resp.error ?? '发送失败') };
19
- },
20
- });
21
-
@@ -1,27 +0,0 @@
1
- import { defineAgentTool } from '@zhin.js/agent/tools';
2
- import { z } from 'zod';
3
- import { getIcqqAgentDeps } from '../../src/icqq-agent-deps.js';
4
- export default defineAgentTool<{ endpoint_id: string; group_id: number }>({
5
- description: '获取 QQ 群的群文件列表',
6
- inputSchema: z.object({
7
- endpoint_id: z.string().describe('Endpoint 名称'),
8
- group_id: z.number().describe('群号'),
9
- }),
10
- platforms: ['icqq'],
11
- tags: ['icqq'],
12
- async execute({ endpoint_id, group_id }: { endpoint_id: string; group_id: number }) {
13
- const { Actions } = await import('../../src/protocol.js');
14
- const endpoint = getIcqqAgentDeps().getEndpoint(endpoint_id);
15
- const resp = await endpoint.ipc.request(Actions.GFS_LIST, { group_id });
16
- if (!resp.ok) throw new Error(resp.error ?? '获取群文件失败');
17
- const files = Array.isArray(resp.data) ? resp.data : [];
18
- if (!files.length) return { files: [], message: '群文件为空' };
19
- return {
20
- files: files.slice(0, 30).map((f: { name: string; size: number; uploader_uin: string; upload_time: number }) => ({
21
- name: f.name, size: f.size, uploader: f.uploader_uin, upload_time: f.upload_time,
22
- })),
23
- count: files.length,
24
- };
25
- },
26
- });
27
-
@@ -1,20 +0,0 @@
1
- import { defineAgentTool } from '@zhin.js/agent/tools';
2
- import { z } from 'zod';
3
- import { getIcqqAgentDeps } from '../../src/icqq-agent-deps.js';
4
- export default defineAgentTool<{ endpoint_id: string; group_id: number; user_id: number }>({
5
- description: '邀请好友加入 QQ 群',
6
- inputSchema: z.object({
7
- endpoint_id: z.string().describe('Endpoint QQ号'),
8
- group_id: z.number().describe('目标群号'),
9
- user_id: z.number().describe('要邀请的 QQ号'),
10
- }),
11
- platforms: ['icqq'],
12
- tags: ['icqq'],
13
- async execute({ endpoint_id, group_id, user_id }: { endpoint_id: string; group_id: number; user_id: number }) {
14
- const { Actions } = await import('../../src/protocol.js');
15
- const endpoint = getIcqqAgentDeps().getEndpoint(endpoint_id);
16
- const resp = await endpoint.ipc.request(Actions.GROUP_INVITE, { group_id, user_id });
17
- return { success: resp.ok, message: resp.ok ? `已邀请 ${user_id} 加入群` : (resp.error ?? '邀请失败') };
18
- },
19
- });
20
-
@@ -1,19 +0,0 @@
1
- import { defineAgentTool } from '@zhin.js/agent/tools';
2
- import { z } from 'zod';
3
- import { getIcqqAgentDeps } from '../../src/icqq-agent-deps.js';
4
- export default defineAgentTool<{ endpoint_id: string; group_id: number }>({
5
- description: 'QQ 群签到打卡',
6
- inputSchema: z.object({
7
- endpoint_id: z.string().describe('Endpoint QQ号'),
8
- group_id: z.number().describe('目标群号'),
9
- }),
10
- platforms: ['icqq'],
11
- tags: ['icqq'],
12
- async execute({ endpoint_id, group_id }: { endpoint_id: string; group_id: number }) {
13
- const { Actions } = await import('../../src/protocol.js');
14
- const endpoint = getIcqqAgentDeps().getEndpoint(endpoint_id);
15
- const resp = await endpoint.ipc.request(Actions.GROUP_SIGN, { group_id });
16
- return { success: resp.ok, message: resp.ok ? '群签到成功' : (resp.error ?? '签到失败') };
17
- },
18
- });
19
-
@@ -1,22 +0,0 @@
1
- import { defineAgentTool } from '@zhin.js/agent/tools';
2
- import { z } from 'zod';
3
- import { getIcqqAgentDeps } from '../../src/icqq-agent-deps.js';
4
- export default defineAgentTool<{ endpoint_id: string; group_id: number }>({
5
- description: '查询 QQ 群中当前被禁言的成员列表',
6
- inputSchema: z.object({
7
- endpoint_id: z.string().describe('Endpoint QQ号'),
8
- group_id: z.number().describe('目标群号'),
9
- }),
10
- platforms: ['icqq'],
11
- tags: ['icqq'],
12
- permissions: ['platform(icqq,scene_admin)'],
13
- async execute({ endpoint_id, group_id }: { endpoint_id: string; group_id: number }) {
14
- const { Actions } = await import('../../src/protocol.js');
15
- const endpoint = getIcqqAgentDeps().getEndpoint(endpoint_id);
16
- const resp = await endpoint.ipc.request(Actions.GROUP_MUTED_LIST, { group_id });
17
- if (!resp.ok) throw new Error(resp.error ?? '获取禁言列表失败');
18
- const list = Array.isArray(resp.data) ? resp.data : [];
19
- return { muted_members: list, count: list.length };
20
- },
21
- });
22
-
@@ -1,20 +0,0 @@
1
- import { defineAgentTool } from '@zhin.js/agent/tools';
2
- import { z } from 'zod';
3
- import { getIcqqAgentDeps } from '../../src/icqq-agent-deps.js';
4
- export default defineAgentTool<{ endpoint_id: string; group_id: number; user_id: number }>({
5
- description: '在 QQ 群中对某个成员执行戳一戳互动操作',
6
- inputSchema: z.object({
7
- endpoint_id: z.string().describe('Endpoint QQ号'),
8
- group_id: z.number().describe('目标群号'),
9
- user_id: z.number().describe('要戳的目标成员 QQ号'),
10
- }),
11
- platforms: ['icqq'],
12
- tags: ['icqq'],
13
- async execute({ endpoint_id, group_id, user_id }: { endpoint_id: string; group_id: number; user_id: number }) {
14
- const { Actions } = await import('../../src/protocol.js');
15
- const endpoint = getIcqqAgentDeps().getEndpoint(endpoint_id);
16
- const resp = await endpoint.ipc.request(Actions.GROUP_POKE, { group_id, user_id });
17
- return { success: resp.ok, message: resp.ok ? `已戳了戳 ${user_id}` : (resp.error ?? '戳一戳失败') };
18
- },
19
- });
20
-
@@ -1,22 +0,0 @@
1
- import { defineAgentTool } from '@zhin.js/agent/tools';
2
- import { z } from 'zod';
3
- import { getIcqqAgentDeps } from '../../src/icqq-agent-deps.js';
4
- export default defineAgentTool<{ endpoint_id: string; user_id: number; times?: number }>({
5
- description: '给用户点赞(竖大拇指),每人每天最多 20 次',
6
- inputSchema: z.object({
7
- endpoint_id: z.string().describe('Endpoint QQ号'),
8
- user_id: z.number().describe('要点赞的目标用户 QQ号'),
9
- times: z.number().optional().describe('点赞次数(1-20),默认 1'),
10
- }),
11
- platforms: ['icqq'],
12
- tags: ['icqq'],
13
- async execute({ endpoint_id, user_id, times }: { endpoint_id: string; user_id: number; times?: number }) {
14
- const { Actions } = await import('../../src/protocol.js');
15
- const endpoint = getIcqqAgentDeps().getEndpoint(endpoint_id);
16
- const resp = await endpoint.ipc.request(Actions.FRIEND_LIKE, {
17
- user_id, times: Math.min(times ?? 1, 20),
18
- });
19
- return { success: resp.ok, message: resp.ok ? `已给 ${user_id} 点赞` : (resp.error ?? '点赞失败') };
20
- },
21
- });
22
-
@@ -1,22 +0,0 @@
1
- import { defineAgentTool } from '@zhin.js/agent/tools';
2
- import { z } from 'zod';
3
- import { getIcqqAgentDeps } from '../../src/icqq-agent-deps.js';
4
- export default defineAgentTool<{ endpoint_id: string; group_id: number; enable?: boolean }>({
5
- description: '开启或关闭 QQ 群的匿名聊天功能',
6
- inputSchema: z.object({
7
- endpoint_id: z.string().describe('Endpoint QQ号'),
8
- group_id: z.number().describe('目标群号'),
9
- enable: z.boolean().optional().describe('true=开启,false=关闭,默认 true'),
10
- }),
11
- platforms: ['icqq'],
12
- tags: ['icqq'],
13
- permissions: ['platform(icqq,scene_owner)'],
14
- async execute({ endpoint_id, group_id, enable }: { endpoint_id: string; group_id: number; enable?: boolean }) {
15
- const { Actions } = await import('../../src/protocol.js');
16
- const endpoint = getIcqqAgentDeps().getEndpoint(endpoint_id);
17
- const on = enable ?? true;
18
- const resp = await endpoint.ipc.request(Actions.GROUP_ALLOW_ANONY, { group_id, enable: on });
19
- return { success: resp.ok, message: resp.ok ? (on ? '已开启匿名聊天' : '已关闭匿名聊天') : (resp.error ?? '操作失败') };
20
- },
21
- });
22
-
@@ -1,25 +0,0 @@
1
- import { defineAgentTool } from '@zhin.js/agent/tools';
2
- import { z } from 'zod';
3
- import { getIcqqAgentDeps } from '../../src/icqq-agent-deps.js';
4
- export default defineAgentTool<{ endpoint_id: string; group_id: number; user_id: number; title: string; duration?: number }>({
5
- description: '设置 QQ 群成员的专属头衔',
6
- inputSchema: z.object({
7
- endpoint_id: z.string().describe('Endpoint QQ号'),
8
- group_id: z.number().describe('目标群号'),
9
- user_id: z.number().describe('目标成员 QQ号'),
10
- title: z.string().describe('头衔文字'),
11
- duration: z.number().optional().describe('持续时间(秒),-1永久'),
12
- }),
13
- platforms: ['icqq'],
14
- tags: ['icqq'],
15
- permissions: ['platform(icqq,scene_owner)'],
16
- async execute({ endpoint_id, group_id, user_id, title, duration }: { endpoint_id: string; group_id: number; user_id: number; title: string; duration?: number }) {
17
- const { Actions } = await import('../../src/protocol.js');
18
- const endpoint = getIcqqAgentDeps().getEndpoint(endpoint_id);
19
- const resp = await endpoint.ipc.request(Actions.SET_GROUP_TITLE, {
20
- group_id, user_id, title, duration: duration ?? -1,
21
- });
22
- return { success: resp.ok, message: resp.ok ? `已将 ${user_id} 的头衔设为 "${title}"` : (resp.error ?? '设置失败') };
23
- },
24
- });
25
-