@zhin.js/adapter-satori 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,39 @@
1
1
  # @zhin.js/adapter-satori
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/page@1.1.13
26
+ - @zhin.js/host-http@1.1.13
27
+ - @zhin.js/feature-kit@1.1.11
28
+ - @zhin.js/skill@1.1.12
29
+
30
+ ## 1.1.20
31
+
32
+ ### Patch Changes
33
+
34
+ - Updated dependencies [5e878ba]
35
+ - @zhin.js/page@1.1.12
36
+
3
37
  ## 1.1.19
4
38
 
5
39
  ### Patch Changes
package/lib/endpoint.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { createSatoriSelfProfile } from './self-profile.js';
1
2
  import { acceptHttpIngress } from 'imhelper';
2
3
  /**
3
4
  * SatoriEndpoint — WebSocket and webhook lifecycle, outbound, admit.
@@ -34,6 +35,8 @@ export class SatoriWsEndpoint extends SatoriClient {
34
35
  close: () => { this.#open = false; }, stop: () => this.#stop(),
35
36
  send: request => this.#send(request),
36
37
  management: this.#management, control: this.#control,
38
+ profile: createSatoriSelfProfile({ call, platform: options.config.platform, accountId: options.config.userId,
39
+ reportAccount: id => this[endpointSpec].reportSelfUserId(id) }),
37
40
  });
38
41
  forwardSatoriClientEvents(this, (name, payload) => {
39
42
  void this[endpointSpec].events.run(() => {
@@ -304,6 +307,8 @@ export class SatoriWebhookEndpoint extends SatoriClient {
304
307
  close: () => { this.#open = false; }, stop: () => this.#stop(),
305
308
  send: request => this.#send(request),
306
309
  management: this.#management, control: this.#control,
310
+ profile: createSatoriSelfProfile({ call, platform: options.config.platform, accountId: options.config.userId,
311
+ reportAccount: id => this[endpointSpec].reportSelfUserId(id) }),
307
312
  });
308
313
  forwardSatoriClientEvents(this, (name, payload) => {
309
314
  void this[endpointSpec].events.run(() => {
package/lib/protocol.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import type { EndpointProfileConfiguration } from 'zhin.js/adapter';
1
2
  /** Satori protocol helpers. Spec: https://satori.chat/zh-CN/protocol/overview.html */
2
3
  import { type ConversationRef } from '@zhin.js/im-contract';
3
4
  /** Opcode:EVENT=0, PING=1, PONG=2, IDENTIFY=3, READY=4, META=5 */
@@ -74,7 +75,7 @@ export interface SatoriWireSegment {
74
75
  readonly data?: Record<string, unknown>;
75
76
  }
76
77
  /** One endpoint config after AdapterIndex expands `plugins.<instanceKey>.endpoints`. */
77
- export interface SatoriEndpointConfig {
78
+ export interface SatoriEndpointConfig extends EndpointProfileConfiguration {
78
79
  readonly id: string;
79
80
  /** Exact remote login selected by this configured Endpoint. */
80
81
  readonly platform: string;
@@ -0,0 +1,11 @@
1
+ import type { EndpointProfile } from 'zhin.js/adapter';
2
+ import type { SatoriActionCaller } from './client.js';
3
+ interface SatoriSelfProfileOptions {
4
+ readonly call: SatoriActionCaller;
5
+ readonly platform: string;
6
+ readonly accountId: string;
7
+ readonly reportAccount: (id: string) => void;
8
+ }
9
+ /** login.get is scoped by Satori-Platform/Satori-User-ID, never the gateway's first login. */
10
+ export declare function createSatoriSelfProfile({ call, platform, accountId, reportAccount }: SatoriSelfProfileOptions): EndpointProfile;
11
+ export {};
@@ -0,0 +1,15 @@
1
+ /** login.get is scoped by Satori-Platform/Satori-User-ID, never the gateway's first login. */
2
+ export function createSatoriSelfProfile({ call, platform, accountId, reportAccount }) {
3
+ return Object.freeze({
4
+ writableFields: Object.freeze([]),
5
+ async read({ signal }) {
6
+ const self = await call({ resource: 'login', method: 'get', signal });
7
+ if (self?.user?.id !== accountId || (self.platform !== undefined && self.platform !== platform)) {
8
+ throw new Error('Satori returned another account profile');
9
+ }
10
+ reportAccount(self.user.id);
11
+ return { ...(typeof self.user.name === 'string' ? { nickname: self.user.name } : {}),
12
+ ...(typeof self.user.avatar === 'string' ? { avatar: self.user.avatar } : {}) };
13
+ },
14
+ });
15
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zhin.js/adapter-satori",
3
- "version": "1.1.19",
3
+ "version": "1.1.21",
4
4
  "description": "Zhin.js Satori adapter for Plugin Runtime (WebSocket client)",
5
5
  "type": "module",
6
6
  "main": "./lib/index.js",
@@ -41,30 +41,30 @@
41
41
  "@imhelper/satori-v1": "1.0.7",
42
42
  "imhelper": "1.0.7",
43
43
  "ws": "^8.21.1",
44
- "@zhin.js/adapter": "1.1.26",
45
- "@zhin.js/client": "1.1.22",
44
+ "@zhin.js/adapter": "1.1.27",
45
+ "@zhin.js/client": "1.1.23",
46
46
  "@zhin.js/console-contract": "1.1.3",
47
- "@zhin.js/core": "1.1.54",
48
- "@zhin.js/feature-kit": "1.1.10",
49
- "@zhin.js/host-http": "1.1.12",
50
- "@zhin.js/im-contract": "1.1.9",
47
+ "@zhin.js/core": "1.1.55",
48
+ "@zhin.js/feature-kit": "1.1.11",
49
+ "@zhin.js/host-http": "1.1.13",
50
+ "@zhin.js/im-contract": "1.1.10",
51
51
  "@zhin.js/logger": "1.1.2",
52
- "@zhin.js/page": "1.1.11",
53
- "@zhin.js/skill": "1.1.11"
52
+ "@zhin.js/page": "1.1.13",
53
+ "@zhin.js/skill": "1.1.12"
54
54
  },
55
55
  "devDependencies": {
56
56
  "@types/node": "^26.1.2",
57
57
  "@types/ws": "^8.18.1",
58
58
  "typescript": "^6.0.3",
59
59
  "vitest": "^4.1.10",
60
- "@zhin.js/host-http": "1.1.12",
61
- "zhin.js": "1.1.19"
60
+ "@zhin.js/host-http": "1.1.13",
61
+ "zhin.js": "1.1.20"
62
62
  },
63
63
  "peerDependencies": {
64
- "@zhin.js/adapter": "^1.1.26",
65
- "@zhin.js/command": "^1.1.12",
66
- "@zhin.js/core": "^1.1.54",
67
- "zhin.js": "^1.1.19"
64
+ "@zhin.js/adapter": "^1.1.27",
65
+ "@zhin.js/command": "^1.1.13",
66
+ "@zhin.js/core": "^1.1.55",
67
+ "zhin.js": "^1.1.20"
68
68
  },
69
69
  "peerDependenciesMeta": {
70
70
  "@zhin.js/command": {
@@ -95,7 +95,7 @@
95
95
  "features": [
96
96
  {
97
97
  "package": "@zhin.js/adapter",
98
- "api": "^2.0.0"
98
+ "api": "^2.1.0"
99
99
  },
100
100
  {
101
101
  "package": "@zhin.js/command",
package/schema.json CHANGED
@@ -119,6 +119,27 @@
119
119
  "type": "string",
120
120
  "minLength": 1,
121
121
  "description": "Selected Satori login user ID"
122
+ },
123
+ "nickname": {
124
+ "type": [
125
+ "string",
126
+ "null"
127
+ ],
128
+ "description": "账号昵称兜底",
129
+ "x-i18n": {
130
+ "en": {
131
+ "description": "Fallback account nickname"
132
+ }
133
+ }
134
+ },
135
+ "profile": {
136
+ "$ref": "#/$defs/selfProfileFallback",
137
+ "description": "账号资料兜底",
138
+ "x-i18n": {
139
+ "en": {
140
+ "description": "Fallback account profile"
141
+ }
142
+ }
122
143
  }
123
144
  },
124
145
  "required": [
@@ -143,9 +164,93 @@
143
164
  "description": "Command prefix. The default empty string allows unprefixed commands; '/' requires a leading slash. Each endpoints[i] can override it."
144
165
  }
145
166
  }
167
+ },
168
+ "nickname": {
169
+ "type": [
170
+ "string",
171
+ "null"
172
+ ],
173
+ "description": "账号昵称兜底",
174
+ "x-i18n": {
175
+ "en": {
176
+ "description": "Fallback account nickname"
177
+ }
178
+ }
179
+ },
180
+ "profile": {
181
+ "$ref": "#/$defs/selfProfileFallback",
182
+ "description": "账号资料兜底",
183
+ "x-i18n": {
184
+ "en": {
185
+ "description": "Fallback account profile"
186
+ }
187
+ }
146
188
  }
147
189
  },
148
190
  "required": [
149
191
  "endpoints"
150
- ]
192
+ ],
193
+ "$defs": {
194
+ "selfProfileFallback": {
195
+ "type": "object",
196
+ "additionalProperties": false,
197
+ "properties": {
198
+ "gender": {
199
+ "type": [
200
+ "string",
201
+ "null"
202
+ ],
203
+ "enum": [
204
+ "male",
205
+ "female",
206
+ "other",
207
+ "unknown",
208
+ null
209
+ ]
210
+ },
211
+ "age": {
212
+ "type": [
213
+ "integer",
214
+ "null"
215
+ ],
216
+ "minimum": 0
217
+ },
218
+ "birthday": {
219
+ "type": [
220
+ "string",
221
+ "null"
222
+ ],
223
+ "pattern": "^\\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\\d|3[01])$"
224
+ },
225
+ "signature": {
226
+ "type": [
227
+ "string",
228
+ "null"
229
+ ]
230
+ },
231
+ "avatar": {
232
+ "type": [
233
+ "string",
234
+ "null"
235
+ ],
236
+ "pattern": "^(https?://[^\\s/?#]+(?:[/?#].*)?|)$"
237
+ },
238
+ "interests": {
239
+ "type": [
240
+ "array",
241
+ "null"
242
+ ],
243
+ "items": {
244
+ "type": "string"
245
+ }
246
+ },
247
+ "bio": {
248
+ "type": [
249
+ "string",
250
+ "null"
251
+ ]
252
+ }
253
+ }
254
+ }
255
+ }
151
256
  }
package/src/endpoint.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { createSatoriSelfProfile } from './self-profile.js';
1
2
  import { acceptHttpIngress } from 'imhelper';
2
3
  /**
3
4
  * SatoriEndpoint — WebSocket and webhook lifecycle, outbound, admit.
@@ -88,6 +89,8 @@ export class SatoriWsEndpoint extends SatoriClient implements Endpoint {
88
89
  close: () => { this.#open = false; }, stop: () => this.#stop(),
89
90
  send: request => this.#send(request),
90
91
  management: this.#management, control: this.#control,
92
+ profile: createSatoriSelfProfile({ call, platform: options.config.platform, accountId: options.config.userId,
93
+ reportAccount: id => this[endpointSpec].reportSelfUserId(id) }),
91
94
  });
92
95
  forwardSatoriClientEvents(this, (name, payload) => {
93
96
  void this[endpointSpec].events.run(() => {
@@ -370,6 +373,8 @@ export class SatoriWebhookEndpoint extends SatoriClient implements Endpoint {
370
373
  close: () => { this.#open = false; }, stop: () => this.#stop(),
371
374
  send: request => this.#send(request),
372
375
  management: this.#management, control: this.#control,
376
+ profile: createSatoriSelfProfile({ call, platform: options.config.platform, accountId: options.config.userId,
377
+ reportAccount: id => this[endpointSpec].reportSelfUserId(id) }),
373
378
  });
374
379
  forwardSatoriClientEvents(this, (name, payload) => {
375
380
  void this[endpointSpec].events.run(() => {
package/src/protocol.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import type { EndpointProfileConfiguration } from 'zhin.js/adapter';
1
2
  /** Satori protocol helpers. Spec: https://satori.chat/zh-CN/protocol/overview.html */
2
3
 
3
4
  import { EndpointDeliveryError, isMediaRef, type ConversationKind, type ConversationRef } from '@zhin.js/im-contract';
@@ -78,7 +79,7 @@ export interface SatoriWireSegment {
78
79
  }
79
80
 
80
81
  /** One endpoint config after AdapterIndex expands `plugins.<instanceKey>.endpoints`. */
81
- export interface SatoriEndpointConfig {
82
+ export interface SatoriEndpointConfig extends EndpointProfileConfiguration {
82
83
  readonly id: string;
83
84
  /** Exact remote login selected by this configured Endpoint. */
84
85
  readonly platform: string;
@@ -0,0 +1,26 @@
1
+ import type { EndpointProfile } from 'zhin.js/adapter';
2
+ import type { SatoriActionCaller } from './client.js';
3
+ import type { SatoriLogin } from './protocol.js';
4
+
5
+ interface SatoriSelfProfileOptions {
6
+ readonly call: SatoriActionCaller;
7
+ readonly platform: string;
8
+ readonly accountId: string;
9
+ readonly reportAccount: (id: string) => void;
10
+ }
11
+
12
+ /** login.get is scoped by Satori-Platform/Satori-User-ID, never the gateway's first login. */
13
+ export function createSatoriSelfProfile({ call, platform, accountId, reportAccount }: SatoriSelfProfileOptions): EndpointProfile {
14
+ return Object.freeze<EndpointProfile>({
15
+ writableFields: Object.freeze([]),
16
+ async read({ signal }) {
17
+ const self = await call({ resource: 'login', method: 'get', signal }) as SatoriLogin;
18
+ if (self?.user?.id !== accountId || (self.platform !== undefined && self.platform !== platform)) {
19
+ throw new Error('Satori returned another account profile');
20
+ }
21
+ reportAccount(self.user.id);
22
+ return { ...(typeof self.user.name === 'string' ? { nickname: self.user.name } : {}),
23
+ ...(typeof self.user.avatar === 'string' ? { avatar: self.user.avatar } : {}) };
24
+ },
25
+ });
26
+ }