@zhin.js/adapter-satori 1.1.20 → 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 CHANGED
@@ -1,5 +1,62 @@
1
1
  # @zhin.js/adapter-satori
2
2
 
3
+ ## 1.1.22
4
+
5
+ ### Patch Changes
6
+
7
+ - 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.
8
+ - 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.
9
+ - 4fe49b5: 支持配置按需生效:分离保存与有效版本,独立变更先应用,账号资料更新保留连接,模型按回合使用确定版本;Console 返回结构化应用结果。监听改为仅显式 --watch 启用,开发模板显式选择源码和配置监听。
10
+
11
+ 自变更消费配置应用回执,避免已处理配置被二次重载;持久化本次写入修订和应用结果,未知结果或修订冲突时停止自动续作并保留现场,恢复不会覆盖未经本次变更确认的配置。
12
+
13
+ - Updated dependencies [b249e5e]
14
+ - Updated dependencies [57661f6]
15
+ - Updated dependencies [cbd3f14]
16
+ - Updated dependencies [299863a]
17
+ - Updated dependencies [aaa93d7]
18
+ - Updated dependencies [bd524d1]
19
+ - Updated dependencies [126ae99]
20
+ - Updated dependencies [4fe49b5]
21
+ - Updated dependencies [cce07db]
22
+ - Updated dependencies [b652db3]
23
+ - Updated dependencies [0315ba0]
24
+ - @zhin.js/core@1.1.56
25
+ - @zhin.js/adapter@1.1.28
26
+ - @zhin.js/im-contract@1.1.11
27
+ - @zhin.js/skill@1.1.13
28
+ - @zhin.js/host-http@1.1.14
29
+ - @zhin.js/feature-kit@1.1.12
30
+ - @zhin.js/client@1.1.24
31
+ - @zhin.js/page@1.1.14
32
+
33
+ ## 1.1.21
34
+
35
+ ### Patch Changes
36
+
37
+ - 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.
38
+
39
+ 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.
40
+
41
+ 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.
42
+
43
+ - Updated dependencies [b88e988]
44
+ - Updated dependencies [f78eb84]
45
+ - Updated dependencies [c15cef9]
46
+ - Updated dependencies [b0c02a2]
47
+ - Updated dependencies [af8f803]
48
+ - Updated dependencies [26fda97]
49
+ - Updated dependencies [976886c]
50
+ - Updated dependencies [032dc96]
51
+ - @zhin.js/adapter@1.1.27
52
+ - @zhin.js/client@1.1.23
53
+ - @zhin.js/im-contract@1.1.10
54
+ - @zhin.js/core@1.1.55
55
+ - @zhin.js/page@1.1.13
56
+ - @zhin.js/host-http@1.1.13
57
+ - @zhin.js/feature-kit@1.1.11
58
+ - @zhin.js/skill@1.1.12
59
+
3
60
  ## 1.1.20
4
61
 
5
62
  ### Patch Changes
@@ -8,11 +8,21 @@ import {} from "../../lib/protocol.js";
8
8
  export { SatoriWebhookEndpoint, SatoriWsEndpoint } from "../../lib/endpoint.js";
9
9
  export default defineAdapter({
10
10
  capabilities: ['inbound', 'outbound'],
11
- operations: ['recall'],
12
11
  // Satori 协议 img/file 元素消费 url 与 base64 内联数据;无卡片交互面,交互段降级纯文本。
13
- segments: {
14
- outboundMedia: ['url', 'base64'],
15
- interactive: 'text',
12
+ profile: {
13
+ default: {
14
+ messaging: {
15
+ segments: {
16
+ outboundMedia: ['url', 'base64'],
17
+ interactive: 'text',
18
+ },
19
+ recall: {},
20
+ },
21
+ actions: {
22
+ recall: { scopes: ['private', 'group', 'channel'] },
23
+ },
24
+ delivery: { send: true, spool: true },
25
+ },
16
26
  },
17
27
  createAdapter: context => new SatoriAdapter(context),
18
28
  });
@@ -18,11 +18,21 @@ export type {
18
18
 
19
19
  export default defineAdapter<SatoriEndpointConfig>({
20
20
  capabilities: ['inbound', 'outbound'],
21
- operations: ['recall'],
22
21
  // Satori 协议 img/file 元素消费 url 与 base64 内联数据;无卡片交互面,交互段降级纯文本。
23
- segments: {
24
- outboundMedia: ['url', 'base64'],
25
- interactive: 'text',
22
+ profile: {
23
+ default: {
24
+ messaging: {
25
+ segments: {
26
+ outboundMedia: ['url', 'base64'],
27
+ interactive: 'text',
28
+ },
29
+ recall: {},
30
+ },
31
+ actions: {
32
+ recall: { scopes: ['private', 'group', 'channel'] },
33
+ },
34
+ delivery: { send: true, spool: true },
35
+ },
26
36
  },
27
37
  createAdapter: context => new SatoriAdapter(context),
28
38
  });
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.20",
3
+ "version": "1.1.22",
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.28",
45
+ "@zhin.js/client": "1.1.24",
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.56",
48
+ "@zhin.js/feature-kit": "1.1.12",
49
+ "@zhin.js/host-http": "1.1.14",
50
+ "@zhin.js/im-contract": "1.1.11",
51
51
  "@zhin.js/logger": "1.1.2",
52
- "@zhin.js/page": "1.1.12",
53
- "@zhin.js/skill": "1.1.11"
52
+ "@zhin.js/page": "1.1.14",
53
+ "@zhin.js/skill": "1.1.13"
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.14",
61
+ "zhin.js": "1.1.21"
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.28",
65
+ "@zhin.js/command": "^1.1.14",
66
+ "@zhin.js/core": "^1.1.56",
67
+ "zhin.js": "^1.1.21"
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/plugin.js CHANGED
@@ -3,6 +3,7 @@ import { definePlugin, pluginConsoleRpcToken } from 'zhin.js';
3
3
  import { createSatoriConsoleRpc } from "./lib/console.js";
4
4
  export default definePlugin({
5
5
  name: 'satori',
6
+ configUpdate: { featurePaths: [['nickname'], ['profile'], ['endpoints']] },
6
7
  metadata: {
7
8
  displayName: 'Satori Adapter',
8
9
  },
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
+ }