@zhin.js/adapter-icqq 8.0.14 → 9.0.1
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 +39 -0
- package/README.md +82 -3
- package/adapters/icqq.js +1 -3
- package/adapters/icqq.ts +2 -8
- package/agent/prompt-sections/platform.ts +17 -0
- package/lib/client.d.ts +19 -0
- package/lib/client.js +3 -0
- package/lib/endpoint.d.ts +9 -6
- package/lib/endpoint.js +232 -83
- package/lib/icqq-endpoint-commands.d.ts +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/package.json +21 -14
- package/plugin.js +1 -24
- package/src/client.ts +29 -0
- package/src/endpoint.ts +236 -85
- package/src/index.ts +4 -6
- package/tools/announce.js +3 -6
- package/tools/announce.ts +4 -7
- package/tools/essence.js +5 -7
- package/tools/essence.ts +6 -8
- package/tools/friend_list.js +6 -9
- package/tools/friend_list.ts +7 -10
- package/tools/group_files.js +3 -6
- package/tools/group_files.ts +4 -7
- package/tools/group_invite.js +6 -8
- package/tools/group_invite.ts +7 -9
- package/tools/group_kick.js +6 -8
- package/tools/group_kick.ts +7 -9
- package/tools/group_list.js +7 -10
- package/tools/group_list.ts +8 -11
- package/tools/group_member_info.js +3 -6
- package/tools/group_member_info.ts +3 -7
- package/tools/group_sign.js +5 -7
- package/tools/group_sign.ts +6 -8
- package/tools/list_muted.js +3 -6
- package/tools/list_muted.ts +4 -7
- package/tools/poke.js +3 -6
- package/tools/poke.ts +4 -7
- package/tools/send_user_like.js +3 -6
- package/tools/send_user_like.ts +4 -7
- package/tools/set_anonymous.js +5 -7
- package/tools/set_anonymous.ts +6 -8
- package/tools/set_mute.js +6 -8
- package/tools/set_mute.ts +7 -9
- package/tools/set_title.js +6 -8
- package/tools/set_title.ts +7 -9
- package/tools/user_info.js +3 -6
- package/tools/user_info.ts +4 -7
- package/lib/agent-prompt.d.ts +0 -2
- package/lib/agent-prompt.js +0 -97
- package/lib/icqq-agent-deps.d.ts +0 -13
- package/lib/icqq-agent-deps.js +0 -27
- package/src/agent-prompt.ts +0 -110
- package/src/icqq-agent-deps.ts +0 -43
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,44 @@
|
|
|
1
1
|
# @zhin.js/adapter-icqq
|
|
2
2
|
|
|
3
|
+
## 9.0.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 54bfd6b: Introduce Prompt Sections as a generation-owned Plugin Runtime Feature. Projects can declare typed context under `agent/prompt-sections/`, select interactive or scheduled profiles and IM platforms, and govern presentation order separately from required/preferred/opportunistic budget retention. In-flight turns remain pinned to their original generation across hot reloads, required policy fails explicitly when it cannot fit, duplicate identities are rejected, and the previous mutable Agent-local discovery and platform contributor APIs are removed. ICQQ and GitHub platform guidance now use the same Feature instead of a module-global registry.
|
|
8
|
+
|
|
9
|
+
Expose a content-free Prompt Section catalog through Console introspection, including owner, source, generation, profiles, and budget policy without disclosing prompt text. New AI projects mount the Feature automatically, and the full-bot example plus Chinese and English product documentation demonstrate the supported configuration.
|
|
10
|
+
|
|
11
|
+
- e9c6a73: Keep a replacement ICQQ connection alive when configuration hot reload retires the previous endpoint.
|
|
12
|
+
- 1fc78bc: Unify native platform Client access behind the literal `adapter` discriminant. Handlers infer both native events and Clients, while command, inbound/outbound middleware, and both Agent tool authoring surfaces expose the exact operation-scoped Client through a lazy `$client` getter. Definitions without `adapter` keep `$client` typed as `unknown`, and runtime dispatch rejects adapter mismatches before resolving the Client. Bundled platform tools now use this single path instead of model-provided endpoint ids and adapter-specific dependency wrappers. Every adapter registers one Client/EventMap contract, and protocol adapters including NapCat, Milky, OneBot and Satori now produce transport-independent Client objects rather than letting Endpoint instances impersonate Clients.
|
|
13
|
+
- Updated dependencies [e9c6a73]
|
|
14
|
+
- Updated dependencies [4e8117c]
|
|
15
|
+
- Updated dependencies [902fa35]
|
|
16
|
+
- Updated dependencies [54bfd6b]
|
|
17
|
+
- Updated dependencies [12025ee]
|
|
18
|
+
- Updated dependencies [09b14d6]
|
|
19
|
+
- Updated dependencies [1fc78bc]
|
|
20
|
+
- @zhin.js/agent@1.1.16
|
|
21
|
+
- @zhin.js/adapter@1.2.1
|
|
22
|
+
- @zhin.js/prompt-section@0.0.1
|
|
23
|
+
- @zhin.js/core@1.5.14
|
|
24
|
+
- @zhin.js/command@1.0.16
|
|
25
|
+
- @zhin.js/logger@1.0.77
|
|
26
|
+
- @zhin.js/tool@1.0.13
|
|
27
|
+
- zhin.js@6.0.14
|
|
28
|
+
- @zhin.js/feature-kit@1.0.13
|
|
29
|
+
- @zhin.js/permission@1.0.4
|
|
30
|
+
|
|
31
|
+
## 9.0.0
|
|
32
|
+
|
|
33
|
+
### Patch Changes
|
|
34
|
+
|
|
35
|
+
- Updated dependencies [f2c532f]
|
|
36
|
+
- Updated dependencies [3dbf990]
|
|
37
|
+
- @zhin.js/adapter@1.2.0
|
|
38
|
+
- @zhin.js/core@1.5.13
|
|
39
|
+
- @zhin.js/agent@1.1.15
|
|
40
|
+
- zhin.js@6.0.13
|
|
41
|
+
|
|
3
42
|
## 8.0.14
|
|
4
43
|
|
|
5
44
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@ ICQQ Plugin Runtime 适配器 — 进程内直接使用 [@icqqjs/icqq](https://g
|
|
|
5
5
|
## 功能特性
|
|
6
6
|
|
|
7
7
|
- 群聊 / 私聊 / 群临时会话 / QQ 频道消息
|
|
8
|
-
-
|
|
8
|
+
- 入站:ICQQ Client 原始事件经 `Endpoint.emit(...)` 唯一入口上送;文本与图片 / 语音 / 视频 / 文件统一归一为 canonical `Segment` + `MediaRef`
|
|
9
9
|
- 出站:canonical Segment 直接投影为 ICQQ 原生 `Sendable`,再由 `sendGroupMsg` / `sendPrivateMsg` / …发送
|
|
10
10
|
- 群聊 reaction:`control.addReaction` / `removeReaction`(协议 ACK 失败不阻塞后续发送)
|
|
11
11
|
- Agent 工具:包根 `tools/`(`@zhin.js/tool` Feature;模型侧名为 `icqq__send_user_like` 等)
|
|
@@ -32,6 +32,12 @@ pnpm add @icqqjs/qqsign
|
|
|
32
32
|
|
|
33
33
|
签名:未配置 `signApiAddr` 时,若已安装 `@icqqjs/qqsign` 则自动走本地签名。
|
|
34
34
|
|
|
35
|
+
## 前置条件
|
|
36
|
+
|
|
37
|
+
1. 准备可登录的 QQ 账号,并选择远程 `signApiAddr` 或安装本地 `@icqqjs/qqsign`。
|
|
38
|
+
2. 确保运行目录可持久化设备与登录状态;容器部署应挂载对应数据目录。
|
|
39
|
+
3. 首次登录可能要求二维码、滑块或设备确认,可在 Console 登录待办或终端完成。
|
|
40
|
+
|
|
35
41
|
## 配置(Plugin Runtime)
|
|
36
42
|
|
|
37
43
|
```yaml
|
|
@@ -65,10 +71,74 @@ plugins:
|
|
|
65
71
|
| 群临时会话 | `{ kind: 'private', id: uin, parent: { kind: 'group', id: gid } }` |
|
|
66
72
|
| 频道 | `{ kind: 'channel', id: channelId, parent: { kind: 'channel', id: guildId } }` |
|
|
67
73
|
|
|
74
|
+
## 直接使用完整 ICQQ Client
|
|
75
|
+
|
|
76
|
+
适配器把 `icqq` 注册为 `@icqqjs/icqq.Client` 与 SDK `EventMap` 的类型判别项。
|
|
77
|
+
所有 Feature 都使用同一个 `adapter` 字段完成类型缩窄与运行时过滤:
|
|
78
|
+
|
|
79
|
+
```ts
|
|
80
|
+
import { defineHandler } from 'zhin.js/handler'
|
|
81
|
+
import '@zhin.js/adapter-icqq'
|
|
82
|
+
|
|
83
|
+
export default defineHandler({
|
|
84
|
+
adapter: 'icqq',
|
|
85
|
+
event: 'request.group.add',
|
|
86
|
+
async handle({ client, event }) {
|
|
87
|
+
await client.setGroupAddRequest(event.flag, true)
|
|
88
|
+
},
|
|
89
|
+
})
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
`client` 就是当前账号的真实 ICQQ SDK 实例,不是 Endpoint facade。未知扩展事件可显式使用
|
|
93
|
+
`event: '*'`;此时 Client 类型保持完整,事件 payload 为 `unknown`。普通消息回复仍应走
|
|
94
|
+
`Message.$reply`;群管理、请求审批与 ICQQ 专属查询可直接调用当前事件的 `client`。
|
|
95
|
+
|
|
96
|
+
Command context 的 `$client` 是按需读取的 getter:
|
|
97
|
+
|
|
98
|
+
```ts
|
|
99
|
+
export default defineCommand({
|
|
100
|
+
adapter: 'icqq',
|
|
101
|
+
async execute(context) {
|
|
102
|
+
await context.$client.sendLike(Number(context.sender!.id), 10)
|
|
103
|
+
return 'ok'
|
|
104
|
+
},
|
|
105
|
+
})
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
Middleware 使用同一个判别字段;不声明 `adapter` 时 `$client` 的类型是 `unknown`:
|
|
109
|
+
|
|
110
|
+
```ts
|
|
111
|
+
export default defineMiddleware<Message>({
|
|
112
|
+
target: 'inbound',
|
|
113
|
+
adapter: 'icqq',
|
|
114
|
+
async handle(context, next) {
|
|
115
|
+
console.log(context.$client.uin, context.input.content)
|
|
116
|
+
await next()
|
|
117
|
+
},
|
|
118
|
+
})
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
Agent tool 的 IM turn 同样直接读取当前 Client:
|
|
122
|
+
|
|
123
|
+
```ts
|
|
124
|
+
export default defineAgentTool({
|
|
125
|
+
adapter: 'icqq',
|
|
126
|
+
description: '获取群列表',
|
|
127
|
+
async execute(_input, context) {
|
|
128
|
+
return context.$client.getGroupList()
|
|
129
|
+
},
|
|
130
|
+
})
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
`adapter` 缺失时 `$client` 静态类型为 `unknown`;声明后若实际 operation 不属于 ICQQ,
|
|
134
|
+
运行时会在执行前拒绝。Client 只能在当前 operation 内使用。task、schedule 或 Host 等脱离
|
|
135
|
+
IM turn 的场景,才使用 `icqqClient.get(context, endpointId)` 显式选择账号。
|
|
136
|
+
|
|
68
137
|
## 架构
|
|
69
138
|
|
|
70
139
|
- `plugin.ts` + `adapters/icqq.ts`(`defineAdapter`)
|
|
71
|
-
-
|
|
140
|
+
- Client token:`src/client.ts`(直接引用 ICQQ `Client` / `EventMap`)
|
|
141
|
+
- Endpoint:`src/endpoint.ts`(组合 ICQQ `Client`,负责账号 transport 与 Zhin lifecycle)
|
|
72
142
|
- 协议常量 / 配置:`src/protocol.ts`
|
|
73
143
|
- Agent 工具:`tools/*.ts`;权限说明见 `agent/PERMITS.md`
|
|
74
144
|
|
|
@@ -80,10 +150,19 @@ plugins:
|
|
|
80
150
|
- ICQQ 的语音、视频、文件是独立消息元素;它们与其他段混发时适配器会明确拒绝,避免协议栈静默丢段。
|
|
81
151
|
- 入站语音 / 视频在 Endpoint 持有原生 Client 时解析可下载 URL;解析失败则保留真实平台引用,不伪造或丢弃媒体。
|
|
82
152
|
- **Console 社交/群管 RPC 已接线**:endpoint 把好友/群/群成员列表、请求审批和群管操作归一化为冻结的 `EndpointManagement`。Host 只消费该语义端口。
|
|
83
|
-
- 好友/入群请求与通知:经 `
|
|
153
|
+
- 好友/入群请求与通知:经 the unified `Endpoint.emit(...)` ingress 分发到 `handlers`(`notice.receive` / `request.receive`);审批走 `Request.$approve` / `EndpointManagement.approveRequest`。Console `request.list` 优先读 `management.listRequests()`(`getSystemMsg`),不再写入 `unified_inbox_request/notice`。
|
|
84
154
|
- `system.*`(登录扫码等)分发到 `system.receive`。
|
|
85
155
|
- **登录辅助**:`system.login.qrcode|slider|device|auth` 经 `loginAssistToken`(`LoginAssist`)挂起待办;刷新后可用 Console `login.list` / `login.submit` 或终端 stdin 继续(对齐 icqq 官方 stdin 流程)。`system.online` / `login.error` 会清理该 endpoint 待办。
|
|
86
156
|
|
|
157
|
+
## 故障排查
|
|
158
|
+
|
|
159
|
+
| 现象 | 排查 |
|
|
160
|
+
| --- | --- |
|
|
161
|
+
| 一直停在登录中 | 打开 Console 登录待办,完成二维码、滑块或设备确认 |
|
|
162
|
+
| 签名失败 | 检查 `signApiAddr`;本地模式确认 `@icqqjs/qqsign` 已安装且版本匹配 |
|
|
163
|
+
| 重启后重复登录 | 持久化设备与会话数据目录,避免每次生成新设备 |
|
|
164
|
+
| 请求或通知未显示 | 在 Endpoint 详情检查请求视图;ICQQ 优先读取平台请求列表 |
|
|
165
|
+
|
|
87
166
|
## License
|
|
88
167
|
|
|
89
168
|
MIT
|
package/adapters/icqq.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Convention entry: discover `adapters/icqq.ts` → defineAdapter.
|
|
4
4
|
*/
|
|
5
5
|
import { defineAdapter } from 'zhin.js/adapter';
|
|
6
|
-
import { loginAssistToken
|
|
6
|
+
import { loginAssistToken } from '@zhin.js/core/runtime';
|
|
7
7
|
import { IcqqEndpoint } from "../lib/endpoint.js";
|
|
8
8
|
import { icqqRuntimeStateToken } from "../lib/icqq-runtime-state.js";
|
|
9
9
|
import { resolveIcqqConfig, } from "../lib/protocol.js";
|
|
@@ -24,8 +24,6 @@ export default defineAdapter({
|
|
|
24
24
|
});
|
|
25
25
|
return new IcqqEndpoint({
|
|
26
26
|
id: context.id,
|
|
27
|
-
gateway: context.use(messageGatewayToken),
|
|
28
|
-
sideEvents: context.use(sideEventGatewayToken),
|
|
29
27
|
loginAssist: context.use(loginAssistToken),
|
|
30
28
|
config,
|
|
31
29
|
});
|
package/adapters/icqq.ts
CHANGED
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Convention entry: discover `adapters/icqq.ts` → defineAdapter.
|
|
3
3
|
*/
|
|
4
|
-
import { defineAdapter
|
|
5
|
-
import {
|
|
6
|
-
loginAssistToken,
|
|
7
|
-
messageGatewayToken,
|
|
8
|
-
sideEventGatewayToken,
|
|
9
|
-
} from '@zhin.js/core/runtime';
|
|
4
|
+
import { defineAdapter } from 'zhin.js/adapter';
|
|
5
|
+
import { loginAssistToken } from '@zhin.js/core/runtime';
|
|
10
6
|
import { IcqqEndpoint } from '../src/endpoint.js';
|
|
11
7
|
import { icqqRuntimeStateToken } from '../src/icqq-runtime-state.js';
|
|
12
8
|
import {
|
|
@@ -39,8 +35,6 @@ export default defineAdapter<IcqqAdapterConfig>({
|
|
|
39
35
|
});
|
|
40
36
|
return new IcqqEndpoint({
|
|
41
37
|
id: context.id,
|
|
42
|
-
gateway: context.use(messageGatewayToken),
|
|
43
|
-
sideEvents: context.use(sideEventGatewayToken),
|
|
44
38
|
loginAssist: context.use(loginAssistToken),
|
|
45
39
|
config,
|
|
46
40
|
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { defineAgentPromptSection } from '@zhin.js/prompt-section';
|
|
2
|
+
|
|
3
|
+
export default defineAgentPromptSection({
|
|
4
|
+
title: 'ICQQ / QQ',
|
|
5
|
+
content: [
|
|
6
|
+
'On icqq/QQ: if icqq__send_user_like is in your tool list, call it with { user_id, times }.',
|
|
7
|
+
'The current IM operation selects the bot Client automatically. user_id is the sender to like. times is 1-20.',
|
|
8
|
+
'Do not claim the tool is missing until calling it this turn or load_tool("icqq__send_user_like") fails.',
|
|
9
|
+
'Other social tools include icqq__poke and icqq__friend_list.',
|
|
10
|
+
].join('\n'),
|
|
11
|
+
layer: 'tools',
|
|
12
|
+
order: 70,
|
|
13
|
+
retention: 'preferred',
|
|
14
|
+
maxChars: 1200,
|
|
15
|
+
profiles: ['interactive'],
|
|
16
|
+
platforms: ['icqq'],
|
|
17
|
+
});
|
package/lib/client.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Client, EventMap } from '@icqqjs/icqq';
|
|
2
|
+
type EventPayload<TListener> = TListener extends (event: infer TEvent, ...rest: readonly unknown[]) => unknown ? TEvent : never;
|
|
3
|
+
/** The actual ICQQ SDK instance exposed by every ICQQ Endpoint event. */
|
|
4
|
+
export type IcqqClient = Client;
|
|
5
|
+
/** Native ICQQ event-name → first public event payload, derived from the SDK SSOT. */
|
|
6
|
+
export type IcqqClientEventMap = {
|
|
7
|
+
readonly [TName in keyof EventMap]: EventPayload<EventMap[TName]>;
|
|
8
|
+
};
|
|
9
|
+
declare module '@zhin.js/feature-kit' {
|
|
10
|
+
interface AdapterClientRegistry {
|
|
11
|
+
readonly icqq: {
|
|
12
|
+
readonly client: IcqqClient;
|
|
13
|
+
readonly events: IcqqClientEventMap;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
/** Typed, generation-checked identity used by handlers, commands, tools and schedules. */
|
|
18
|
+
export declare const icqqClient: import("@zhin.js/adapter").EndpointClientToken<Client, IcqqClientEventMap>;
|
|
19
|
+
export {};
|
package/lib/client.js
ADDED
package/lib/endpoint.d.ts
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
import { Client } from '@icqqjs/icqq';
|
|
2
|
-
import
|
|
2
|
+
import { Endpoint } from 'zhin.js/adapter';
|
|
3
|
+
import type { EndpointControl, EndpointManagement, EndpointSendRequest } from 'zhin.js/adapter';
|
|
3
4
|
import type { EndpointContentPort } from '@zhin.js/adapter';
|
|
4
|
-
import type { MessageGateway, SideEventGateway } from '@zhin.js/core/runtime';
|
|
5
5
|
import { type LoginAssist } from '@zhin.js/core';
|
|
6
6
|
import type { CapabilityId } from 'zhin.js';
|
|
7
7
|
import { type IcqqInboundMessage, type ResolvedIcqqConfig } from './protocol.js';
|
|
8
8
|
export interface IcqqEndpointOptions {
|
|
9
9
|
readonly id: CapabilityId;
|
|
10
|
-
readonly gateway: MessageGateway;
|
|
11
10
|
readonly config: ResolvedIcqqConfig;
|
|
12
|
-
readonly sideEvents: SideEventGateway;
|
|
13
11
|
readonly loginAssist: LoginAssist;
|
|
14
12
|
}
|
|
15
|
-
|
|
13
|
+
declare class ManagedIcqqClient extends Client {
|
|
14
|
+
cancelReconnect(): void;
|
|
15
|
+
}
|
|
16
|
+
export declare class IcqqEndpoint extends Endpoint<Client> {
|
|
16
17
|
#private;
|
|
18
|
+
readonly client: ManagedIcqqClient;
|
|
17
19
|
readonly endpointName: string;
|
|
18
20
|
readonly content: EndpointContentPort;
|
|
19
21
|
readonly management: EndpointManagement;
|
|
@@ -24,5 +26,6 @@ export declare class IcqqEndpoint extends Client implements EndpointInstance {
|
|
|
24
26
|
close(): Promise<void>;
|
|
25
27
|
stop(): Promise<void>;
|
|
26
28
|
send({ conversation, payload }: EndpointSendRequest): Promise<string>;
|
|
27
|
-
admit(msg: IcqqInboundMessage
|
|
29
|
+
admit(msg: IcqqInboundMessage): Promise<void>;
|
|
28
30
|
}
|
|
31
|
+
export {};
|