@zhin.js/adapter-kook 1.1.19 → 1.1.21

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 CHANGED
@@ -1,5 +1,42 @@
1
1
  # @zhin.js/adapter-kook
2
2
 
3
+ ## 1.1.21
4
+
5
+ ### Patch Changes
6
+
7
+ - af8f803: Use the current Endpoint's platform profile for Agent account identity, with per-field configured fallbacks and scoped, identity-approved profile tools. Keep SOUL first-person and independent of account names. Profile ports preserve the source Client, cancellation, truthful update outcomes and private image authority.
8
+
9
+ Adapter Feature API 2.1 and Tool Feature API 1.1 describe the additive profile requirements; new Core, official adapters and generated plugins declare the corresponding floors. Existing compatible API-2.0/API-1.0 plugins remain accepted by the newer providers. npm releases remain patch.
10
+
11
+ Private IM assets now bind to the full canonical conversation and principal. Existing IM asset records that contain only the earlier lossy hash remain on disk until their original expiry, but cannot be safely rebound; recapture them. No automatic file deletion, platform profile mutation or workspace SOUL rewrite occurs during upgrade.
12
+
13
+ - Updated dependencies [b88e988]
14
+ - Updated dependencies [f78eb84]
15
+ - Updated dependencies [c15cef9]
16
+ - Updated dependencies [b0c02a2]
17
+ - Updated dependencies [af8f803]
18
+ - Updated dependencies [26fda97]
19
+ - Updated dependencies [976886c]
20
+ - Updated dependencies [032dc96]
21
+ - @zhin.js/adapter@1.1.27
22
+ - @zhin.js/client@1.1.23
23
+ - @zhin.js/im-contract@1.1.10
24
+ - @zhin.js/core@1.1.55
25
+ - @zhin.js/tool@1.1.14
26
+ - @zhin.js/page@1.1.13
27
+ - @zhin.js/host-http@1.1.13
28
+ - @zhin.js/agent-feature@1.1.12
29
+ - @zhin.js/feature-kit@1.1.11
30
+ - @zhin.js/permission@1.1.11
31
+ - @zhin.js/skill@1.1.12
32
+
33
+ ## 1.1.20
34
+
35
+ ### Patch Changes
36
+
37
+ - Updated dependencies [5e878ba]
38
+ - @zhin.js/page@1.1.12
39
+
3
40
  ## 1.1.19
4
41
 
5
42
  ### Patch Changes
package/lib/endpoint.js CHANGED
@@ -10,6 +10,7 @@ import { RuntimeKookClient, kookWebsocketClientOptions, kookWebhookClientOptions
10
10
  import { recallKookMessage, sendKookOutbound } from './outbound.js';
11
11
  import { KookSenderRoleResolver } from './sender-roles.js';
12
12
  import { receiveKookSideEvent } from './side-event-dispatch.js';
13
+ import { createKookSelfProfile } from './self-profile.js';
13
14
  /** 入站 message.receive 载荷:规范角色 owner/admin 进 roles,原始角色 id 进 permissions。 */
14
15
  function kookInboundPayload(endpointId, conversation, msg, projection, selfId) {
15
16
  return {
@@ -58,6 +59,7 @@ export class KookWebsocketEndpoint extends RuntimeKookClient {
58
59
  stop: () => this.#stopFramework(), send: request => this.#sendFramework(request),
59
60
  name: options.config.id, get transportState() { return endpoint.#transportState; },
60
61
  management: this.#management, control: this.#control,
62
+ profile: createKookSelfProfile({ client: this, reportAccount: id => this[endpointSpec].reportSelfUserId(id) }),
61
63
  });
62
64
  }
63
65
  get #transportState() {
@@ -206,6 +208,7 @@ export class KookWebhookEndpoint extends RuntimeKookClient {
206
208
  start: signal => this.#startFramework(signal), open: () => this.#openFramework(), close: () => this.#closeFramework(),
207
209
  stop: () => this.#stopFramework(), send: request => this.#sendFramework(request), name: options.config.id,
208
210
  management: this.#management, control: this.#control,
211
+ profile: createKookSelfProfile({ client: this, reportAccount: id => this[endpointSpec].reportSelfUserId(id) }),
209
212
  });
210
213
  }
211
214
  /** Used by webhook handler. */
package/lib/protocol.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- /** KOOK protocol helpers. Canonicalization is owned by Core. */
1
+ import type { EndpointProfileConfiguration } from 'zhin.js/adapter';
2
2
  import type { IncomingMessage } from 'node:http';
3
3
  import { type ConversationRef } from '@zhin.js/im-contract';
4
4
  import type { Locale } from 'zhin.js/i18n';
@@ -10,7 +10,7 @@ export declare enum KookPermission {
10
10
  ChannelAdmin = 5
11
11
  }
12
12
  /** One endpoint config after AdapterIndex expands `plugins.<instanceKey>.endpoints`. */
13
- export interface KookEndpointConfig {
13
+ export interface KookEndpointConfig extends EndpointProfileConfiguration {
14
14
  readonly apiProxy?: import('./api-proxy.js').KookApiProxy;
15
15
  readonly streamProxy?: import('./stream-proxy.js').KookStreamProxy;
16
16
  readonly id: string;
@@ -0,0 +1,9 @@
1
+ import { type EndpointProfile } from 'zhin.js/adapter';
2
+ import type { RuntimeKookClient } from './ws.js';
3
+ interface KookSelfProfileOptions {
4
+ readonly client: Pick<RuntimeKookClient, 'getSelfInfo'>;
5
+ readonly reportAccount: (id: string) => void;
6
+ }
7
+ /** Bot account profile facts from the SDK's existing /user/me method. */
8
+ export declare function createKookSelfProfile({ client, reportAccount }: KookSelfProfileOptions): EndpointProfile;
9
+ export {};
@@ -0,0 +1,14 @@
1
+ import { createEndpointOperation } from 'zhin.js/adapter';
2
+ /** Bot account profile facts from the SDK's existing /user/me method. */
3
+ export function createKookSelfProfile({ client, reportAccount }) {
4
+ return Object.freeze({
5
+ writableFields: Object.freeze([]),
6
+ async read({ signal }) {
7
+ const self = await createEndpointOperation({ signal }).prepare(() => client.getSelfInfo());
8
+ if (!self?.id || typeof self.username !== 'string')
9
+ throw new Error('KOOK returned an incomplete self profile');
10
+ reportAccount(self.id);
11
+ return { nickname: self.username, ...(typeof self.avatar === 'string' ? { avatar: self.avatar } : {}) };
12
+ },
13
+ });
14
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zhin.js/adapter-kook",
3
- "version": "1.1.19",
3
+ "version": "1.1.21",
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.26",
37
- "@zhin.js/agent-feature": "1.1.11",
38
- "@zhin.js/client": "1.1.22",
36
+ "@zhin.js/adapter": "1.1.27",
37
+ "@zhin.js/agent-feature": "1.1.12",
38
+ "@zhin.js/client": "1.1.23",
39
39
  "@zhin.js/console-contract": "1.1.3",
40
- "@zhin.js/core": "1.1.54",
41
- "@zhin.js/feature-kit": "1.1.10",
42
- "@zhin.js/host-http": "1.1.12",
43
- "@zhin.js/im-contract": "1.1.9",
40
+ "@zhin.js/core": "1.1.55",
41
+ "@zhin.js/feature-kit": "1.1.11",
42
+ "@zhin.js/host-http": "1.1.13",
43
+ "@zhin.js/im-contract": "1.1.10",
44
44
  "@zhin.js/logger": "1.1.2",
45
- "@zhin.js/page": "1.1.11",
46
- "@zhin.js/permission": "1.1.10",
47
- "@zhin.js/skill": "1.1.11",
48
- "@zhin.js/tool": "1.1.13"
45
+ "@zhin.js/page": "1.1.13",
46
+ "@zhin.js/permission": "1.1.11",
47
+ "@zhin.js/skill": "1.1.12",
48
+ "@zhin.js/tool": "1.1.14"
49
49
  },
50
50
  "peerDependencies": {
51
51
  "zod": "^4.0.0",
52
- "@zhin.js/adapter": "^1.1.26",
53
- "@zhin.js/command": "^1.1.12",
54
- "@zhin.js/core": "^1.1.54",
55
- "zhin.js": "^1.1.19"
52
+ "@zhin.js/adapter": "^1.1.27",
53
+ "@zhin.js/command": "^1.1.13",
54
+ "@zhin.js/core": "^1.1.55",
55
+ "zhin.js": "^1.1.20"
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.12",
74
- "zhin.js": "1.1.19"
73
+ "@zhin.js/host-http": "1.1.13",
74
+ "zhin.js": "1.1.20"
75
75
  },
76
76
  "files": [
77
77
  "adapters",
@@ -103,7 +103,7 @@
103
103
  "features": [
104
104
  {
105
105
  "package": "@zhin.js/adapter",
106
- "api": "^2.0.0"
106
+ "api": "^2.1.0"
107
107
  },
108
108
  {
109
109
  "package": "@zhin.js/command",
@@ -111,7 +111,7 @@
111
111
  },
112
112
  {
113
113
  "package": "@zhin.js/tool",
114
- "api": "^1.0.0"
114
+ "api": "^1.1.0"
115
115
  },
116
116
  {
117
117
  "package": "@zhin.js/skill",
package/schema.json CHANGED
@@ -212,6 +212,27 @@
212
212
  }
213
213
  },
214
214
  "description": "Optional fixed loopback TCP route for www.kookapp.cn JSON API only; verified TLS remains enabled."
215
+ },
216
+ "nickname": {
217
+ "type": [
218
+ "string",
219
+ "null"
220
+ ],
221
+ "description": "账号昵称兜底",
222
+ "x-i18n": {
223
+ "en": {
224
+ "description": "Fallback account nickname"
225
+ }
226
+ }
227
+ },
228
+ "profile": {
229
+ "$ref": "#/$defs/selfProfileFallback",
230
+ "description": "账号资料兜底",
231
+ "x-i18n": {
232
+ "en": {
233
+ "description": "Fallback account profile"
234
+ }
235
+ }
215
236
  }
216
237
  },
217
238
  "required": [
@@ -234,9 +255,93 @@
234
255
  "description": "Command prefix. The default empty string allows unprefixed commands; '/' requires a leading slash. Each endpoints[i] can override it."
235
256
  }
236
257
  }
258
+ },
259
+ "nickname": {
260
+ "type": [
261
+ "string",
262
+ "null"
263
+ ],
264
+ "description": "账号昵称兜底",
265
+ "x-i18n": {
266
+ "en": {
267
+ "description": "Fallback account nickname"
268
+ }
269
+ }
270
+ },
271
+ "profile": {
272
+ "$ref": "#/$defs/selfProfileFallback",
273
+ "description": "账号资料兜底",
274
+ "x-i18n": {
275
+ "en": {
276
+ "description": "Fallback account profile"
277
+ }
278
+ }
237
279
  }
238
280
  },
239
281
  "required": [
240
282
  "endpoints"
241
- ]
283
+ ],
284
+ "$defs": {
285
+ "selfProfileFallback": {
286
+ "type": "object",
287
+ "additionalProperties": false,
288
+ "properties": {
289
+ "gender": {
290
+ "type": [
291
+ "string",
292
+ "null"
293
+ ],
294
+ "enum": [
295
+ "male",
296
+ "female",
297
+ "other",
298
+ "unknown",
299
+ null
300
+ ]
301
+ },
302
+ "age": {
303
+ "type": [
304
+ "integer",
305
+ "null"
306
+ ],
307
+ "minimum": 0
308
+ },
309
+ "birthday": {
310
+ "type": [
311
+ "string",
312
+ "null"
313
+ ],
314
+ "pattern": "^\\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\\d|3[01])$"
315
+ },
316
+ "signature": {
317
+ "type": [
318
+ "string",
319
+ "null"
320
+ ]
321
+ },
322
+ "avatar": {
323
+ "type": [
324
+ "string",
325
+ "null"
326
+ ],
327
+ "pattern": "^(https?://[^\\s/?#]+(?:[/?#].*)?|)$"
328
+ },
329
+ "interests": {
330
+ "type": [
331
+ "array",
332
+ "null"
333
+ ],
334
+ "items": {
335
+ "type": "string"
336
+ }
337
+ },
338
+ "bio": {
339
+ "type": [
340
+ "string",
341
+ "null"
342
+ ]
343
+ }
344
+ }
345
+ }
346
+ }
242
347
  }
package/src/endpoint.ts CHANGED
@@ -42,6 +42,7 @@ import {
42
42
  import { recallKookMessage, sendKookOutbound } from './outbound.js';
43
43
  import { KookSenderRoleResolver, type KookSenderRoleProjection } from './sender-roles.js';
44
44
  import { receiveKookSideEvent } from './side-event-dispatch.js';
45
+ import { createKookSelfProfile } from './self-profile.js';
45
46
 
46
47
  export interface KookEndpointOptions {
47
48
  readonly id: CapabilityId;
@@ -105,6 +106,7 @@ export class KookWebsocketEndpoint extends RuntimeKookClient implements Endpoint
105
106
  stop: () => this.#stopFramework(), send: request => this.#sendFramework(request),
106
107
  name: options.config.id, get transportState() { return endpoint.#transportState; },
107
108
  management: this.#management, control: this.#control,
109
+ profile: createKookSelfProfile({ client: this, reportAccount: id => this[endpointSpec].reportSelfUserId(id) }),
108
110
  });
109
111
  }
110
112
 
@@ -266,6 +268,7 @@ export class KookWebhookEndpoint extends RuntimeKookClient implements Endpoint {
266
268
  start: signal => this.#startFramework(signal), open: () => this.#openFramework(), close: () => this.#closeFramework(),
267
269
  stop: () => this.#stopFramework(), send: request => this.#sendFramework(request), name: options.config.id,
268
270
  management: this.#management, control: this.#control,
271
+ profile: createKookSelfProfile({ client: this, reportAccount: id => this[endpointSpec].reportSelfUserId(id) }),
269
272
  });
270
273
  }
271
274
 
package/src/protocol.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import type { EndpointProfileConfiguration } from 'zhin.js/adapter';
1
2
  /** KOOK protocol helpers. Canonicalization is owned by Core. */
2
3
 
3
4
  import { createDecipheriv, timingSafeEqual } from 'node:crypto';
@@ -28,7 +29,7 @@ export enum KookPermission {
28
29
  }
29
30
 
30
31
  /** One endpoint config after AdapterIndex expands `plugins.<instanceKey>.endpoints`. */
31
- export interface KookEndpointConfig {
32
+ export interface KookEndpointConfig extends EndpointProfileConfiguration {
32
33
  readonly apiProxy?: import('./api-proxy.js').KookApiProxy;
33
34
  readonly streamProxy?: import('./stream-proxy.js').KookStreamProxy;
34
35
  readonly id: string;
@@ -0,0 +1,20 @@
1
+ import { createEndpointOperation, type EndpointProfile } from 'zhin.js/adapter';
2
+ import type { RuntimeKookClient } from './ws.js';
3
+
4
+ interface KookSelfProfileOptions {
5
+ readonly client: Pick<RuntimeKookClient, 'getSelfInfo'>;
6
+ readonly reportAccount: (id: string) => void;
7
+ }
8
+
9
+ /** Bot account profile facts from the SDK's existing /user/me method. */
10
+ export function createKookSelfProfile({ client, reportAccount }: KookSelfProfileOptions): EndpointProfile {
11
+ return Object.freeze<EndpointProfile>({
12
+ writableFields: Object.freeze([]),
13
+ async read({ signal }) {
14
+ const self = await createEndpointOperation({ signal }).prepare(() => client.getSelfInfo());
15
+ if (!self?.id || typeof self.username !== 'string') throw new Error('KOOK returned an incomplete self profile');
16
+ reportAccount(self.id);
17
+ return { nickname: self.username, ...(typeof self.avatar === 'string' ? { avatar: self.avatar } : {}) };
18
+ },
19
+ });
20
+ }