@zhin.js/adapter-icqq 8.0.9 → 8.0.11
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.
- package/CHANGELOG.md +27 -0
- package/README.md +36 -28
- package/adapters/icqq.js +6 -11
- package/adapters/icqq.ts +7 -16
- package/agent/PERMITS.md +2 -0
- package/lib/agent-prompt.js +17 -22
- package/lib/cq-message.d.ts +2 -2
- package/lib/cq-message.js +2 -2
- package/lib/endpoint.d.ts +6 -76
- package/lib/endpoint.js +348 -507
- package/lib/forward-msg.d.ts +7 -8
- package/lib/forward-msg.js +11 -24
- package/lib/icqq-agent-deps.d.ts +3 -15
- package/lib/icqq-agent-deps.js +0 -5
- package/lib/icqq-endpoint-commands.js +6 -15
- package/lib/icqq-guild.d.ts +15 -11
- package/lib/icqq-guild.js +9 -17
- package/lib/icqq-inbound.d.ts +20 -20
- package/lib/icqq-inbound.js +9 -9
- package/lib/icqq-inbox.d.ts +2 -10
- package/lib/icqq-runtime-state.js +1 -1
- package/lib/index.d.ts +2 -3
- package/lib/index.js +2 -3
- package/lib/outbound-media.d.ts +3 -8
- package/lib/outbound-media.js +3 -8
- package/lib/protocol.d.ts +38 -57
- package/lib/protocol.js +25 -22
- package/lib/types.d.ts +4 -40
- package/lib/types.js +0 -5
- package/package.json +22 -13
- package/plugin.js +8 -3
- package/schema.json +119 -61
- package/src/agent-prompt.ts +17 -22
- package/src/cq-message.ts +2 -2
- package/src/endpoint.ts +360 -602
- package/src/forward-msg.ts +12 -26
- package/src/icqq-agent-deps.ts +3 -17
- package/src/icqq-endpoint-commands.ts +6 -15
- package/src/icqq-guild.ts +16 -25
- package/src/icqq-inbound.ts +26 -26
- package/src/icqq-inbox.ts +2 -10
- package/src/icqq-runtime-state.ts +1 -1
- package/src/index.ts +2 -9
- package/src/outbound-media.ts +4 -9
- package/src/protocol.ts +61 -67
- package/src/types.ts +4 -41
- package/tools/announce.js +19 -0
- package/tools/announce.ts +18 -0
- package/tools/essence.js +24 -0
- package/{agent/tools → tools}/essence.ts +8 -8
- package/tools/friend_list.js +20 -0
- package/{agent/tools → tools}/friend_list.ts +7 -7
- package/tools/group_files.js +25 -0
- package/tools/group_files.ts +23 -0
- package/tools/group_invite.js +25 -0
- package/tools/group_invite.ts +22 -0
- package/tools/group_kick.js +28 -0
- package/tools/group_kick.ts +24 -0
- package/tools/group_list.js +21 -0
- package/{agent/tools → tools}/group_list.ts +7 -7
- package/tools/group_sign.js +21 -0
- package/tools/group_sign.ts +19 -0
- package/tools/list_muted.js +20 -0
- package/tools/list_muted.ts +19 -0
- package/tools/poke.js +19 -0
- package/tools/poke.ts +18 -0
- package/tools/send_user_like.js +28 -0
- package/tools/send_user_like.ts +25 -0
- package/tools/set_anonymous.js +23 -0
- package/tools/set_anonymous.ts +21 -0
- package/tools/set_mute.js +26 -0
- package/tools/set_mute.ts +23 -0
- package/tools/set_title.js +27 -0
- package/tools/set_title.ts +24 -0
- package/tools/user_info.js +17 -0
- package/tools/user_info.ts +16 -0
- package/agent/tools/announce.ts +0 -21
- package/agent/tools/group_files.ts +0 -27
- package/agent/tools/group_invite.ts +0 -20
- package/agent/tools/group_sign.ts +0 -19
- package/agent/tools/list_muted.ts +0 -22
- package/agent/tools/poke.ts +0 -20
- package/agent/tools/send_user_like.ts +0 -22
- package/agent/tools/set_anonymous.ts +0 -22
- package/agent/tools/set_title.ts +0 -25
- package/lib/ipc-client.d.ts +0 -73
- package/lib/ipc-client.js +0 -358
- package/src/ipc-client.ts +0 -417
|
@@ -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
|
+
});
|
package/agent/tools/announce.ts
DELETED
|
@@ -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
|
-
|
package/agent/tools/poke.ts
DELETED
|
@@ -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
|
-
|
package/agent/tools/set_title.ts
DELETED
|
@@ -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
|
-
|
package/lib/ipc-client.d.ts
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import type { IpcResponse, IpcEvent } from "./protocol.js";
|
|
2
|
-
export declare class IpcClient {
|
|
3
|
-
private socket;
|
|
4
|
-
private buffer;
|
|
5
|
-
private pending;
|
|
6
|
-
private eventHandlers;
|
|
7
|
-
private _closed;
|
|
8
|
-
/** 是否为客户端主动 close()(与对端断线区分) */
|
|
9
|
-
private _userClosed;
|
|
10
|
-
private _remoteDisconnectEmitted;
|
|
11
|
-
private onRemoteDisconnect;
|
|
12
|
-
private constructor();
|
|
13
|
-
get closed(): boolean;
|
|
14
|
-
/**
|
|
15
|
-
* 注册「对端断开 / 连接异常关闭」回调(不含本端 close())。
|
|
16
|
-
* 传入 null 可清除回调。
|
|
17
|
-
*/
|
|
18
|
-
setOnRemoteDisconnect(handler: (() => void) | null): void;
|
|
19
|
-
/** 注册数据处理 handler(RPC 模式延迟到 challenge 完成后调用) */
|
|
20
|
-
private attachDataHandler;
|
|
21
|
-
/**
|
|
22
|
-
* 通过 IPC(Unix Socket)连接守护进程并完成认证。
|
|
23
|
-
* @param uin - 目标账号的 QQ 号
|
|
24
|
-
* @returns 已认证的 IpcClient 实例
|
|
25
|
-
* @throws 守护进程未运行或认证失败时抛出错误
|
|
26
|
-
*/
|
|
27
|
-
static connect(uin: number): Promise<IpcClient>;
|
|
28
|
-
/**
|
|
29
|
-
* 通过 RPC(TCP)连接守护进程并完成 HMAC 挑战-响应认证。
|
|
30
|
-
*
|
|
31
|
-
* 流程:
|
|
32
|
-
* 1. 服务端连接后发送 { challenge: "<hex>" }
|
|
33
|
-
* 2. 客户端用 HMAC-SHA256(token, challenge) 生成 digest
|
|
34
|
-
* 3. 客户端发送 { action: "auth", params: { digest: "<hex>" } }
|
|
35
|
-
* 4. 服务端验证 digest,通过则认证成功
|
|
36
|
-
*
|
|
37
|
-
* token 不会明文传输,防止中间人嗅探。
|
|
38
|
-
*
|
|
39
|
-
* @param options.host - 远程主机地址
|
|
40
|
-
* @param options.port - 远程端口
|
|
41
|
-
* @param options.token - 认证 token(用于 HMAC 计算,不会明文传输)
|
|
42
|
-
*/
|
|
43
|
-
static connectRpc(options: {
|
|
44
|
-
host: string;
|
|
45
|
-
port: number;
|
|
46
|
-
token: string;
|
|
47
|
-
}): Promise<IpcClient>;
|
|
48
|
-
/**
|
|
49
|
-
* 通过 RPC 连接守护进程(自动从 daemon.rpc 文件读取地址)。
|
|
50
|
-
* @param uin - 目标账号的 QQ 号
|
|
51
|
-
*/
|
|
52
|
-
static connectRpcByUin(uin: number): Promise<IpcClient>;
|
|
53
|
-
private onData;
|
|
54
|
-
/**
|
|
55
|
-
* 注册 icqq 事件回调。
|
|
56
|
-
* 新版守护进程在认证后会自动广播事件(event.id = "*")。
|
|
57
|
-
*/
|
|
58
|
-
onEvent(onEvent: (event: IpcEvent) => void): () => void;
|
|
59
|
-
/**
|
|
60
|
-
* 发送 IPC 请求并等待响应。
|
|
61
|
-
*/
|
|
62
|
-
request(action: string, params?: Record<string, unknown>, timeoutMs?: number): Promise<IpcResponse>;
|
|
63
|
-
/**
|
|
64
|
-
* 订阅 daemon 推送事件:服务端自动推送全部事件,type/id 过滤在客户端完成。
|
|
65
|
-
* @returns 订阅句柄,包含 unsubscribe() 方法
|
|
66
|
-
*/
|
|
67
|
-
subscribe(_action: string, params: Record<string, unknown>, onEvent: (event: IpcEvent) => void): {
|
|
68
|
-
id: string;
|
|
69
|
-
unsubscribe: () => Promise<void>;
|
|
70
|
-
};
|
|
71
|
-
/** 关闭连接 */
|
|
72
|
-
close(): void;
|
|
73
|
-
}
|