@zhin.js/adapter-kook 1.1.21 → 1.1.22
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 +35 -0
- package/adapters/kook/index.js +17 -5
- package/adapters/kook/index.ts +17 -5
- package/lib/side-event-dispatch.js +4 -3
- package/lib/side-event-map.d.ts +5 -0
- package/lib/side-event-map.js +15 -0
- package/package.json +18 -18
- package/plugin.js +1 -0
- package/src/side-event-dispatch.ts +4 -3
- package/src/side-event-map.ts +18 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,40 @@
|
|
|
1
1
|
# @zhin.js/adapter-kook
|
|
2
2
|
|
|
3
|
+
## 1.1.22
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- b249e5e: ADR 0044 C4:事件映射迁出 core。新增 `@zhin.js/adapter-onebot-events`,承载 OneBot v11 / NapCat / icqq 的原始通知与请求 → 标准事件映射(`receiveOneBotLikeSideEvent`、`mapNoticeParts`、`mapRequestParts`、`resolveSideEventDedupeKey` 及 OneBot 映射表,icqq 差异用覆盖表表达);KOOK、Slack 的映射迁入各自适配器;`@zhin.js/core` 只保留标准事件名、类型与 `buildNotice` / `buildRequest` / `buildSystem` / `senderFromId`,不再含任何平台名。core 不再导出上述映射函数与 `ONEBOT_/KOOK_/SLACK_NOTICE_PARTS_MAP`、`SideEventPlatform`、`OneBotLike*` 类型,适配器改从共享包导入。
|
|
8
|
+
- 41ff1a5: ADR 0044 C5: every official adapter now declares a capability `profile` (its `segments` moved into `profile.default.messaging.segments`). icqq declares the complete profile (per conversation kind: scene, all 14 actions with real limits, events, feedback, delivery) and implements the seven new management ports (`pokeUser`, `unmuteGroupMember`, `muteAllGroupMembers`, `setGroupCard`, `setGroupTitle`, `setGroupEssence`, `inviteGroupMember`) with fresh bot-role reads. qq official declares its passive reply windows; undeclared capabilities stay unsupported.
|
|
9
|
+
- cbd3f14: ADR 0044 integration and C6 guard. `delivery.spool` now reproduces the pre-0044 media rule (icqq `false`, every other official adapter `true`). icqq narrows `actions.recall.others` unless the Bot is admin or owner, and declares recall for groups. Endpoint kind capabilities merge the Endpoint's `operations` (Discord reactions keep working; Discord declares reaction feedback). Adapters in the `@zhin.js/` scope are trusted: their custom prompt text is not labelled `external_content`. Core no longer keeps a telegram/discord interactive-policy table (adapters declare `segments.interactive`). New `pnpm check:no-platform-branches` blocks platform-name branches in runtime code.
|
|
10
|
+
- 4fe49b5: 支持配置按需生效:分离保存与有效版本,独立变更先应用,账号资料更新保留连接,模型按回合使用确定版本;Console 返回结构化应用结果。监听改为仅显式 --watch 启用,开发模板显式选择源码和配置监听。
|
|
11
|
+
|
|
12
|
+
自变更消费配置应用回执,避免已处理配置被二次重载;持久化本次写入修订和应用结果,未知结果或修订冲突时停止自动续作并保留现场,恢复不会覆盖未经本次变更确认的配置。
|
|
13
|
+
|
|
14
|
+
- Updated dependencies [b249e5e]
|
|
15
|
+
- Updated dependencies [57661f6]
|
|
16
|
+
- Updated dependencies [cbd3f14]
|
|
17
|
+
- Updated dependencies [299863a]
|
|
18
|
+
- Updated dependencies [aaa93d7]
|
|
19
|
+
- Updated dependencies [bd524d1]
|
|
20
|
+
- Updated dependencies [126ae99]
|
|
21
|
+
- Updated dependencies [4fe49b5]
|
|
22
|
+
- Updated dependencies [cce07db]
|
|
23
|
+
- Updated dependencies [b652db3]
|
|
24
|
+
- Updated dependencies [0315ba0]
|
|
25
|
+
- Updated dependencies [00be764]
|
|
26
|
+
- @zhin.js/core@1.1.56
|
|
27
|
+
- @zhin.js/adapter@1.1.28
|
|
28
|
+
- @zhin.js/im-contract@1.1.11
|
|
29
|
+
- @zhin.js/tool@1.1.15
|
|
30
|
+
- @zhin.js/skill@1.1.13
|
|
31
|
+
- @zhin.js/host-http@1.1.14
|
|
32
|
+
- @zhin.js/feature-kit@1.1.12
|
|
33
|
+
- @zhin.js/client@1.1.24
|
|
34
|
+
- @zhin.js/page@1.1.14
|
|
35
|
+
- @zhin.js/agent-feature@1.1.13
|
|
36
|
+
- @zhin.js/permission@1.1.12
|
|
37
|
+
|
|
3
38
|
## 1.1.21
|
|
4
39
|
|
|
5
40
|
### Patch Changes
|
package/adapters/kook/index.js
CHANGED
|
@@ -9,13 +9,25 @@ import {} from "../../lib/protocol.js";
|
|
|
9
9
|
export { KookWebhookEndpoint, KookWebsocketEndpoint, } from "../../lib/endpoint.js";
|
|
10
10
|
export default defineAdapter({
|
|
11
11
|
capabilities: ['inbound', 'outbound'],
|
|
12
|
-
operations: ['recall'],
|
|
13
12
|
// KOOK 图片上传后以原生卡片保留图文混排;KMarkdown 原生消费;
|
|
14
13
|
// 原生卡片按钮经 return-val 事件进入 canonical action 链路。
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
profile: {
|
|
15
|
+
default: {
|
|
16
|
+
messaging: {
|
|
17
|
+
segments: {
|
|
18
|
+
outboundMedia: ['url', 'upload'],
|
|
19
|
+
interactive: 'native',
|
|
20
|
+
markdown: 'native',
|
|
21
|
+
},
|
|
22
|
+
quote: true,
|
|
23
|
+
recall: {},
|
|
24
|
+
},
|
|
25
|
+
actions: {
|
|
26
|
+
recall: { scopes: ['private', 'group', 'channel'] },
|
|
27
|
+
quoteReply: { scopes: ['private', 'group', 'channel'] },
|
|
28
|
+
},
|
|
29
|
+
delivery: { send: true, proactive: true, spool: true },
|
|
30
|
+
},
|
|
19
31
|
},
|
|
20
32
|
createAdapter: context => new KookAdapter(context),
|
|
21
33
|
});
|
package/adapters/kook/index.ts
CHANGED
|
@@ -20,13 +20,25 @@ export type { KookClientTransport } from '../../src/ws.js';
|
|
|
20
20
|
|
|
21
21
|
export default defineAdapter<KookEndpointConfig>({
|
|
22
22
|
capabilities: ['inbound', 'outbound'],
|
|
23
|
-
operations: ['recall'],
|
|
24
23
|
// KOOK 图片上传后以原生卡片保留图文混排;KMarkdown 原生消费;
|
|
25
24
|
// 原生卡片按钮经 return-val 事件进入 canonical action 链路。
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
profile: {
|
|
26
|
+
default: {
|
|
27
|
+
messaging: {
|
|
28
|
+
segments: {
|
|
29
|
+
outboundMedia: ['url', 'upload'],
|
|
30
|
+
interactive: 'native',
|
|
31
|
+
markdown: 'native',
|
|
32
|
+
},
|
|
33
|
+
quote: true,
|
|
34
|
+
recall: {},
|
|
35
|
+
},
|
|
36
|
+
actions: {
|
|
37
|
+
recall: { scopes: ['private', 'group', 'channel'] },
|
|
38
|
+
quoteReply: { scopes: ['private', 'group', 'channel'] },
|
|
39
|
+
},
|
|
40
|
+
delivery: { send: true, proactive: true, spool: true },
|
|
41
|
+
},
|
|
30
42
|
},
|
|
31
43
|
createAdapter: context => new KookAdapter(context),
|
|
32
44
|
});
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { composeSideEventName, buildNotice,
|
|
1
|
+
import { composeSideEventName, buildNotice, senderFromId } from '@zhin.js/core';
|
|
2
2
|
import { formatCompact } from '@zhin.js/logger';
|
|
3
|
+
import { mapKookNoticeParts } from './side-event-map.js';
|
|
3
4
|
function extractKookNoticeType(raw) {
|
|
4
5
|
if (!raw || typeof raw !== 'object')
|
|
5
6
|
return null;
|
|
@@ -16,10 +17,10 @@ export function receiveKookSideEvent(emit, configId, raw, logger) {
|
|
|
16
17
|
const noticeType = extractKookNoticeType(raw);
|
|
17
18
|
if (!noticeType)
|
|
18
19
|
return false;
|
|
19
|
-
|
|
20
|
+
const parts = mapKookNoticeParts(noticeType);
|
|
21
|
+
if (!parts)
|
|
20
22
|
return false;
|
|
21
23
|
const event = raw;
|
|
22
|
-
const parts = mapNoticeParts('kook', noticeType);
|
|
23
24
|
const body = event.extra?.body;
|
|
24
25
|
const guildId = event.extra?.guild_id
|
|
25
26
|
?? (event.channel_type === 'GROUP' && event.type === 255 ? event.target_id : undefined);
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { SideEventParts } from '@zhin.js/core';
|
|
2
|
+
/** KOOK extra.type 原始值 → 标准 scene_type + sub_type */
|
|
3
|
+
export declare const KOOK_NOTICE_PARTS_MAP: Readonly<Record<string, SideEventParts>>;
|
|
4
|
+
/** 已登记的 KOOK 通知映射为标准 scene_type + sub_type;未登记返回 undefined。 */
|
|
5
|
+
export declare function mapKookNoticeParts(raw: string): SideEventParts | undefined;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** KOOK extra.type 原始值 → 标准 scene_type + sub_type */
|
|
2
|
+
export const KOOK_NOTICE_PARTS_MAP = {
|
|
3
|
+
joined_guild: { scene_type: 'group', sub_type: 'member_increase' },
|
|
4
|
+
exited_guild: { scene_type: 'group', sub_type: 'member_decrease' },
|
|
5
|
+
deleted_message: { scene_type: 'group', sub_type: 'recall' },
|
|
6
|
+
deleted_private_message: { scene_type: 'friend', sub_type: 'recall' },
|
|
7
|
+
added_reaction: { scene_type: 'group', sub_type: 'emoji_reaction' },
|
|
8
|
+
deleted_reaction: { scene_type: 'group', sub_type: 'emoji_reaction' },
|
|
9
|
+
private_added_reaction: { scene_type: 'group', sub_type: 'emoji_reaction' },
|
|
10
|
+
private_deleted_reaction: { scene_type: 'group', sub_type: 'emoji_reaction' },
|
|
11
|
+
};
|
|
12
|
+
/** 已登记的 KOOK 通知映射为标准 scene_type + sub_type;未登记返回 undefined。 */
|
|
13
|
+
export function mapKookNoticeParts(raw) {
|
|
14
|
+
return Object.prototype.hasOwnProperty.call(KOOK_NOTICE_PARTS_MAP, raw) ? KOOK_NOTICE_PARTS_MAP[raw] : undefined;
|
|
15
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zhin.js/adapter-kook",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.22",
|
|
4
4
|
"description": "Zhin.js KOOK adapter for Plugin Runtime (WebSocket gateway or Webhook)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./lib/index.js",
|
|
@@ -33,26 +33,26 @@
|
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"kook-client": "^1.0.5",
|
|
36
|
-
"@zhin.js/adapter": "1.1.
|
|
37
|
-
"@zhin.js/agent-feature": "1.1.
|
|
38
|
-
"@zhin.js/client": "1.1.
|
|
36
|
+
"@zhin.js/adapter": "1.1.28",
|
|
37
|
+
"@zhin.js/agent-feature": "1.1.13",
|
|
38
|
+
"@zhin.js/client": "1.1.24",
|
|
39
39
|
"@zhin.js/console-contract": "1.1.3",
|
|
40
|
-
"@zhin.js/core": "1.1.
|
|
41
|
-
"@zhin.js/feature-kit": "1.1.
|
|
42
|
-
"@zhin.js/host-http": "1.1.
|
|
43
|
-
"@zhin.js/im-contract": "1.1.
|
|
40
|
+
"@zhin.js/core": "1.1.56",
|
|
41
|
+
"@zhin.js/feature-kit": "1.1.12",
|
|
42
|
+
"@zhin.js/host-http": "1.1.14",
|
|
43
|
+
"@zhin.js/im-contract": "1.1.11",
|
|
44
44
|
"@zhin.js/logger": "1.1.2",
|
|
45
|
-
"@zhin.js/page": "1.1.
|
|
46
|
-
"@zhin.js/permission": "1.1.
|
|
47
|
-
"@zhin.js/skill": "1.1.
|
|
48
|
-
"@zhin.js/tool": "1.1.
|
|
45
|
+
"@zhin.js/page": "1.1.14",
|
|
46
|
+
"@zhin.js/permission": "1.1.12",
|
|
47
|
+
"@zhin.js/skill": "1.1.13",
|
|
48
|
+
"@zhin.js/tool": "1.1.15"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
51
|
"zod": "^4.0.0",
|
|
52
|
-
"@zhin.js/adapter": "^1.1.
|
|
53
|
-
"@zhin.js/command": "^1.1.
|
|
54
|
-
"@zhin.js/core": "^1.1.
|
|
55
|
-
"zhin.js": "^1.1.
|
|
52
|
+
"@zhin.js/adapter": "^1.1.28",
|
|
53
|
+
"@zhin.js/command": "^1.1.14",
|
|
54
|
+
"@zhin.js/core": "^1.1.56",
|
|
55
|
+
"zhin.js": "^1.1.21"
|
|
56
56
|
},
|
|
57
57
|
"peerDependenciesMeta": {
|
|
58
58
|
"@zhin.js/command": {
|
|
@@ -70,8 +70,8 @@
|
|
|
70
70
|
"typescript": "^6.0.3",
|
|
71
71
|
"vitest": "^4.1.10",
|
|
72
72
|
"zod": "^4.4.3",
|
|
73
|
-
"@zhin.js/host-http": "1.1.
|
|
74
|
-
"zhin.js": "1.1.
|
|
73
|
+
"@zhin.js/host-http": "1.1.14",
|
|
74
|
+
"zhin.js": "1.1.21"
|
|
75
75
|
},
|
|
76
76
|
"files": [
|
|
77
77
|
"adapters",
|
package/plugin.js
CHANGED
|
@@ -5,6 +5,7 @@ import { checkKookPlatformPermit } from "./lib/platform-permit.js";
|
|
|
5
5
|
import { createKookConsoleRpc } from "./lib/console.js";
|
|
6
6
|
export default definePlugin({
|
|
7
7
|
name: 'kook',
|
|
8
|
+
configUpdate: { featurePaths: [['nickname'], ['profile'], ['endpoints']] },
|
|
8
9
|
metadata: {
|
|
9
10
|
displayName: 'KOOK WebSocket Adapter',
|
|
10
11
|
},
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { composeSideEventName, buildNotice,
|
|
1
|
+
import { composeSideEventName, buildNotice, senderFromId } from '@zhin.js/core';
|
|
2
2
|
import type { EndpointEventEmitter } from 'zhin.js/adapter';
|
|
3
3
|
import { formatCompact, type getAdapterLogger } from '@zhin.js/logger';
|
|
4
4
|
import type { KookWebhookEventData } from './protocol.js';
|
|
5
|
+
import { mapKookNoticeParts } from './side-event-map.js';
|
|
5
6
|
|
|
6
7
|
function extractKookNoticeType(raw: unknown): string | null {
|
|
7
8
|
if (!raw || typeof raw !== 'object') return null;
|
|
@@ -22,9 +23,9 @@ export function receiveKookSideEvent(
|
|
|
22
23
|
): boolean {
|
|
23
24
|
const noticeType = extractKookNoticeType(raw);
|
|
24
25
|
if (!noticeType) return false;
|
|
25
|
-
|
|
26
|
+
const parts = mapKookNoticeParts(noticeType);
|
|
27
|
+
if (!parts) return false;
|
|
26
28
|
const event = raw as KookWebhookEventData;
|
|
27
|
-
const parts = mapNoticeParts('kook', noticeType);
|
|
28
29
|
const body = event.extra?.body;
|
|
29
30
|
const guildId = event.extra?.guild_id
|
|
30
31
|
?? (event.channel_type === 'GROUP' && event.type === 255 ? event.target_id : undefined);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { SideEventParts } from '@zhin.js/core';
|
|
2
|
+
|
|
3
|
+
/** KOOK extra.type 原始值 → 标准 scene_type + sub_type */
|
|
4
|
+
export const KOOK_NOTICE_PARTS_MAP: Readonly<Record<string, SideEventParts>> = {
|
|
5
|
+
joined_guild: { scene_type: 'group', sub_type: 'member_increase' },
|
|
6
|
+
exited_guild: { scene_type: 'group', sub_type: 'member_decrease' },
|
|
7
|
+
deleted_message: { scene_type: 'group', sub_type: 'recall' },
|
|
8
|
+
deleted_private_message: { scene_type: 'friend', sub_type: 'recall' },
|
|
9
|
+
added_reaction: { scene_type: 'group', sub_type: 'emoji_reaction' },
|
|
10
|
+
deleted_reaction: { scene_type: 'group', sub_type: 'emoji_reaction' },
|
|
11
|
+
private_added_reaction: { scene_type: 'group', sub_type: 'emoji_reaction' },
|
|
12
|
+
private_deleted_reaction: { scene_type: 'group', sub_type: 'emoji_reaction' },
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
/** 已登记的 KOOK 通知映射为标准 scene_type + sub_type;未登记返回 undefined。 */
|
|
16
|
+
export function mapKookNoticeParts(raw: string): SideEventParts | undefined {
|
|
17
|
+
return Object.prototype.hasOwnProperty.call(KOOK_NOTICE_PARTS_MAP, raw) ? KOOK_NOTICE_PARTS_MAP[raw] : undefined;
|
|
18
|
+
}
|