@zhin.js/adapter-icqq 8.0.9 → 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.
- package/CHANGELOG.md +15 -0
- package/README.md +36 -28
- package/adapters/icqq.js +4 -9
- package/adapters/icqq.ts +5 -14
- 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 +4 -74
- 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 +4 -13
- 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/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 +24 -21
- package/lib/types.d.ts +4 -40
- package/lib/types.js +0 -5
- package/package.json +25 -13
- package/plugin.js +6 -1
- package/schema.json +119 -61
- package/src/agent-prompt.ts +17 -22
- package/src/cq-message.ts +2 -2
- package/src/endpoint.ts +358 -600
- package/src/forward-msg.ts +12 -26
- package/src/icqq-agent-deps.ts +3 -17
- package/src/icqq-endpoint-commands.ts +4 -13
- package/src/icqq-guild.ts +16 -25
- package/src/icqq-inbound.ts +26 -26
- package/src/icqq-inbox.ts +2 -10
- package/src/icqqjs-icqq.d.ts +88 -0
- package/src/index.ts +2 -9
- package/src/outbound-media.ts +4 -9
- package/src/protocol.ts +60 -66
- 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
package/src/agent-prompt.ts
CHANGED
|
@@ -9,7 +9,7 @@ import { filterTools, type AgentTool } from 'zhin.js/ai';
|
|
|
9
9
|
function isIcqqDelegatedTask(query: string, goal: string): boolean {
|
|
10
10
|
const text = `${query} ${goal}`;
|
|
11
11
|
const lower = text.toLowerCase();
|
|
12
|
-
if (/\bicqq\b|
|
|
12
|
+
if (/\bicqq\b|icqq__|send_private_msg|friend\s+send/i.test(text)) return true;
|
|
13
13
|
if (/\bfriend\s+like\b/.test(lower) && /qq|好友|\d{5,}/i.test(text)) return true;
|
|
14
14
|
if (/点赞/.test(text) && /qq|好友|\d{5,}/i.test(text)) return true;
|
|
15
15
|
if (/发消息|发送消息|私聊/.test(text) && /qq|\d{5,}/i.test(text)) return true;
|
|
@@ -23,27 +23,22 @@ function selectIcqqDeferredTools(
|
|
|
23
23
|
maxTools: number,
|
|
24
24
|
): DeferredToolCatalogItem[] {
|
|
25
25
|
const pool = deferredCatalog.filter(
|
|
26
|
-
t => !t.name.startsWith('mcp_filesystem')
|
|
26
|
+
t => !t.name.startsWith('mcp_filesystem')
|
|
27
|
+
&& !t.name.startsWith('mcp_memory_')
|
|
28
|
+
&& !t.name.startsWith('mcp_icqq_'),
|
|
27
29
|
);
|
|
28
|
-
const
|
|
29
|
-
const icqqTools = pool.filter(t => t.name.startsWith('icqq_'));
|
|
30
|
+
const icqqTools = pool.filter(t => t.name.startsWith('icqq__') || t.name.startsWith('icqq_'));
|
|
30
31
|
const pinned: DeferredToolCatalogItem[] = [];
|
|
31
|
-
const bash = pool.find(t => t.name === 'bash');
|
|
32
|
-
if (bash) pinned.push(bash);
|
|
33
32
|
const preferOrder = [
|
|
34
|
-
'
|
|
35
|
-
'
|
|
36
|
-
'
|
|
37
|
-
'icqq_friend_list',
|
|
38
|
-
'icqq_poke',
|
|
33
|
+
'icqq__send_user_like',
|
|
34
|
+
'icqq__friend_list',
|
|
35
|
+
'icqq__poke',
|
|
39
36
|
];
|
|
40
37
|
for (const name of preferOrder) {
|
|
41
|
-
const t =
|
|
42
|
-
icqqMcpTools.find(x => x.name === name) ??
|
|
43
|
-
icqqTools.find(x => x.name === name);
|
|
38
|
+
const t = icqqTools.find(x => x.name === name);
|
|
44
39
|
if (t) pinned.push(t);
|
|
45
40
|
}
|
|
46
|
-
for (const t of
|
|
41
|
+
for (const t of icqqTools) {
|
|
47
42
|
if (pinned.length >= maxTools) break;
|
|
48
43
|
if (!pinned.some(p => p.name === t.name)) pinned.push(t);
|
|
49
44
|
}
|
|
@@ -61,16 +56,16 @@ function selectIcqqDeferredTools(
|
|
|
61
56
|
}
|
|
62
57
|
|
|
63
58
|
const ORCHESTRATOR_ICQQ = [
|
|
64
|
-
'On icqq/QQ:
|
|
65
|
-
'
|
|
66
|
-
'
|
|
59
|
+
'On icqq/QQ: if icqq__send_user_like is in your tool list, call it now with { endpoint_id, user_id, times }.',
|
|
60
|
+
'endpoint_id is this bot QQ (Session endpoint). user_id is the sender to like. times is 1-20.',
|
|
61
|
+
'Do not tell the user the tool is missing until you have called it this turn (or load_tool("icqq__send_user_like") failed).',
|
|
62
|
+
'Ignore prior turns that said the like tool was unavailable. Other social tools: icqq__poke, icqq__friend_list.',
|
|
67
63
|
].join('\n');
|
|
68
64
|
|
|
69
65
|
const WORKER_ICQQ = [
|
|
70
|
-
'
|
|
71
|
-
'
|
|
72
|
-
'
|
|
73
|
-
'Do NOT use mcp_filesystem_* or explore node_modules / package.json to "discover" icqq.',
|
|
66
|
+
'Friend like: load_tool("icqq__send_user_like") then call with { endpoint_id, user_id, times }. endpoint_id is this bot QQ (origin.endpoint).',
|
|
67
|
+
'Poke: icqq__poke. Friend list: icqq__friend_list.',
|
|
68
|
+
'Do NOT use mcp_icqq_*, mcp_filesystem_*, or bash `icqq friend like`.',
|
|
74
69
|
'Do not stop at --help; execute the action the goal describes.',
|
|
75
70
|
].map(line => `- ${line}`).join('\n');
|
|
76
71
|
|
package/src/cq-message.ts
CHANGED
|
@@ -128,8 +128,8 @@ export function parseCqMessage(raw: string): MessageSegment[] {
|
|
|
128
128
|
return segments.length ? segments : [{ type: "text", data: { text: raw } }];
|
|
129
129
|
}
|
|
130
130
|
|
|
131
|
-
/** 构建 icqq
|
|
132
|
-
export function
|
|
131
|
+
/** 构建 icqq send_*_msg 的 message 字符串(非空) */
|
|
132
|
+
export function buildIcqqMessage(content: SendContent): string {
|
|
133
133
|
let message = toCqString(content).trim();
|
|
134
134
|
if (!message) message = "\u200b";
|
|
135
135
|
return message;
|