@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.
Files changed (87) hide show
  1. package/CHANGELOG.md +15 -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 +2 -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 +24 -21
  27. package/lib/types.d.ts +4 -40
  28. package/lib/types.js +0 -5
  29. package/package.json +25 -13
  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 +2 -2
  34. package/src/endpoint.ts +358 -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 +60 -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
@@ -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|mcp_icqq|send_private_msg|friend\s+send/i.test(text)) return true;
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') && !t.name.startsWith('mcp_memory_'),
26
+ t => !t.name.startsWith('mcp_filesystem')
27
+ && !t.name.startsWith('mcp_memory_')
28
+ && !t.name.startsWith('mcp_icqq_'),
27
29
  );
28
- const icqqMcpTools = pool.filter(t => t.name.startsWith('mcp_icqq_'));
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
- 'mcp_icqq_icqq_invoke',
35
- 'mcp_icqq_icqq_list_actions',
36
- 'icqq_send_user_like',
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 [...icqqMcpTools, ...icqqTools]) {
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: use run_deferred_task with tool_query "mcp_icqq_icqq_invoke" or "icqq_send_user_like".',
65
- 'Examples: send_private_msg, friend_like; do not use mcp_filesystem_* for QQ tasks.',
66
- 'Skip tool_search when the user clearly asks to send a message, like a friend, or poke on QQ.',
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
- 'Send private message: `mcp_icqq_icqq_invoke` action `send_private_msg` params `{ user_id, message }`, or bash `icqq friend send <uid> "<text>"`.',
71
- 'Friend like: action `friend_like` or `icqq_send_user_like`, or bash `icqq friend like <uid> -t <times>`.',
72
- 'Use `icqq_list_actions` only if action name is unclear.',
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 IPC send_*_msg 的 message 字符串(非空) */
132
- export function buildIcqqIpcMessage(content: SendContent): string {
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;