@zhin.js/adapter-kook 1.1.22 → 1.1.23
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 +33 -0
- package/lib/sender-roles.d.ts +0 -8
- package/lib/sender-roles.js +14 -16
- package/package.json +18 -18
- package/src/sender-roles.ts +6 -16
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,38 @@
|
|
|
1
1
|
# @zhin.js/adapter-kook
|
|
2
2
|
|
|
3
|
+
## 1.1.23
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- bc6ccb1: Deep audit bug fixes and 7 architectural improvements:
|
|
8
|
+
- 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.
|
|
9
|
+
- 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'`).
|
|
10
|
+
- 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.
|
|
11
|
+
- Push down `DatabaseContextRepository` and `DatabaseScheduleJobStorage` full-session/full-table memory scans to indexed SQL queries.
|
|
12
|
+
- Add kernel-level inbound `replyTo` and `mentioned` auto-promotion (`promoteInboundMessagePayload`) plus reusable `InboundDeduper` and `TtlLookupCache` primitives in `@zhin.js/adapter`.
|
|
13
|
+
- Add `MiddlewareContext.dispatch` (`InboundDispatchSummary`) and `onAfterDispatch` hooks for `after-dispatch` middlewares, and support incremental rendering of in-place `envelope.payload` array mutations in `OutboundDeliveryRuntime`.
|
|
14
|
+
- Unify `HistoryWindowTracker` and `AgentCompactionRuntime` token/message budgets (`resolveUnifiedHistoryAndCompactionBudget`).
|
|
15
|
+
- 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.
|
|
16
|
+
- Updated dependencies [3a8504b]
|
|
17
|
+
- Updated dependencies [6163abc]
|
|
18
|
+
- Updated dependencies [fed2c27]
|
|
19
|
+
- Updated dependencies [bc6ccb1]
|
|
20
|
+
- Updated dependencies [72b5a12]
|
|
21
|
+
- Updated dependencies [aa41889]
|
|
22
|
+
- Updated dependencies [4427e72]
|
|
23
|
+
- Updated dependencies [22bd14a]
|
|
24
|
+
- @zhin.js/agent-feature@1.1.14
|
|
25
|
+
- @zhin.js/core@1.1.57
|
|
26
|
+
- @zhin.js/client@1.1.25
|
|
27
|
+
- @zhin.js/page@1.1.15
|
|
28
|
+
- @zhin.js/im-contract@1.1.12
|
|
29
|
+
- @zhin.js/adapter@1.1.29
|
|
30
|
+
- @zhin.js/host-http@1.1.15
|
|
31
|
+
- @zhin.js/feature-kit@1.1.13
|
|
32
|
+
- @zhin.js/tool@1.1.16
|
|
33
|
+
- @zhin.js/permission@1.1.13
|
|
34
|
+
- @zhin.js/skill@1.1.14
|
|
35
|
+
|
|
3
36
|
## 1.1.22
|
|
4
37
|
|
|
5
38
|
### Patch Changes
|
package/lib/sender-roles.d.ts
CHANGED
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* KOOK 入站发送者角色投影。
|
|
3
|
-
*
|
|
4
|
-
* 事件只携带数字角色 id,无法直接判断群主 / 管理员;这里按服务器缓存
|
|
5
|
-
* guild.view(群主 id)与 guild-role.list(角色权限位),把发送者投影为
|
|
6
|
-
* 跨平台规范角色 owner / admin。原始角色 id 以 `role:<id>` 形式放入 permissions,
|
|
7
|
-
* 不进入 `sender.roles`。
|
|
8
|
-
*/
|
|
9
1
|
import type { KookClientTransport } from './ws.js';
|
|
10
2
|
export interface KookSenderRoleProjection {
|
|
11
3
|
/** 规范角色:owner / admin;普通成员为 undefined。 */
|
package/lib/sender-roles.js
CHANGED
|
@@ -1,11 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* KOOK 入站发送者角色投影。
|
|
3
|
+
*
|
|
4
|
+
* 事件只携带数字角色 id,无法直接判断群主 / 管理员;这里按服务器缓存
|
|
5
|
+
* guild.view(群主 id)与 guild-role.list(角色权限位),把发送者投影为
|
|
6
|
+
* 跨平台规范角色 owner / admin。原始角色 id 以 `role:<id>` 形式放入 permissions,
|
|
7
|
+
* 不进入 `sender.roles`。
|
|
8
|
+
*/
|
|
9
|
+
import { TtlLookupCache } from 'zhin.js/adapter';
|
|
1
10
|
/** KOOK 角色权限位:0x1 = 管理员。 */
|
|
2
11
|
const KOOK_ROLE_ADMIN_BIT = 1;
|
|
3
12
|
const CACHE_TTL_MS = 60_000;
|
|
4
13
|
export class KookSenderRoleResolver {
|
|
5
14
|
getClient;
|
|
6
|
-
#guilds = new
|
|
7
|
-
/** One lookup per guild at a time: concurrent messages on a cache miss share it. */
|
|
8
|
-
#lookups = new Map();
|
|
15
|
+
#guilds = new TtlLookupCache({ ttlMs: CACHE_TTL_MS });
|
|
9
16
|
constructor(getClient) {
|
|
10
17
|
this.getClient = getClient;
|
|
11
18
|
}
|
|
@@ -24,18 +31,11 @@ export class KookSenderRoleResolver {
|
|
|
24
31
|
return { permissions };
|
|
25
32
|
}
|
|
26
33
|
async #snapshot(guildId) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
let lookup = this.#lookups.get(guildId);
|
|
31
|
-
if (!lookup) {
|
|
32
|
-
lookup = this.#fetch(guildId).finally(() => this.#lookups.delete(guildId));
|
|
33
|
-
this.#lookups.set(guildId, lookup);
|
|
34
|
-
}
|
|
35
|
-
return lookup;
|
|
34
|
+
return this.#guilds.getOrLoad(guildId, () => this.#fetch(guildId), {
|
|
35
|
+
cacheWhen: (snapshot) => snapshot !== undefined,
|
|
36
|
+
});
|
|
36
37
|
}
|
|
37
38
|
async #fetch(guildId) {
|
|
38
|
-
const now = Date.now();
|
|
39
39
|
const client = this.getClient();
|
|
40
40
|
if (!client)
|
|
41
41
|
return undefined;
|
|
@@ -54,8 +54,6 @@ export class KookSenderRoleResolver {
|
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
catch { /* 保守:视为无管理员角色 */ }
|
|
57
|
-
|
|
58
|
-
this.#guilds.set(guildId, snapshot);
|
|
59
|
-
return snapshot;
|
|
57
|
+
return { ...(ownerId ? { ownerId } : {}), adminRoleIds };
|
|
60
58
|
}
|
|
61
59
|
}
|
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.23",
|
|
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.29",
|
|
37
|
+
"@zhin.js/agent-feature": "1.1.14",
|
|
38
|
+
"@zhin.js/client": "1.1.25",
|
|
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.57",
|
|
41
|
+
"@zhin.js/feature-kit": "1.1.13",
|
|
42
|
+
"@zhin.js/host-http": "1.1.15",
|
|
43
|
+
"@zhin.js/im-contract": "1.1.12",
|
|
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.15",
|
|
46
|
+
"@zhin.js/permission": "1.1.13",
|
|
47
|
+
"@zhin.js/skill": "1.1.14",
|
|
48
|
+
"@zhin.js/tool": "1.1.16"
|
|
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.29",
|
|
53
|
+
"@zhin.js/command": "^1.1.15",
|
|
54
|
+
"@zhin.js/core": "^1.1.57",
|
|
55
|
+
"zhin.js": "^1.1.22"
|
|
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.15",
|
|
74
|
+
"zhin.js": "1.1.22"
|
|
75
75
|
},
|
|
76
76
|
"files": [
|
|
77
77
|
"adapters",
|
package/src/sender-roles.ts
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* 跨平台规范角色 owner / admin。原始角色 id 以 `role:<id>` 形式放入 permissions,
|
|
7
7
|
* 不进入 `sender.roles`。
|
|
8
8
|
*/
|
|
9
|
+
import { TtlLookupCache } from 'zhin.js/adapter';
|
|
9
10
|
import type { KookClientTransport } from './ws.js';
|
|
10
11
|
|
|
11
12
|
/** KOOK 角色权限位:0x1 = 管理员。 */
|
|
@@ -19,15 +20,12 @@ export interface KookSenderRoleProjection {
|
|
|
19
20
|
}
|
|
20
21
|
|
|
21
22
|
interface GuildSnapshot {
|
|
22
|
-
readonly at: number;
|
|
23
23
|
readonly ownerId?: string;
|
|
24
24
|
readonly adminRoleIds: ReadonlySet<string>;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
export class KookSenderRoleResolver {
|
|
28
|
-
readonly #guilds = new
|
|
29
|
-
/** One lookup per guild at a time: concurrent messages on a cache miss share it. */
|
|
30
|
-
readonly #lookups = new Map<string, Promise<GuildSnapshot | undefined>>();
|
|
28
|
+
readonly #guilds = new TtlLookupCache<string, GuildSnapshot | undefined>({ ttlMs: CACHE_TTL_MS });
|
|
31
29
|
|
|
32
30
|
constructor(private readonly getClient: () => KookClientTransport | null) {}
|
|
33
31
|
|
|
@@ -51,18 +49,12 @@ export class KookSenderRoleResolver {
|
|
|
51
49
|
}
|
|
52
50
|
|
|
53
51
|
async #snapshot(guildId: string): Promise<GuildSnapshot | undefined> {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
if (!lookup) {
|
|
58
|
-
lookup = this.#fetch(guildId).finally(() => this.#lookups.delete(guildId));
|
|
59
|
-
this.#lookups.set(guildId, lookup);
|
|
60
|
-
}
|
|
61
|
-
return lookup;
|
|
52
|
+
return this.#guilds.getOrLoad(guildId, () => this.#fetch(guildId), {
|
|
53
|
+
cacheWhen: (snapshot): snapshot is GuildSnapshot => snapshot !== undefined,
|
|
54
|
+
});
|
|
62
55
|
}
|
|
63
56
|
|
|
64
57
|
async #fetch(guildId: string): Promise<GuildSnapshot | undefined> {
|
|
65
|
-
const now = Date.now();
|
|
66
58
|
const client = this.getClient();
|
|
67
59
|
if (!client) return undefined;
|
|
68
60
|
let ownerId: string | undefined;
|
|
@@ -76,8 +68,6 @@ export class KookSenderRoleResolver {
|
|
|
76
68
|
if ((Number(role.permissions) & KOOK_ROLE_ADMIN_BIT) !== 0) adminRoleIds.add(String(role.role_id));
|
|
77
69
|
}
|
|
78
70
|
} catch { /* 保守:视为无管理员角色 */ }
|
|
79
|
-
|
|
80
|
-
this.#guilds.set(guildId, snapshot);
|
|
81
|
-
return snapshot;
|
|
71
|
+
return { ...(ownerId ? { ownerId } : {}), adminRoleIds };
|
|
82
72
|
}
|
|
83
73
|
}
|