@zhin.js/adapter-onebot11 1.1.22 → 1.1.24
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 +55 -0
- package/lib/protocol.d.ts +2 -0
- package/lib/protocol.js +3 -0
- package/lib/ws-endpoint.js +2 -0
- package/lib/ws-types.d.ts +1 -0
- package/lib/wss-endpoint.js +2 -0
- package/package.json +19 -20
- package/pages/index/index.js +1 -2
- package/pages/index/index.ts +1 -2
- package/plugin.js +8 -6
- package/src/protocol.ts +4 -0
- package/src/ws-endpoint.ts +2 -0
- package/src/ws-types.ts +1 -0
- package/src/wss-endpoint.ts +2 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,60 @@
|
|
|
1
1
|
# @zhin.js/adapter-onebot11
|
|
2
2
|
|
|
3
|
+
## 1.1.24
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- cbf1fb1: Unify Console page blueprints (`definePageBlueprint`, `defineAdapterPage`, `defineCommentReviewPage`, `projectBlueprintToImCard`, `projectBlueprintToCliPanel`) into `@zhin.js/console-contract` and `@zhin.js/page`, add zero-esbuild pure Blueprint synthesis + static client bundle mounting to `@zhin.js/pagemanager`, remove `@zhin.js/client` (React 19) and `.tsx` from all 30 server-side plugins and adapters (including `bilibili` and `juejin`), and remove legacy Era-1 Koa `PageManager` code.
|
|
8
|
+
- Updated dependencies [cbf1fb1]
|
|
9
|
+
- Updated dependencies [008ccad]
|
|
10
|
+
- Updated dependencies [a1f1028]
|
|
11
|
+
- @zhin.js/console-contract@1.1.4
|
|
12
|
+
- @zhin.js/page@1.1.16
|
|
13
|
+
- @zhin.js/core@1.1.58
|
|
14
|
+
- @zhin.js/im-contract@1.1.13
|
|
15
|
+
- @zhin.js/host-http@1.1.16
|
|
16
|
+
- @zhin.js/adapter@1.1.30
|
|
17
|
+
- @zhin.js/adapter-onebot-events@0.0.3
|
|
18
|
+
- @zhin.js/tool@1.1.17
|
|
19
|
+
- @zhin.js/agent-feature@1.1.15
|
|
20
|
+
- @zhin.js/feature-kit@1.1.14
|
|
21
|
+
- @zhin.js/permission@1.1.14
|
|
22
|
+
- @zhin.js/skill@1.1.15
|
|
23
|
+
|
|
24
|
+
## 1.1.23
|
|
25
|
+
|
|
26
|
+
### Patch Changes
|
|
27
|
+
|
|
28
|
+
- bc6ccb1: Deep audit bug fixes and 7 architectural improvements:
|
|
29
|
+
- Sink Agent Turn ingress pipeline from `@zhin.js/cli` into `@zhin.js/agent/runtime` (`plugin-runtime/ingress/`) and decompose `ingress-route.ts` into modular pipeline stages.
|
|
30
|
+
- Bind Session State Plane (`JsxButtonRegistry`, `InteractionRuntime`, `RuntimeInteractiveRouter`) to `PluginIncarnationRef` so active buttons and interactions survive unrelated-plugin HMR while expiring when the owning plugin reloads, and support per-conversation fallback numbering (`numberingScope: 'conversation'`).
|
|
31
|
+
- Establish `conversation_events` as the canonical message SSOT and reference `conversation_event_id`, `conversation_key`, `platform_message_id`, and `message_key` in `agent_messages` (`AGENT_MESSAGE_QUERY_VERSION = 2`), threading `conversationSequence` across inbound and outbound delivery receipts.
|
|
32
|
+
- Push down `DatabaseContextRepository` and `DatabaseScheduleJobStorage` full-session/full-table memory scans to indexed SQL queries.
|
|
33
|
+
- Add kernel-level inbound `replyTo` and `mentioned` auto-promotion (`promoteInboundMessagePayload`) plus reusable `InboundDeduper` and `TtlLookupCache` primitives in `@zhin.js/adapter`.
|
|
34
|
+
- Add `MiddlewareContext.dispatch` (`InboundDispatchSummary`) and `onAfterDispatch` hooks for `after-dispatch` middlewares, and support incremental rendering of in-place `envelope.payload` array mutations in `OutboundDeliveryRuntime`.
|
|
35
|
+
- Unify `HistoryWindowTracker` and `AgentCompactionRuntime` token/message budgets (`resolveUnifiedHistoryAndCompactionBudget`).
|
|
36
|
+
- Fix schema validation, database transaction connection cleanup and SQLite WAL mode, schedule timer wheel head-of-line blocking, security policy bash read paths and subagent guard propagation, group merge window permission carrier handoff, micro-compact namespaced tool matching, and WebSocket force-close / inbound segment mapping across adapters.
|
|
37
|
+
- Updated dependencies [3a8504b]
|
|
38
|
+
- Updated dependencies [6163abc]
|
|
39
|
+
- Updated dependencies [fed2c27]
|
|
40
|
+
- Updated dependencies [bc6ccb1]
|
|
41
|
+
- Updated dependencies [72b5a12]
|
|
42
|
+
- Updated dependencies [aa41889]
|
|
43
|
+
- Updated dependencies [4427e72]
|
|
44
|
+
- Updated dependencies [22bd14a]
|
|
45
|
+
- @zhin.js/agent-feature@1.1.14
|
|
46
|
+
- @zhin.js/core@1.1.57
|
|
47
|
+
- @zhin.js/client@1.1.25
|
|
48
|
+
- @zhin.js/page@1.1.15
|
|
49
|
+
- @zhin.js/im-contract@1.1.12
|
|
50
|
+
- @zhin.js/adapter@1.1.29
|
|
51
|
+
- @zhin.js/host-http@1.1.15
|
|
52
|
+
- @zhin.js/feature-kit@1.1.13
|
|
53
|
+
- @zhin.js/tool@1.1.16
|
|
54
|
+
- @zhin.js/adapter-onebot-events@0.0.2
|
|
55
|
+
- @zhin.js/permission@1.1.13
|
|
56
|
+
- @zhin.js/skill@1.1.14
|
|
57
|
+
|
|
3
58
|
## 1.1.22
|
|
4
59
|
|
|
5
60
|
### Patch Changes
|
package/lib/protocol.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ import type { EndpointProfileConfiguration } from 'zhin.js/adapter';
|
|
|
5
5
|
* Spec: https://github.com/botuniverse/onebot-11
|
|
6
6
|
*/
|
|
7
7
|
import { type MediaRef, type ConversationRef } from '@zhin.js/im-contract';
|
|
8
|
+
import { type Segment } from '@zhin.js/core';
|
|
8
9
|
/** One endpoint config after AdapterIndex expands `plugins.<instanceKey>.endpoints`. */
|
|
9
10
|
export interface OneBot11EndpointConfig extends EndpointProfileConfiguration {
|
|
10
11
|
readonly connection?: 'ws' | 'wss';
|
|
@@ -117,6 +118,7 @@ export interface OneBot11InboundFields {
|
|
|
117
118
|
readonly replyTo: {
|
|
118
119
|
readonly id: string;
|
|
119
120
|
} | undefined;
|
|
121
|
+
readonly segments?: readonly Segment[];
|
|
120
122
|
}
|
|
121
123
|
/** 构造 gateway.receive 的 metadata 与提升字段(ws / wss 两个 endpoint 共用)。 */
|
|
122
124
|
export declare function formatInboundMetadata(ev: OneBot11Event, endpoint: string): OneBot11InboundFields;
|
package/lib/protocol.js
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* Spec: https://github.com/botuniverse/onebot-11
|
|
5
5
|
*/
|
|
6
6
|
import { EndpointDeliveryError, isMediaRef } from '@zhin.js/im-contract';
|
|
7
|
+
import { toCanonicalSegments } from '@zhin.js/core';
|
|
7
8
|
import { formatCompact, getLogger } from '@zhin.js/logger';
|
|
8
9
|
const logger = getLogger('onebot11');
|
|
9
10
|
function normalizeConnection(connection) {
|
|
@@ -161,6 +162,7 @@ export function formatInboundMetadata(ev, endpoint) {
|
|
|
161
162
|
const nickname = senderNickname(ev);
|
|
162
163
|
const quoteId = extractQuoteId(ev);
|
|
163
164
|
const mentioned = isOneBot11BotMentioned({ selfId, message: ev.message });
|
|
165
|
+
const segments = Array.isArray(ev.message) ? toCanonicalSegments(ev.message) : undefined;
|
|
164
166
|
return {
|
|
165
167
|
metadata: Object.freeze({
|
|
166
168
|
message_type: ev.message_type,
|
|
@@ -174,6 +176,7 @@ export function formatInboundMetadata(ev, endpoint) {
|
|
|
174
176
|
endpointId: endpoint,
|
|
175
177
|
mentioned,
|
|
176
178
|
replyTo: quoteId ? { id: quoteId } : undefined,
|
|
179
|
+
...(segments?.length ? { segments } : {}),
|
|
177
180
|
};
|
|
178
181
|
}
|
|
179
182
|
/**
|
package/lib/ws-endpoint.js
CHANGED
|
@@ -165,6 +165,7 @@ export class OneBot11WsEndpoint extends Onebot11Client {
|
|
|
165
165
|
endpointId: inbound.endpointId,
|
|
166
166
|
...(inbound.mentioned ? { mentioned: true } : {}),
|
|
167
167
|
...(inbound.replyTo ? { replyTo: inbound.replyTo } : {}),
|
|
168
|
+
...(inbound.segments?.length ? { segments: inbound.segments } : {}),
|
|
168
169
|
metadata: inbound.metadata,
|
|
169
170
|
}).catch((err) => {
|
|
170
171
|
this.#logger.warn(formatCompact({
|
|
@@ -207,6 +208,7 @@ export class OneBot11WsEndpoint extends Onebot11Client {
|
|
|
207
208
|
}
|
|
208
209
|
try {
|
|
209
210
|
ws.close();
|
|
211
|
+
ws.terminate?.();
|
|
210
212
|
}
|
|
211
213
|
catch {
|
|
212
214
|
/* ignore */
|
package/lib/ws-types.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export interface OneBot11WsSocket {
|
|
|
3
3
|
readonly readyState: number;
|
|
4
4
|
send(data: string): void;
|
|
5
5
|
close(code?: number, reason?: string): void;
|
|
6
|
+
terminate?(): void;
|
|
6
7
|
ping?(): void;
|
|
7
8
|
on(event: 'open' | 'message' | 'close' | 'error' | 'pong', listener: (...args: unknown[]) => void): void;
|
|
8
9
|
}
|
package/lib/wss-endpoint.js
CHANGED
|
@@ -172,6 +172,7 @@ export class OneBot11WssEndpoint extends Onebot11Client {
|
|
|
172
172
|
endpointId: inbound.endpointId,
|
|
173
173
|
...(inbound.mentioned ? { mentioned: true } : {}),
|
|
174
174
|
...(inbound.replyTo ? { replyTo: inbound.replyTo } : {}),
|
|
175
|
+
...(inbound.segments?.length ? { segments: inbound.segments } : {}),
|
|
175
176
|
metadata: inbound.metadata,
|
|
176
177
|
}).catch((err) => {
|
|
177
178
|
this.#logger.warn(formatCompact({
|
|
@@ -220,6 +221,7 @@ export class OneBot11WssEndpoint extends Onebot11Client {
|
|
|
220
221
|
}
|
|
221
222
|
try {
|
|
222
223
|
socket.close();
|
|
224
|
+
socket.terminate?.();
|
|
223
225
|
}
|
|
224
226
|
catch {
|
|
225
227
|
/* ignore */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zhin.js/adapter-onebot11",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.24",
|
|
4
4
|
"description": "Zhin.js OneBot 11 adapter for Plugin Runtime (WebSocket client)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./lib/index.js",
|
|
@@ -45,20 +45,19 @@
|
|
|
45
45
|
"@imhelper/onebot-v11": "1.0.7",
|
|
46
46
|
"imhelper": "1.0.7",
|
|
47
47
|
"ws": "^8.21.1",
|
|
48
|
-
"@zhin.js/adapter-onebot-events": "0.0.
|
|
49
|
-
"@zhin.js/adapter": "1.1.
|
|
50
|
-
"@zhin.js/agent-feature": "1.1.
|
|
51
|
-
"@zhin.js/
|
|
52
|
-
"@zhin.js/
|
|
53
|
-
"@zhin.js/
|
|
54
|
-
"@zhin.js/
|
|
55
|
-
"@zhin.js/
|
|
56
|
-
"@zhin.js/im-contract": "1.1.11",
|
|
48
|
+
"@zhin.js/adapter-onebot-events": "0.0.3",
|
|
49
|
+
"@zhin.js/adapter": "1.1.30",
|
|
50
|
+
"@zhin.js/agent-feature": "1.1.15",
|
|
51
|
+
"@zhin.js/console-contract": "1.1.4",
|
|
52
|
+
"@zhin.js/core": "1.1.58",
|
|
53
|
+
"@zhin.js/feature-kit": "1.1.14",
|
|
54
|
+
"@zhin.js/host-http": "1.1.16",
|
|
55
|
+
"@zhin.js/im-contract": "1.1.13",
|
|
57
56
|
"@zhin.js/logger": "1.1.2",
|
|
58
|
-
"@zhin.js/page": "1.1.
|
|
59
|
-
"@zhin.js/permission": "1.1.
|
|
60
|
-
"@zhin.js/skill": "1.1.
|
|
61
|
-
"@zhin.js/tool": "1.1.
|
|
57
|
+
"@zhin.js/page": "1.1.16",
|
|
58
|
+
"@zhin.js/permission": "1.1.14",
|
|
59
|
+
"@zhin.js/skill": "1.1.15",
|
|
60
|
+
"@zhin.js/tool": "1.1.17"
|
|
62
61
|
},
|
|
63
62
|
"devDependencies": {
|
|
64
63
|
"@types/node": "^26.1.2",
|
|
@@ -66,15 +65,15 @@
|
|
|
66
65
|
"typescript": "^6.0.3",
|
|
67
66
|
"vitest": "^4.1.10",
|
|
68
67
|
"zod": "^4.4.3",
|
|
69
|
-
"@zhin.js/host-http": "1.1.
|
|
70
|
-
"zhin.js": "1.1.
|
|
68
|
+
"@zhin.js/host-http": "1.1.16",
|
|
69
|
+
"zhin.js": "1.1.23"
|
|
71
70
|
},
|
|
72
71
|
"peerDependencies": {
|
|
73
72
|
"zod": "^4.0.0",
|
|
74
|
-
"@zhin.js/adapter": "^1.1.
|
|
75
|
-
"@zhin.js/command": "^1.1.
|
|
76
|
-
"@zhin.js/core": "^1.1.
|
|
77
|
-
"zhin.js": "^1.1.
|
|
73
|
+
"@zhin.js/adapter": "^1.1.30",
|
|
74
|
+
"@zhin.js/command": "^1.1.16",
|
|
75
|
+
"@zhin.js/core": "^1.1.58",
|
|
76
|
+
"zhin.js": "^1.1.23"
|
|
78
77
|
},
|
|
79
78
|
"peerDependenciesMeta": {
|
|
80
79
|
"@zhin.js/command": {
|
package/pages/index/index.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
// Generated by build-plugin-runtime-entries.mjs. Do not edit.
|
|
2
|
-
import { definePage } from '@zhin.js/console-contract';
|
|
3
|
-
import { createAdapterConsolePage } from '@zhin.js/client';
|
|
2
|
+
import { definePage, createAdapterConsolePage } from '@zhin.js/console-contract';
|
|
4
3
|
export const meta = definePage({
|
|
5
4
|
title: 'OneBot 11',
|
|
6
5
|
titleI18n: { en: 'OneBot 11' },
|
package/pages/index/index.ts
CHANGED
package/plugin.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Generated by build-plugin-runtime-entries.mjs. Do not edit.
|
|
2
|
-
import { definePlugin
|
|
2
|
+
import { definePlugin } from 'zhin.js';
|
|
3
3
|
import { permissionHostToken, createSceneRolePlatformChecker } from '@zhin.js/permission';
|
|
4
4
|
import { createOnebot11ConsoleRpc } from "./lib/console.js";
|
|
5
5
|
export default definePlugin({
|
|
@@ -9,10 +9,12 @@ export default definePlugin({
|
|
|
9
9
|
displayName: 'OneBot 11 Adapter',
|
|
10
10
|
},
|
|
11
11
|
setup(context) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
const dispose = context.resources.has(permissionHostToken)
|
|
13
|
+
? context.resources.use(permissionHostToken).registerPlatform('onebot11', createSceneRolePlatformChecker())
|
|
14
|
+
: undefined;
|
|
15
|
+
return {
|
|
16
|
+
consoleRpc: createOnebot11ConsoleRpc(context.resources, () => context.config.get()),
|
|
17
|
+
...(dispose ? { dispose } : {}),
|
|
18
|
+
};
|
|
17
19
|
},
|
|
18
20
|
});
|
package/src/protocol.ts
CHANGED
|
@@ -5,6 +5,7 @@ import type { EndpointProfileConfiguration } from 'zhin.js/adapter';
|
|
|
5
5
|
* Spec: https://github.com/botuniverse/onebot-11
|
|
6
6
|
*/
|
|
7
7
|
import { EndpointDeliveryError, isMediaRef, type MediaRef, type ConversationRef } from '@zhin.js/im-contract';
|
|
8
|
+
import { toCanonicalSegments, type Segment } from '@zhin.js/core';
|
|
8
9
|
import { formatCompact, getLogger } from '@zhin.js/logger';
|
|
9
10
|
|
|
10
11
|
const logger = getLogger('onebot11');
|
|
@@ -261,6 +262,7 @@ export interface OneBot11InboundFields {
|
|
|
261
262
|
readonly endpointId: string;
|
|
262
263
|
readonly mentioned: boolean;
|
|
263
264
|
readonly replyTo: { readonly id: string } | undefined;
|
|
265
|
+
readonly segments?: readonly Segment[];
|
|
264
266
|
}
|
|
265
267
|
|
|
266
268
|
/** 构造 gateway.receive 的 metadata 与提升字段(ws / wss 两个 endpoint 共用)。 */
|
|
@@ -272,6 +274,7 @@ export function formatInboundMetadata(
|
|
|
272
274
|
const nickname = senderNickname(ev);
|
|
273
275
|
const quoteId = extractQuoteId(ev);
|
|
274
276
|
const mentioned = isOneBot11BotMentioned({ selfId, message: ev.message });
|
|
277
|
+
const segments = Array.isArray(ev.message) ? toCanonicalSegments(ev.message) : undefined;
|
|
275
278
|
return {
|
|
276
279
|
metadata: Object.freeze({
|
|
277
280
|
message_type: ev.message_type,
|
|
@@ -285,6 +288,7 @@ export function formatInboundMetadata(
|
|
|
285
288
|
endpointId: endpoint,
|
|
286
289
|
mentioned,
|
|
287
290
|
replyTo: quoteId ? { id: quoteId } : undefined,
|
|
291
|
+
...(segments?.length ? { segments } : {}),
|
|
288
292
|
};
|
|
289
293
|
}
|
|
290
294
|
|
package/src/ws-endpoint.ts
CHANGED
|
@@ -206,6 +206,7 @@ export class OneBot11WsEndpoint extends Onebot11Client implements Endpoint {
|
|
|
206
206
|
endpointId: inbound.endpointId,
|
|
207
207
|
...(inbound.mentioned ? { mentioned: true } : {}),
|
|
208
208
|
...(inbound.replyTo ? { replyTo: inbound.replyTo } : {}),
|
|
209
|
+
...(inbound.segments?.length ? { segments: inbound.segments } : {}),
|
|
209
210
|
metadata: inbound.metadata,
|
|
210
211
|
}).catch((err) => {
|
|
211
212
|
this.#logger.warn(formatCompact({
|
|
@@ -251,6 +252,7 @@ export class OneBot11WsEndpoint extends Onebot11Client implements Endpoint {
|
|
|
251
252
|
}
|
|
252
253
|
try {
|
|
253
254
|
ws.close();
|
|
255
|
+
ws.terminate?.();
|
|
254
256
|
} catch {
|
|
255
257
|
/* ignore */
|
|
256
258
|
}
|
package/src/ws-types.ts
CHANGED
|
@@ -3,6 +3,7 @@ export interface OneBot11WsSocket {
|
|
|
3
3
|
readonly readyState: number;
|
|
4
4
|
send(data: string): void;
|
|
5
5
|
close(code?: number, reason?: string): void;
|
|
6
|
+
terminate?(): void;
|
|
6
7
|
ping?(): void;
|
|
7
8
|
on(event: 'open' | 'message' | 'close' | 'error' | 'pong', listener: (...args: unknown[]) => void): void;
|
|
8
9
|
}
|
package/src/wss-endpoint.ts
CHANGED
|
@@ -208,6 +208,7 @@ export class OneBot11WssEndpoint extends Onebot11Client implements Endpoint {
|
|
|
208
208
|
endpointId: inbound.endpointId,
|
|
209
209
|
...(inbound.mentioned ? { mentioned: true } : {}),
|
|
210
210
|
...(inbound.replyTo ? { replyTo: inbound.replyTo } : {}),
|
|
211
|
+
...(inbound.segments?.length ? { segments: inbound.segments } : {}),
|
|
211
212
|
metadata: inbound.metadata,
|
|
212
213
|
}).catch((err) => {
|
|
213
214
|
this.#logger.warn(formatCompact({
|
|
@@ -257,6 +258,7 @@ export class OneBot11WssEndpoint extends Onebot11Client implements Endpoint {
|
|
|
257
258
|
}
|
|
258
259
|
try {
|
|
259
260
|
socket.close();
|
|
261
|
+
socket.terminate?.();
|
|
260
262
|
} catch {
|
|
261
263
|
/* ignore */
|
|
262
264
|
}
|