@zhin.js/adapter-icqq 9.0.0 → 9.0.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 (57) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/README.md +82 -3
  3. package/adapters/icqq.js +1 -3
  4. package/adapters/icqq.ts +2 -8
  5. package/agent/prompt-sections/platform.ts +17 -0
  6. package/lib/client.d.ts +19 -0
  7. package/lib/client.js +3 -0
  8. package/lib/endpoint.d.ts +9 -6
  9. package/lib/endpoint.js +232 -83
  10. package/lib/icqq-endpoint-commands.d.ts +1 -1
  11. package/lib/index.d.ts +1 -1
  12. package/lib/index.js +1 -1
  13. package/lib/protocol.js +1 -1
  14. package/package.json +21 -14
  15. package/plugin.js +1 -24
  16. package/src/client.ts +29 -0
  17. package/src/endpoint.ts +236 -85
  18. package/src/index.ts +4 -6
  19. package/src/protocol.ts +1 -1
  20. package/tools/announce.js +3 -6
  21. package/tools/announce.ts +4 -7
  22. package/tools/essence.js +5 -7
  23. package/tools/essence.ts +6 -8
  24. package/tools/friend_list.js +6 -9
  25. package/tools/friend_list.ts +7 -10
  26. package/tools/group_files.js +3 -6
  27. package/tools/group_files.ts +4 -7
  28. package/tools/group_invite.js +6 -8
  29. package/tools/group_invite.ts +7 -9
  30. package/tools/group_kick.js +6 -8
  31. package/tools/group_kick.ts +7 -9
  32. package/tools/group_list.js +7 -10
  33. package/tools/group_list.ts +8 -11
  34. package/tools/group_member_info.js +3 -6
  35. package/tools/group_member_info.ts +3 -7
  36. package/tools/group_sign.js +5 -7
  37. package/tools/group_sign.ts +6 -8
  38. package/tools/list_muted.js +3 -6
  39. package/tools/list_muted.ts +4 -7
  40. package/tools/poke.js +3 -6
  41. package/tools/poke.ts +4 -7
  42. package/tools/send_user_like.js +3 -6
  43. package/tools/send_user_like.ts +4 -7
  44. package/tools/set_anonymous.js +5 -7
  45. package/tools/set_anonymous.ts +6 -8
  46. package/tools/set_mute.js +6 -8
  47. package/tools/set_mute.ts +7 -9
  48. package/tools/set_title.js +6 -8
  49. package/tools/set_title.ts +7 -9
  50. package/tools/user_info.js +3 -6
  51. package/tools/user_info.ts +4 -7
  52. package/lib/agent-prompt.d.ts +0 -2
  53. package/lib/agent-prompt.js +0 -97
  54. package/lib/icqq-agent-deps.d.ts +0 -13
  55. package/lib/icqq-agent-deps.js +0 -27
  56. package/src/agent-prompt.ts +0 -110
  57. package/src/icqq-agent-deps.ts +0 -43
package/tools/announce.js CHANGED
@@ -1,19 +1,16 @@
1
1
  // Generated by build-plugin-runtime-entries.mjs. Do not edit.
2
2
  import { defineAgentTool } from '@zhin.js/tool';
3
3
  import { z } from 'zod';
4
- import { getIcqqAgentDeps } from "../lib/icqq-agent-deps.js";
5
4
  export default defineAgentTool({
6
5
  description: '发送 QQ 群公告(需要管理员权限)',
7
6
  inputSchema: z.object({
8
- endpoint_id: z.string().describe('Endpoint QQ号'),
9
7
  group_id: z.number().describe('目标群号'),
10
8
  content: z.string().describe('公告内容'),
11
9
  }),
12
- platforms: ['icqq'],
10
+ adapter: 'icqq',
13
11
  permissions: ['role(master,admin,trusted,owner)'],
14
- async execute({ endpoint_id, group_id, content }) {
15
- const endpoint = getIcqqAgentDeps().getEndpoint(endpoint_id);
16
- await endpoint.sendGroupNotice(group_id, content);
12
+ async execute({ group_id, content }, context) {
13
+ await context.$client.sendGroupNotice(group_id, content);
17
14
  return { success: true, message: '群公告已发送' };
18
15
  },
19
16
  });
package/tools/announce.ts CHANGED
@@ -1,18 +1,15 @@
1
1
  import { defineAgentTool } from '@zhin.js/tool';
2
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 }>({
3
+ export default defineAgentTool<{ group_id: number; content: string }>({
5
4
  description: '发送 QQ 群公告(需要管理员权限)',
6
5
  inputSchema: z.object({
7
- endpoint_id: z.string().describe('Endpoint QQ号'),
8
6
  group_id: z.number().describe('目标群号'),
9
7
  content: z.string().describe('公告内容'),
10
8
  }),
11
- platforms: ['icqq'],
9
+ adapter: 'icqq',
12
10
  permissions: ['role(master,admin,trusted,owner)'],
13
- async execute({ endpoint_id, group_id, content }: { endpoint_id: string; group_id: number; content: string }) {
14
- const endpoint = getIcqqAgentDeps().getEndpoint(endpoint_id);
15
- await endpoint.sendGroupNotice(group_id, content);
11
+ async execute({ group_id, content }, context) {
12
+ await context.$client.sendGroupNotice(group_id, content);
16
13
  return { success: true, message: '群公告已发送' };
17
14
  },
18
15
  });
package/tools/essence.js CHANGED
@@ -1,23 +1,21 @@
1
1
  // Generated by build-plugin-runtime-entries.mjs. Do not edit.
2
2
  import { defineAgentTool } from '@zhin.js/tool';
3
3
  import { z } from 'zod';
4
- import { getIcqqAgentDeps } from "../lib/icqq-agent-deps.js";
5
4
  export default defineAgentTool({
6
5
  description: '设置或移除 QQ 群精华消息',
7
6
  inputSchema: z.object({
8
- endpoint_id: z.string().describe('Endpoint QQ号'),
9
7
  message_id: z.string().describe('消息 ID'),
10
8
  action: z.enum(['add', 'remove']).describe('add=设为精华, remove=移除精华'),
11
9
  }),
12
- platforms: ['icqq'],
10
+ adapter: 'icqq',
13
11
  approval: 'always',
14
- async execute({ endpoint_id, message_id, action }) {
15
- const endpoint = getIcqqAgentDeps().getEndpoint(endpoint_id);
12
+ async execute({ message_id, action }, context) {
13
+ const client = context.$client;
16
14
  if (action === 'add') {
17
- await endpoint.setEssenceMessage(message_id);
15
+ await client.setEssenceMessage(message_id);
18
16
  }
19
17
  else {
20
- await endpoint.removeEssenceMessage(message_id);
18
+ await client.removeEssenceMessage(message_id);
21
19
  }
22
20
  return { success: true, message: action === 'add' ? '已设为精华' : '已移除精华' };
23
21
  },
package/tools/essence.ts CHANGED
@@ -1,21 +1,19 @@
1
1
  import { defineAgentTool } from '@zhin.js/tool';
2
2
  import { z } from 'zod';
3
- import { getIcqqAgentDeps } from '../src/icqq-agent-deps.js';
4
- export default defineAgentTool<{ endpoint_id: string; message_id: string; action: 'add' | 'remove' }>({
3
+ export default defineAgentTool<{ message_id: string; action: 'add' | 'remove' }>({
5
4
  description: '设置或移除 QQ 群精华消息',
6
5
  inputSchema: z.object({
7
- endpoint_id: z.string().describe('Endpoint QQ号'),
8
6
  message_id: z.string().describe('消息 ID'),
9
7
  action: z.enum(['add', 'remove']).describe('add=设为精华, remove=移除精华'),
10
8
  }),
11
- platforms: ['icqq'],
9
+ adapter: 'icqq',
12
10
  approval: 'always',
13
- async execute({ endpoint_id, message_id, action }: { endpoint_id: string; message_id: string; action: 'add' | 'remove' }) {
14
- const endpoint = getIcqqAgentDeps().getEndpoint(endpoint_id);
11
+ async execute({ message_id, action }, context) {
12
+ const client = context.$client;
15
13
  if (action === 'add') {
16
- await endpoint.setEssenceMessage(message_id);
14
+ await client.setEssenceMessage(message_id);
17
15
  } else {
18
- await endpoint.removeEssenceMessage(message_id);
16
+ await client.removeEssenceMessage(message_id);
19
17
  }
20
18
  return { success: true, message: action === 'add' ? '已设为精华' : '已移除精华' };
21
19
  },
@@ -1,21 +1,18 @@
1
1
  // Generated by build-plugin-runtime-entries.mjs. Do not edit.
2
2
  import { defineAgentTool } from '@zhin.js/tool';
3
3
  import { z } from 'zod';
4
- import { getIcqqAgentDeps } from "../lib/icqq-agent-deps.js";
5
4
  export default defineAgentTool({
6
5
  description: '获取 QQ 好友列表',
7
- inputSchema: z.object({
8
- endpoint_id: z.string().describe('Endpoint 名称'),
9
- }),
10
- platforms: ['icqq'],
6
+ inputSchema: z.object({}),
7
+ adapter: 'icqq',
11
8
  approval: 'never',
12
- async execute({ endpoint_id }) {
13
- const endpoint = getIcqqAgentDeps().getEndpoint(endpoint_id);
14
- const friends = Array.from(endpoint.fl.values()).map((friend) => ({
9
+ async execute(_input, context) {
10
+ const client = context.$client;
11
+ const friends = Array.from(client.fl.values()).map((friend) => ({
15
12
  user_id: friend.user_id,
16
13
  nickname: friend.nickname,
17
14
  remark: friend.remark,
18
15
  }));
19
- return { friends: friends.slice(0, 50), count: endpoint.fl.size };
16
+ return { friends: friends.slice(0, 50), count: client.fl.size };
20
17
  },
21
18
  });
@@ -1,21 +1,18 @@
1
1
  import { defineAgentTool } from '@zhin.js/tool';
2
2
  import { z } from 'zod';
3
- import { getIcqqAgentDeps } from '../src/icqq-agent-deps.js';
4
3
 
5
- export default defineAgentTool<{ endpoint_id: string }>({
4
+ export default defineAgentTool<Record<string, never>>({
6
5
  description: '获取 QQ 好友列表',
7
- inputSchema: z.object({
8
- endpoint_id: z.string().describe('Endpoint 名称'),
9
- }),
10
- platforms: ['icqq'],
6
+ inputSchema: z.object({}),
7
+ adapter: 'icqq',
11
8
  approval: 'never',
12
- async execute({ endpoint_id }) {
13
- const endpoint = getIcqqAgentDeps().getEndpoint(endpoint_id);
14
- const friends = Array.from(endpoint.fl.values()).map((friend) => ({
9
+ async execute(_input, context) {
10
+ const client = context.$client;
11
+ const friends = Array.from(client.fl.values()).map((friend) => ({
15
12
  user_id: friend.user_id,
16
13
  nickname: friend.nickname,
17
14
  remark: friend.remark,
18
15
  }));
19
- return { friends: friends.slice(0, 50), count: endpoint.fl.size };
16
+ return { friends: friends.slice(0, 50), count: client.fl.size };
20
17
  },
21
18
  });
@@ -1,18 +1,15 @@
1
1
  // Generated by build-plugin-runtime-entries.mjs. Do not edit.
2
2
  import { defineAgentTool } from '@zhin.js/tool';
3
3
  import { z } from 'zod';
4
- import { getIcqqAgentDeps } from "../lib/icqq-agent-deps.js";
5
4
  export default defineAgentTool({
6
5
  description: '获取 QQ 群的群文件列表',
7
6
  inputSchema: z.object({
8
- endpoint_id: z.string().describe('Endpoint 名称'),
9
7
  group_id: z.number().describe('群号'),
10
8
  }),
11
- platforms: ['icqq'],
9
+ adapter: 'icqq',
12
10
  approval: 'never',
13
- async execute({ endpoint_id, group_id }) {
14
- const endpoint = getIcqqAgentDeps().getEndpoint(endpoint_id);
15
- const files = await endpoint.acquireGfs(group_id).ls('/');
11
+ async execute({ group_id }, context) {
12
+ const files = await context.$client.acquireGfs(group_id).ls('/');
16
13
  if (!files.length)
17
14
  return { files: [], message: '群文件为空' };
18
15
  return {
@@ -1,17 +1,14 @@
1
1
  import { defineAgentTool } from '@zhin.js/tool';
2
2
  import { z } from 'zod';
3
- import { getIcqqAgentDeps } from '../src/icqq-agent-deps.js';
4
- export default defineAgentTool<{ endpoint_id: string; group_id: number }>({
3
+ export default defineAgentTool<{ group_id: number }>({
5
4
  description: '获取 QQ 群的群文件列表',
6
5
  inputSchema: z.object({
7
- endpoint_id: z.string().describe('Endpoint 名称'),
8
6
  group_id: z.number().describe('群号'),
9
7
  }),
10
- platforms: ['icqq'],
8
+ adapter: 'icqq',
11
9
  approval: 'never',
12
- async execute({ endpoint_id, group_id }: { endpoint_id: string; group_id: number }) {
13
- const endpoint = getIcqqAgentDeps().getEndpoint(endpoint_id);
14
- const files = await endpoint.acquireGfs(group_id).ls('/');
10
+ async execute({ group_id }, context) {
11
+ const files = await context.$client.acquireGfs(group_id).ls('/');
15
12
  if (!files.length) return { files: [], message: '群文件为空' };
16
13
  return {
17
14
  files: files.slice(0, 30).map((f) => 'size' in f
@@ -1,25 +1,23 @@
1
1
  // Generated by build-plugin-runtime-entries.mjs. Do not edit.
2
2
  import { defineAgentTool } from '@zhin.js/tool';
3
3
  import { z } from 'zod';
4
- import { getIcqqAgentDeps } from "../lib/icqq-agent-deps.js";
5
4
  export default defineAgentTool({
6
5
  description: '邀请好友加入 QQ 群',
7
6
  inputSchema: z.object({
8
- endpoint_id: z.string().describe('Endpoint QQ号'),
9
7
  group_id: z.number().describe('目标群号'),
10
8
  user_id: z.number().describe('要邀请的 QQ号'),
11
9
  }),
12
- platforms: ['icqq'],
10
+ adapter: 'icqq',
13
11
  approval: 'never',
14
- async execute({ endpoint_id, group_id, user_id }) {
15
- const endpoint = getIcqqAgentDeps().getEndpoint(endpoint_id);
16
- const groupInfo = endpoint.pickGroup(group_id);
12
+ async execute({ group_id, user_id }, context) {
13
+ const client = context.$client;
14
+ const groupInfo = client.pickGroup(group_id);
17
15
  if (!groupInfo)
18
16
  return { success: false, message: '目标群不存在' };
19
- const memberInfo = endpoint.pickMember(group_id, user_id);
17
+ const memberInfo = client.pickMember(group_id, user_id);
20
18
  if (memberInfo)
21
19
  return { success: false, message: '目标成员已加入群' };
22
- await endpoint.inviteFriend(group_id, user_id);
20
+ await client.inviteFriend(group_id, user_id);
23
21
  return { success: true, message: `已尝试邀请 ${user_id} 加入群 ${group_id}` };
24
22
  },
25
23
  });
@@ -1,22 +1,20 @@
1
1
  import { defineAgentTool } from '@zhin.js/tool';
2
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 }>({
3
+ export default defineAgentTool<{ group_id: number; user_id: number }>({
5
4
  description: '邀请好友加入 QQ 群',
6
5
  inputSchema: z.object({
7
- endpoint_id: z.string().describe('Endpoint QQ号'),
8
6
  group_id: z.number().describe('目标群号'),
9
7
  user_id: z.number().describe('要邀请的 QQ号'),
10
8
  }),
11
- platforms: ['icqq'],
9
+ adapter: 'icqq',
12
10
  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
- const groupInfo= endpoint.pickGroup(group_id);
11
+ async execute({ group_id, user_id }, context) {
12
+ const client = context.$client;
13
+ const groupInfo= client.pickGroup(group_id);
16
14
  if(!groupInfo) return { success: false, message: '目标群不存在' };
17
- const memberInfo= endpoint.pickMember(group_id,user_id);
15
+ const memberInfo= client.pickMember(group_id,user_id);
18
16
  if(memberInfo) return { success: false, message: '目标成员已加入群' };
19
- await endpoint.inviteFriend(group_id, user_id);
17
+ await client.inviteFriend(group_id, user_id);
20
18
  return { success: true, message: `已尝试邀请 ${user_id} 加入群 ${group_id}` };
21
19
  },
22
20
  });
@@ -1,28 +1,26 @@
1
1
  // Generated by build-plugin-runtime-entries.mjs. Do not edit.
2
2
  import { defineAgentTool } from '@zhin.js/tool';
3
3
  import { z } from 'zod';
4
- import { getIcqqAgentDeps } from "../lib/icqq-agent-deps.js";
5
4
  export default defineAgentTool({
6
5
  description: '踢出 QQ 群中的某个成员',
7
6
  inputSchema: z.object({
8
- endpoint_id: z.string().describe('Endpoint QQ号'),
9
7
  group_id: z.number().describe('目标群号'),
10
8
  user_id: z.number().describe('要踢出的成员 QQ号'),
11
9
  }),
12
- platforms: ['icqq'],
10
+ adapter: 'icqq',
13
11
  permissions: ['role(master,admin,trusted,owner)'],
14
12
  approval: 'never',
15
- async execute({ endpoint_id, group_id, user_id }) {
16
- const endpoint = getIcqqAgentDeps().getEndpoint(endpoint_id);
17
- const selfInfo = endpoint.pickMember(group_id, endpoint.uin);
13
+ async execute({ group_id, user_id }, context) {
14
+ const client = context.$client;
15
+ const selfInfo = client.pickMember(group_id, client.uin);
18
16
  if (!selfInfo.is_admin && !selfInfo.is_owner)
19
17
  return { success: false, message: '我不是群主或管理员,无法踢出成员' };
20
18
  if (selfInfo.user_id === user_id)
21
19
  return { success: false, message: '我不能踢出自己' };
22
- const memberInfo = endpoint.pickMember(group_id, user_id);
20
+ const memberInfo = client.pickMember(group_id, user_id);
23
21
  if (!memberInfo)
24
22
  return { success: false, message: '目标成员不存在' };
25
- await endpoint.setGroupKick(group_id, user_id);
23
+ await client.setGroupKick(group_id, user_id);
26
24
  return { success: true, message: `已踢出 ${user_id} 成员` };
27
25
  },
28
26
  });
@@ -1,24 +1,22 @@
1
1
  import { defineAgentTool } from '@zhin.js/tool';
2
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 }>({
3
+ export default defineAgentTool<{ group_id: number; user_id: number }>({
5
4
  description: '踢出 QQ 群中的某个成员',
6
5
  inputSchema: z.object({
7
- endpoint_id: z.string().describe('Endpoint QQ号'),
8
6
  group_id: z.number().describe('目标群号'),
9
7
  user_id: z.number().describe('要踢出的成员 QQ号'),
10
8
  }),
11
- platforms: ['icqq'],
9
+ adapter: 'icqq',
12
10
  permissions: ['role(master,admin,trusted,owner)'],
13
11
  approval: 'never',
14
- async execute({ endpoint_id, group_id, user_id }: { endpoint_id: string; group_id: number; user_id: number }) {
15
- const endpoint = getIcqqAgentDeps().getEndpoint(endpoint_id);
16
- const selfInfo= endpoint.pickMember(group_id,endpoint.uin);
12
+ async execute({ group_id, user_id }, context) {
13
+ const client = context.$client;
14
+ const selfInfo= client.pickMember(group_id,client.uin);
17
15
  if(!selfInfo.is_admin && !selfInfo.is_owner) return { success: false, message: '我不是群主或管理员,无法踢出成员' };
18
16
  if(selfInfo.user_id === user_id) return { success: false, message: '我不能踢出自己' };
19
- const memberInfo= endpoint.pickMember(group_id,user_id);
17
+ const memberInfo= client.pickMember(group_id,user_id);
20
18
  if(!memberInfo) return { success: false, message: '目标成员不存在' };
21
- await endpoint.setGroupKick(group_id, user_id);
19
+ await client.setGroupKick(group_id, user_id);
22
20
  return { success: true, message: `已踢出 ${user_id} 成员` };
23
21
  },
24
22
  });
@@ -1,22 +1,19 @@
1
1
  // Generated by build-plugin-runtime-entries.mjs. Do not edit.
2
2
  import { defineAgentTool } from '@zhin.js/tool';
3
3
  import { z } from 'zod';
4
- import { getIcqqAgentDeps } from "../lib/icqq-agent-deps.js";
5
4
  export default defineAgentTool({
6
- description: '获取 Endpoint 的 QQ 群列表',
7
- inputSchema: z.object({
8
- endpoint_id: z.string().describe('Endpoint 名称'),
9
- }),
10
- platforms: ['icqq'],
5
+ adapter: 'icqq',
6
+ description: '获取当前 QQ 账号的群列表',
7
+ inputSchema: z.object({}),
11
8
  approval: 'never',
12
- async execute({ endpoint_id }) {
13
- const endpoint = getIcqqAgentDeps().getEndpoint(endpoint_id);
14
- const groups = Array.from(endpoint.gl.values()).map((group) => ({
9
+ async execute(_input, context) {
10
+ const client = context.$client;
11
+ const groups = Array.from(client.gl.values()).map((group) => ({
15
12
  group_id: group.group_id,
16
13
  group_name: group.group_name,
17
14
  member_count: group.member_count,
18
15
  max_member_count: group.max_member_count,
19
16
  }));
20
- return { groups: groups.slice(0, 50), count: endpoint.gl.size };
17
+ return { groups: groups.slice(0, 50), count: client.gl.size };
21
18
  },
22
19
  });
@@ -1,22 +1,19 @@
1
1
  import { defineAgentTool } from '@zhin.js/tool';
2
2
  import { z } from 'zod';
3
- import { getIcqqAgentDeps } from '../src/icqq-agent-deps.js';
4
3
 
5
- export default defineAgentTool<{ endpoint_id: string }>({
6
- description: '获取 Endpoint 的 QQ 群列表',
7
- inputSchema: z.object({
8
- endpoint_id: z.string().describe('Endpoint 名称'),
9
- }),
10
- platforms: ['icqq'],
4
+ export default defineAgentTool<Record<string, never>>({
5
+ adapter: 'icqq',
6
+ description: '获取当前 QQ 账号的群列表',
7
+ inputSchema: z.object({}),
11
8
  approval: 'never',
12
- async execute({ endpoint_id }) {
13
- const endpoint = getIcqqAgentDeps().getEndpoint(endpoint_id);
14
- const groups = Array.from(endpoint.gl.values()).map((group) => ({
9
+ async execute(_input, context) {
10
+ const client = context.$client;
11
+ const groups = Array.from(client.gl.values()).map((group) => ({
15
12
  group_id: group.group_id,
16
13
  group_name: group.group_name,
17
14
  member_count: group.member_count,
18
15
  max_member_count: group.max_member_count,
19
16
  }));
20
- return { groups: groups.slice(0, 50), count: endpoint.gl.size };
17
+ return { groups: groups.slice(0, 50), count: client.gl.size };
21
18
  },
22
19
  });
@@ -1,19 +1,16 @@
1
1
  // Generated by build-plugin-runtime-entries.mjs. Do not edit.
2
2
  import { defineAgentTool } from '@zhin.js/tool';
3
3
  import { z } from 'zod';
4
- import { getIcqqAgentDeps } from "../lib/icqq-agent-deps.js";
5
4
  export default defineAgentTool({
6
5
  description: '获取 QQ 群成员信息',
7
6
  inputSchema: z.object({
8
- endpoint_id: z.string().describe('Endpoint QQ号'),
9
7
  group_id: z.number().describe('目标群号'),
10
8
  user_id: z.number().describe('目标成员 QQ号'),
11
9
  }),
12
- platforms: ['icqq'],
10
+ adapter: 'icqq',
13
11
  approval: 'never',
14
- async execute({ endpoint_id, group_id, user_id }) {
15
- const endpoint = getIcqqAgentDeps().getEndpoint(endpoint_id);
16
- const group = endpoint.pickGroup(group_id);
12
+ async execute({ group_id, user_id }, context) {
13
+ const group = context.$client.pickGroup(group_id);
17
14
  if (!group)
18
15
  return { success: false, message: '目标群不存在' };
19
16
  const memberInfo = group.pickMember(user_id);
@@ -1,8 +1,6 @@
1
1
  import { defineAgentTool } from '@zhin.js/tool';
2
2
  import { z } from 'zod';
3
- import { getIcqqAgentDeps } from '../src/icqq-agent-deps.js';
4
3
  interface GroupMemberInfoInput {
5
- endpoint_id: string;
6
4
  group_id: number;
7
5
  user_id: number;
8
6
  }
@@ -10,15 +8,13 @@ interface GroupMemberInfoInput {
10
8
  export default defineAgentTool<GroupMemberInfoInput>({
11
9
  description: '获取 QQ 群成员信息',
12
10
  inputSchema: z.object({
13
- endpoint_id: z.string().describe('Endpoint QQ号'),
14
11
  group_id: z.number().describe('目标群号'),
15
12
  user_id: z.number().describe('目标成员 QQ号'),
16
13
  }),
17
- platforms: ['icqq'],
14
+ adapter: 'icqq',
18
15
  approval: 'never',
19
- async execute({ endpoint_id, group_id, user_id }) {
20
- const endpoint = getIcqqAgentDeps().getEndpoint(endpoint_id);
21
- const group = endpoint.pickGroup(group_id);
16
+ async execute({ group_id, user_id }, context) {
17
+ const group = context.$client.pickGroup(group_id);
22
18
  if (!group) return { success: false, message: '目标群不存在' };
23
19
  const memberInfo = group.pickMember(user_id);
24
20
  if (!memberInfo) return { success: false, message: '目标成员不存在' };
@@ -1,21 +1,19 @@
1
1
  // Generated by build-plugin-runtime-entries.mjs. Do not edit.
2
2
  import { defineAgentTool } from '@zhin.js/tool';
3
3
  import { z } from 'zod';
4
- import { getIcqqAgentDeps } from "../lib/icqq-agent-deps.js";
5
4
  export default defineAgentTool({
6
5
  description: 'QQ 群签到/打卡',
7
6
  inputSchema: z.object({
8
- endpoint_id: z.string().describe('Endpoint QQ号'),
9
7
  group_id: z.number().describe('目标群号'),
10
8
  }),
11
- platforms: ['icqq'],
9
+ adapter: 'icqq',
12
10
  approval: 'never',
13
- async execute({ endpoint_id, group_id }) {
14
- const endpoint = getIcqqAgentDeps().getEndpoint(endpoint_id);
15
- const groupInfo = endpoint.pickGroup(group_id);
11
+ async execute({ group_id }, context) {
12
+ const client = context.$client;
13
+ const groupInfo = client.pickGroup(group_id);
16
14
  if (!groupInfo)
17
15
  return { success: false, message: '目标群不存在' };
18
- await endpoint.sendGroupSign(group_id);
16
+ await client.sendGroupSign(group_id);
19
17
  return { success: true, message: '群签到成功' };
20
18
  },
21
19
  });
@@ -1,19 +1,17 @@
1
1
  import { defineAgentTool } from '@zhin.js/tool';
2
2
  import { z } from 'zod';
3
- import { getIcqqAgentDeps } from '../src/icqq-agent-deps.js';
4
- export default defineAgentTool<{ endpoint_id: string; group_id: number }>({
3
+ export default defineAgentTool<{ group_id: number }>({
5
4
  description: 'QQ 群签到/打卡',
6
5
  inputSchema: z.object({
7
- endpoint_id: z.string().describe('Endpoint QQ号'),
8
6
  group_id: z.number().describe('目标群号'),
9
7
  }),
10
- platforms: ['icqq'],
8
+ adapter: 'icqq',
11
9
  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);
10
+ async execute({ group_id }, context) {
11
+ const client = context.$client;
12
+ const groupInfo= client.pickGroup(group_id);
15
13
  if(!groupInfo) return { success: false, message: '目标群不存在' };
16
- await endpoint.sendGroupSign(group_id);
14
+ await client.sendGroupSign(group_id);
17
15
  return { success: true, message: '群签到成功' };
18
16
  },
19
17
  });
@@ -1,18 +1,15 @@
1
1
  // Generated by build-plugin-runtime-entries.mjs. Do not edit.
2
2
  import { defineAgentTool } from '@zhin.js/tool';
3
3
  import { z } from 'zod';
4
- import { getIcqqAgentDeps } from "../lib/icqq-agent-deps.js";
5
4
  export default defineAgentTool({
6
5
  description: '查询 QQ 群中当前被禁言的成员列表',
7
6
  inputSchema: z.object({
8
- endpoint_id: z.string().describe('Endpoint QQ号'),
9
7
  group_id: z.number().describe('目标群号'),
10
8
  }),
11
- platforms: ['icqq'],
9
+ adapter: 'icqq',
12
10
  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);
11
+ async execute({ group_id }, context) {
12
+ const members = await context.$client.getGroupMemberList(group_id);
16
13
  const now = Math.floor(Date.now() / 1000);
17
14
  const muted = Array.from(members.values()).filter((m) => m.shutup_time > now);
18
15
  return { muted_members: muted, count: muted.length };
@@ -1,17 +1,14 @@
1
1
  import { defineAgentTool } from '@zhin.js/tool';
2
2
  import { z } from 'zod';
3
- import { getIcqqAgentDeps } from '../src/icqq-agent-deps.js';
4
- export default defineAgentTool<{ endpoint_id: string; group_id: number }>({
3
+ export default defineAgentTool<{ group_id: number }>({
5
4
  description: '查询 QQ 群中当前被禁言的成员列表',
6
5
  inputSchema: z.object({
7
- endpoint_id: z.string().describe('Endpoint QQ号'),
8
6
  group_id: z.number().describe('目标群号'),
9
7
  }),
10
- platforms: ['icqq'],
8
+ adapter: 'icqq',
11
9
  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);
10
+ async execute({ group_id }, context) {
11
+ const members = await context.$client.getGroupMemberList(group_id);
15
12
  const now = Math.floor(Date.now() / 1000);
16
13
  const muted = Array.from(members.values()).filter((m) => m.shutup_time > now);
17
14
  return { muted_members: muted, count: muted.length };
package/tools/poke.js CHANGED
@@ -1,19 +1,16 @@
1
1
  // Generated by build-plugin-runtime-entries.mjs. Do not edit.
2
2
  import { defineAgentTool } from '@zhin.js/tool';
3
3
  import { z } from 'zod';
4
- import { getIcqqAgentDeps } from "../lib/icqq-agent-deps.js";
5
4
  export default defineAgentTool({
6
5
  description: '在 QQ 群中对某个成员执行戳一戳互动操作',
7
6
  inputSchema: z.object({
8
- endpoint_id: z.string().describe('Endpoint QQ号'),
9
7
  group_id: z.number().describe('目标群号'),
10
8
  user_id: z.number().describe('要戳的目标成员 QQ号'),
11
9
  }),
12
- platforms: ['icqq'],
10
+ adapter: 'icqq',
13
11
  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);
12
+ async execute({ group_id, user_id }, context) {
13
+ await context.$client.sendGroupPoke(group_id, user_id);
17
14
  return { success: true, message: `已戳了戳 ${user_id}` };
18
15
  },
19
16
  });
package/tools/poke.ts CHANGED
@@ -1,18 +1,15 @@
1
1
  import { defineAgentTool } from '@zhin.js/tool';
2
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 }>({
3
+ export default defineAgentTool<{ group_id: number; user_id: number }>({
5
4
  description: '在 QQ 群中对某个成员执行戳一戳互动操作',
6
5
  inputSchema: z.object({
7
- endpoint_id: z.string().describe('Endpoint QQ号'),
8
6
  group_id: z.number().describe('目标群号'),
9
7
  user_id: z.number().describe('要戳的目标成员 QQ号'),
10
8
  }),
11
- platforms: ['icqq'],
9
+ adapter: 'icqq',
12
10
  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);
11
+ async execute({ group_id, user_id }, context) {
12
+ await context.$client.sendGroupPoke(group_id, user_id);
16
13
  return { success: true, message: `已戳了戳 ${user_id}` };
17
14
  },
18
15
  });
@@ -1,21 +1,18 @@
1
1
  // Generated by build-plugin-runtime-entries.mjs. Do not edit.
2
2
  import { defineAgentTool } from '@zhin.js/tool';
3
3
  import { z } from 'zod';
4
- import { getIcqqAgentDeps } from "../lib/icqq-agent-deps.js";
5
4
  export default defineAgentTool({
6
5
  description: '尝试给用户点尽量多的赞',
7
6
  inputSchema: z.object({
8
- endpoint_id: z.string().describe('Endpoint QQ号'),
9
7
  user_id: z.number().describe('要点赞的目标用户 QQ号'),
10
8
  }),
11
- platforms: ['icqq'],
9
+ adapter: 'icqq',
12
10
  approval: 'never',
13
- async execute({ endpoint_id, user_id }) {
14
- const endpoint = getIcqqAgentDeps().getEndpoint(endpoint_id);
11
+ async execute({ user_id }, context) {
15
12
  const successArray = [];
16
13
  await Promise.all([20, 20, 10].map(async (times) => {
17
14
  try {
18
- await endpoint.sendLike(user_id, times);
15
+ await context.$client.sendLike(user_id, times);
19
16
  successArray.push(times);
20
17
  }
21
18
  catch { /* ignore */ }