@zhin.js/adapter-icqq 1.1.2 → 1.1.4
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 +30 -0
- package/lib/endpoint.js +8 -26
- package/lib/icqq-inbound.js +40 -0
- package/lib/protocol.js +1 -1
- package/package.json +16 -16
- package/src/endpoint.ts +8 -27
- package/src/icqq-inbound.ts +39 -0
- package/src/protocol.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,35 @@
|
|
|
1
1
|
# @zhin.js/adapter-icqq
|
|
2
2
|
|
|
3
|
+
## 1.1.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 43eda99: Unify Notice and Request payloads with their public types and runtime exports. Use camelCase fields, preserve native data under metadata, and bind canonical endpoint identity and request actions to the held generation. Remove legacy data aliases and from factories.
|
|
8
|
+
|
|
9
|
+
Keep login and lifecycle signals as independent SystemEvent payloads on system.receive, without chat conversation fields or user interaction. Update built-in adapter projections and authoring guidance.
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [43eda99]
|
|
12
|
+
- Updated dependencies [0de4836]
|
|
13
|
+
- @zhin.js/core@1.1.39
|
|
14
|
+
- @zhin.js/permission@1.1.3
|
|
15
|
+
- @zhin.js/adapter@1.1.15
|
|
16
|
+
|
|
17
|
+
## 1.1.3
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- 5b5d270: Complete the canonical share segment contract and preserve native ICQQ share delivery through Core and AI outbound pipelines.
|
|
22
|
+
- Updated dependencies [5b5d270]
|
|
23
|
+
- Updated dependencies [36c2eb9]
|
|
24
|
+
- @zhin.js/im-contract@1.1.2
|
|
25
|
+
- @zhin.js/core@1.1.38
|
|
26
|
+
- @zhin.js/adapter@1.1.15
|
|
27
|
+
- @zhin.js/agent-feature@1.1.2
|
|
28
|
+
- @zhin.js/feature-kit@1.1.2
|
|
29
|
+
- @zhin.js/permission@1.1.2
|
|
30
|
+
- @zhin.js/skill@1.1.2
|
|
31
|
+
- @zhin.js/tool@1.1.2
|
|
32
|
+
|
|
3
33
|
## 1.1.2
|
|
4
34
|
|
|
5
35
|
### Patch Changes
|
package/lib/endpoint.js
CHANGED
|
@@ -2,7 +2,7 @@ import { Client, parseGroupMessageId, } from '@icqqjs/icqq';
|
|
|
2
2
|
import { inspect } from 'node:util';
|
|
3
3
|
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
4
4
|
import { Endpoint, } from 'zhin.js/adapter';
|
|
5
|
-
import { receiveOneBotLikeSideEvent,
|
|
5
|
+
import { receiveOneBotLikeSideEvent, buildSystem, toCanonicalSegments } from '@zhin.js/core';
|
|
6
6
|
import { formatCompact, getAdapterLogger, truncatePreview } from '@zhin.js/logger';
|
|
7
7
|
import { runIcqqLoginAssistStep } from './icqq-login-assist.js';
|
|
8
8
|
import { IcqqContentResolver } from './content-resolver.js';
|
|
@@ -578,16 +578,13 @@ export class IcqqEndpoint extends Endpoint {
|
|
|
578
578
|
});
|
|
579
579
|
}
|
|
580
580
|
#dispatchIcqqSystemSideEvent(type, payload) {
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
$scene_type: scene_type,
|
|
589
|
-
$sub_type: sub_type,
|
|
590
|
-
$timestamp: Date.now(),
|
|
581
|
+
void this.emit('system.receive', buildSystem(payload ?? {}, {
|
|
582
|
+
id: `system:${this.endpointName}:${type}:${Date.now()}`,
|
|
583
|
+
clientAdapter: 'icqq',
|
|
584
|
+
endpointId: this.endpointName,
|
|
585
|
+
type: 'system',
|
|
586
|
+
name: `system.${type}`,
|
|
587
|
+
timestamp: Date.now(),
|
|
591
588
|
})).catch((err) => {
|
|
592
589
|
this.#logger.warn(formatCompact({
|
|
593
590
|
op: 'icqq_system_side_event_failed',
|
|
@@ -984,20 +981,5 @@ function serializeIcqqEvent(event) {
|
|
|
984
981
|
}
|
|
985
982
|
return Object.keys(out).length > 0 ? out : null;
|
|
986
983
|
}
|
|
987
|
-
function parseIcqqSystemScene(type) {
|
|
988
|
-
if (type.startsWith('login.')) {
|
|
989
|
-
return { scene_type: 'login', sub_type: type.slice('login.'.length) || 'unknown' };
|
|
990
|
-
}
|
|
991
|
-
if (type.startsWith('offline.')) {
|
|
992
|
-
return { scene_type: 'offline', sub_type: type.slice('offline.'.length) || 'unknown' };
|
|
993
|
-
}
|
|
994
|
-
if (type === 'online') {
|
|
995
|
-
return { scene_type: 'online', sub_type: 'online' };
|
|
996
|
-
}
|
|
997
|
-
if (type === 'offline') {
|
|
998
|
-
return { scene_type: 'offline', sub_type: 'offline' };
|
|
999
|
-
}
|
|
1000
|
-
return { scene_type: 'system', sub_type: type };
|
|
1001
|
-
}
|
|
1002
984
|
const INBOUND_HOLD_LIMIT = 32;
|
|
1003
985
|
const ICQQ_SERIALIZE_SKIP = ['group', 'member', 'friend', 'discuss', 'client'];
|
package/lib/icqq-inbound.js
CHANGED
|
@@ -360,6 +360,46 @@ export function icqqElementsToSegments(elements) {
|
|
|
360
360
|
});
|
|
361
361
|
break;
|
|
362
362
|
}
|
|
363
|
+
case "share": {
|
|
364
|
+
const url = typeof el.url === "string" ? el.url.trim() : "";
|
|
365
|
+
const title = typeof el.title === "string" ? el.title.trim() : "";
|
|
366
|
+
if (!url || !title)
|
|
367
|
+
break;
|
|
368
|
+
const description = typeof el.summary === "string" && el.summary
|
|
369
|
+
? el.summary
|
|
370
|
+
: undefined;
|
|
371
|
+
const image = typeof el.image === "string" && el.image ? el.image : undefined;
|
|
372
|
+
const audio = typeof el.audio === "string" && el.audio ? el.audio : undefined;
|
|
373
|
+
const content = typeof el.content === "string" && el.content ? el.content : undefined;
|
|
374
|
+
const rawConfig = el.config && typeof el.config === "object" && !Array.isArray(el.config)
|
|
375
|
+
? el.config
|
|
376
|
+
: undefined;
|
|
377
|
+
const appid = Number(rawConfig?.appid);
|
|
378
|
+
const config = Number.isSafeInteger(appid) && appid > 0
|
|
379
|
+
? {
|
|
380
|
+
appid,
|
|
381
|
+
...(typeof rawConfig?.appname === "string" && rawConfig.appname
|
|
382
|
+
? { package: rawConfig.appname }
|
|
383
|
+
: {}),
|
|
384
|
+
...(typeof rawConfig?.appsign === "string" && rawConfig.appsign
|
|
385
|
+
? { sign: rawConfig.appsign }
|
|
386
|
+
: {}),
|
|
387
|
+
}
|
|
388
|
+
: undefined;
|
|
389
|
+
out.push({
|
|
390
|
+
type: "share",
|
|
391
|
+
data: {
|
|
392
|
+
url,
|
|
393
|
+
title,
|
|
394
|
+
...(description ? { description } : {}),
|
|
395
|
+
...(image ? { image } : {}),
|
|
396
|
+
...(audio ? { audio } : {}),
|
|
397
|
+
...(content ? { content } : {}),
|
|
398
|
+
...(config ? { config } : {}),
|
|
399
|
+
},
|
|
400
|
+
});
|
|
401
|
+
break;
|
|
402
|
+
}
|
|
363
403
|
default:
|
|
364
404
|
if (el.text != null && el.text !== "") {
|
|
365
405
|
out.push({ type: "text", data: { text: String(el.text) } });
|
package/lib/protocol.js
CHANGED
|
@@ -405,7 +405,7 @@ function formatShare(data) {
|
|
|
405
405
|
...(appsign ? { appsign } : {}),
|
|
406
406
|
}
|
|
407
407
|
: undefined;
|
|
408
|
-
const summary = optionalString(data.artist);
|
|
408
|
+
const summary = optionalString(data.description) ?? optionalString(data.artist);
|
|
409
409
|
const content = optionalString(data.content);
|
|
410
410
|
const image = optionalString(data.image);
|
|
411
411
|
const audio = optionalString(data.audio);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zhin.js/adapter-icqq",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.4",
|
|
4
4
|
"description": "Zhin.js ICQQ adapter — direct connection to @icqqjs/icqq",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./lib/index.js",
|
|
@@ -34,24 +34,24 @@
|
|
|
34
34
|
"directory": "plugins/adapters/icqq"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@zhin.js/adapter": "1.1.
|
|
38
|
-
"@zhin.js/agent-feature": "1.1.
|
|
39
|
-
"@zhin.js/core": "1.1.
|
|
40
|
-
"@zhin.js/feature-kit": "1.1.
|
|
41
|
-
"@zhin.js/im-contract": "1.1.
|
|
37
|
+
"@zhin.js/adapter": "1.1.15",
|
|
38
|
+
"@zhin.js/agent-feature": "1.1.2",
|
|
39
|
+
"@zhin.js/core": "1.1.39",
|
|
40
|
+
"@zhin.js/feature-kit": "1.1.2",
|
|
41
|
+
"@zhin.js/im-contract": "1.1.2",
|
|
42
42
|
"@zhin.js/logger": "1.1.1",
|
|
43
|
-
"@zhin.js/permission": "1.1.
|
|
44
|
-
"@zhin.js/skill": "1.1.
|
|
45
|
-
"@zhin.js/tool": "1.1.
|
|
43
|
+
"@zhin.js/permission": "1.1.3",
|
|
44
|
+
"@zhin.js/skill": "1.1.2",
|
|
45
|
+
"@zhin.js/tool": "1.1.2"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
48
|
"@icqqjs/icqq": "^1.12.2",
|
|
49
49
|
"zod": "^4.0.0",
|
|
50
|
-
"@zhin.js/adapter": "^1.1.
|
|
51
|
-
"@zhin.js/command": "^1.1.
|
|
52
|
-
"@zhin.js/core": "^1.1.
|
|
53
|
-
"@zhin.js/prompt-section": "^1.1.
|
|
54
|
-
"zhin.js": "^1.1.
|
|
50
|
+
"@zhin.js/adapter": "^1.1.15",
|
|
51
|
+
"@zhin.js/command": "^1.1.3",
|
|
52
|
+
"@zhin.js/core": "^1.1.39",
|
|
53
|
+
"@zhin.js/prompt-section": "^1.1.2",
|
|
54
|
+
"zhin.js": "^1.1.4"
|
|
55
55
|
},
|
|
56
56
|
"peerDependenciesMeta": {
|
|
57
57
|
"@icqqjs/icqq": {
|
|
@@ -76,8 +76,8 @@
|
|
|
76
76
|
"typescript": "^6.0.3",
|
|
77
77
|
"vitest": "^4.1.10",
|
|
78
78
|
"zod": "^4.4.3",
|
|
79
|
-
"@zhin.js/prompt-section": "1.1.
|
|
80
|
-
"zhin.js": "1.1.
|
|
79
|
+
"@zhin.js/prompt-section": "1.1.2",
|
|
80
|
+
"zhin.js": "1.1.4"
|
|
81
81
|
},
|
|
82
82
|
"files": [
|
|
83
83
|
"adapters",
|
package/src/endpoint.ts
CHANGED
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
type EndpointSendRequest,
|
|
19
19
|
} from 'zhin.js/adapter';
|
|
20
20
|
import type { EndpointContentPort } from '@zhin.js/adapter';
|
|
21
|
-
import { receiveOneBotLikeSideEvent,
|
|
21
|
+
import { receiveOneBotLikeSideEvent, buildSystem, toCanonicalSegments, type LoginAssist } from '@zhin.js/core';
|
|
22
22
|
import type { MessageRef } from '@zhin.js/im-contract';
|
|
23
23
|
import { formatCompact, getAdapterLogger, truncatePreview } from '@zhin.js/logger';
|
|
24
24
|
import type { CapabilityId } from 'zhin.js';
|
|
@@ -659,16 +659,13 @@ export class IcqqEndpoint extends Endpoint<Client> {
|
|
|
659
659
|
}
|
|
660
660
|
|
|
661
661
|
#dispatchIcqqSystemSideEvent(type: string, payload: Record<string, unknown> | null): void {
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
$scene_type: scene_type,
|
|
670
|
-
$sub_type: sub_type,
|
|
671
|
-
$timestamp: Date.now(),
|
|
662
|
+
void this.emit('system.receive', buildSystem(payload ?? {}, {
|
|
663
|
+
id: `system:${this.endpointName}:${type}:${Date.now()}`,
|
|
664
|
+
clientAdapter: 'icqq',
|
|
665
|
+
endpointId: this.endpointName,
|
|
666
|
+
type: 'system',
|
|
667
|
+
name: `system.${type}`,
|
|
668
|
+
timestamp: Date.now(),
|
|
672
669
|
})).catch((err) => {
|
|
673
670
|
this.#logger.warn(formatCompact({
|
|
674
671
|
op: 'icqq_system_side_event_failed',
|
|
@@ -1063,22 +1060,6 @@ function serializeIcqqEvent(event: unknown): Record<string, unknown> | null {
|
|
|
1063
1060
|
return Object.keys(out).length > 0 ? out : null;
|
|
1064
1061
|
}
|
|
1065
1062
|
|
|
1066
|
-
function parseIcqqSystemScene(type: string): { scene_type: string; sub_type: string } {
|
|
1067
|
-
if (type.startsWith('login.')) {
|
|
1068
|
-
return { scene_type: 'login', sub_type: type.slice('login.'.length) || 'unknown' };
|
|
1069
|
-
}
|
|
1070
|
-
if (type.startsWith('offline.')) {
|
|
1071
|
-
return { scene_type: 'offline', sub_type: type.slice('offline.'.length) || 'unknown' };
|
|
1072
|
-
}
|
|
1073
|
-
if (type === 'online') {
|
|
1074
|
-
return { scene_type: 'online', sub_type: 'online' };
|
|
1075
|
-
}
|
|
1076
|
-
if (type === 'offline') {
|
|
1077
|
-
return { scene_type: 'offline', sub_type: 'offline' };
|
|
1078
|
-
}
|
|
1079
|
-
return { scene_type: 'system', sub_type: type };
|
|
1080
|
-
}
|
|
1081
|
-
|
|
1082
1063
|
const INBOUND_HOLD_LIMIT = 32;
|
|
1083
1064
|
|
|
1084
1065
|
const ICQQ_SERIALIZE_SKIP = ['group', 'member', 'friend', 'discuss', 'client'] as const;
|
package/src/icqq-inbound.ts
CHANGED
|
@@ -500,6 +500,45 @@ export function icqqElementsToSegments(
|
|
|
500
500
|
});
|
|
501
501
|
break;
|
|
502
502
|
}
|
|
503
|
+
case "share": {
|
|
504
|
+
const url = typeof el.url === "string" ? el.url.trim() : "";
|
|
505
|
+
const title = typeof el.title === "string" ? el.title.trim() : "";
|
|
506
|
+
if (!url || !title) break;
|
|
507
|
+
const description = typeof el.summary === "string" && el.summary
|
|
508
|
+
? el.summary
|
|
509
|
+
: undefined;
|
|
510
|
+
const image = typeof el.image === "string" && el.image ? el.image : undefined;
|
|
511
|
+
const audio = typeof el.audio === "string" && el.audio ? el.audio : undefined;
|
|
512
|
+
const content = typeof el.content === "string" && el.content ? el.content : undefined;
|
|
513
|
+
const rawConfig = el.config && typeof el.config === "object" && !Array.isArray(el.config)
|
|
514
|
+
? el.config as Record<string, unknown>
|
|
515
|
+
: undefined;
|
|
516
|
+
const appid = Number(rawConfig?.appid);
|
|
517
|
+
const config = Number.isSafeInteger(appid) && appid > 0
|
|
518
|
+
? {
|
|
519
|
+
appid,
|
|
520
|
+
...(typeof rawConfig?.appname === "string" && rawConfig.appname
|
|
521
|
+
? { package: rawConfig.appname }
|
|
522
|
+
: {}),
|
|
523
|
+
...(typeof rawConfig?.appsign === "string" && rawConfig.appsign
|
|
524
|
+
? { sign: rawConfig.appsign }
|
|
525
|
+
: {}),
|
|
526
|
+
}
|
|
527
|
+
: undefined;
|
|
528
|
+
out.push({
|
|
529
|
+
type: "share",
|
|
530
|
+
data: {
|
|
531
|
+
url,
|
|
532
|
+
title,
|
|
533
|
+
...(description ? { description } : {}),
|
|
534
|
+
...(image ? { image } : {}),
|
|
535
|
+
...(audio ? { audio } : {}),
|
|
536
|
+
...(content ? { content } : {}),
|
|
537
|
+
...(config ? { config } : {}),
|
|
538
|
+
},
|
|
539
|
+
});
|
|
540
|
+
break;
|
|
541
|
+
}
|
|
503
542
|
default:
|
|
504
543
|
if (el.text != null && el.text !== "") {
|
|
505
544
|
out.push({ type: "text", data: { text: String(el.text) } });
|
package/src/protocol.ts
CHANGED
|
@@ -533,7 +533,7 @@ function formatShare(data: Record<string, unknown> | undefined): ShareElem {
|
|
|
533
533
|
...(appsign ? { appsign } : {}),
|
|
534
534
|
}
|
|
535
535
|
: undefined;
|
|
536
|
-
const summary = optionalString(data.artist);
|
|
536
|
+
const summary = optionalString(data.description) ?? optionalString(data.artist);
|
|
537
537
|
const content = optionalString(data.content);
|
|
538
538
|
const image = optionalString(data.image);
|
|
539
539
|
const audio = optionalString(data.audio);
|