@zhin.js/adapter-satori 5.0.12 → 6.0.0
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/adapters/satori.js +5 -1
- package/adapters/satori.ts +5 -1
- package/lib/endpoint.d.ts +8 -4
- package/lib/endpoint.js +10 -4
- package/package.json +11 -11
- package/src/endpoint.ts +14 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,38 @@
|
|
|
1
1
|
# @zhin.js/adapter-satori
|
|
2
2
|
|
|
3
|
+
## 6.0.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- f2c532f: Expose exact per-Endpoint message operations through one validated Adapter capability model, route Core control calls through declared active capabilities, and connect existing recall, edit, reaction, and typing implementations across platform adapters.
|
|
8
|
+
- Updated dependencies [b10d058]
|
|
9
|
+
- Updated dependencies [f2c532f]
|
|
10
|
+
- @zhin.js/host-http@1.0.12
|
|
11
|
+
- @zhin.js/adapter@1.2.0
|
|
12
|
+
- @zhin.js/core@1.5.13
|
|
13
|
+
- zhin.js@6.0.13
|
|
14
|
+
|
|
15
|
+
## 5.0.13
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- 5969c5b: Add SideEventGateway so adapters forward notice/request/system into HandlerIndex. HandlerContext now exposes only generation-safe capabilities and prompt ports; live Endpoint escape hatches are removed.
|
|
20
|
+
- Updated dependencies [5969c5b]
|
|
21
|
+
- Updated dependencies [d336a3f]
|
|
22
|
+
- Updated dependencies [5969c5b]
|
|
23
|
+
- Updated dependencies [5969c5b]
|
|
24
|
+
- Updated dependencies [974772e]
|
|
25
|
+
- Updated dependencies [5969c5b]
|
|
26
|
+
- Updated dependencies [2f786bd]
|
|
27
|
+
- Updated dependencies [1312ca0]
|
|
28
|
+
- Updated dependencies [985fa22]
|
|
29
|
+
- @zhin.js/im-contract@1.0.4
|
|
30
|
+
- @zhin.js/core@1.5.12
|
|
31
|
+
- @zhin.js/adapter@1.1.11
|
|
32
|
+
- @zhin.js/host-http@1.0.11
|
|
33
|
+
- @zhin.js/command@1.0.15
|
|
34
|
+
- zhin.js@6.0.12
|
|
35
|
+
|
|
3
36
|
## 5.0.12
|
|
4
37
|
|
|
5
38
|
### Patch Changes
|
package/adapters/satori.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Convention entry: discover `adapters/satori.ts` → defineAdapter.
|
|
4
4
|
*/
|
|
5
5
|
import { defineAdapter } from 'zhin.js/adapter';
|
|
6
|
-
import { messageGatewayToken } from '@zhin.js/core/runtime';
|
|
6
|
+
import { messageGatewayToken, sideEventGatewayToken } from '@zhin.js/core/runtime';
|
|
7
7
|
import { httpHostToken } from '@zhin.js/host-http';
|
|
8
8
|
import { SatoriWebhookEndpoint, SatoriWsEndpoint } from "../lib/endpoint.js";
|
|
9
9
|
import { resolveSatoriConfig, } from "../lib/protocol.js";
|
|
@@ -11,6 +11,7 @@ import { satoriRuntimeStateToken } from "../lib/satori-runtime-state.js";
|
|
|
11
11
|
export { SatoriWebhookEndpoint, SatoriWsEndpoint } from "../lib/endpoint.js";
|
|
12
12
|
export default defineAdapter({
|
|
13
13
|
capabilities: ['inbound', 'outbound'],
|
|
14
|
+
operations: ['recall'],
|
|
14
15
|
// Satori 协议 img/file 元素消费 url 与 base64 内联数据;无卡片交互面,交互段降级纯文本。
|
|
15
16
|
segments: {
|
|
16
17
|
outboundMedia: ['url', 'base64'],
|
|
@@ -19,6 +20,7 @@ export default defineAdapter({
|
|
|
19
20
|
create(context) {
|
|
20
21
|
const config = resolveSatoriConfig(context.config);
|
|
21
22
|
const gateway = context.use(messageGatewayToken);
|
|
23
|
+
const sideEvents = context.use(sideEventGatewayToken);
|
|
22
24
|
// 注册到插件运行时状态(satori.endpoint list 的"运行中"数据源)
|
|
23
25
|
context.use(satoriRuntimeStateToken).endpoints.set(config.id, {
|
|
24
26
|
id: config.id,
|
|
@@ -28,6 +30,7 @@ export default defineAdapter({
|
|
|
28
30
|
return new SatoriWebhookEndpoint({
|
|
29
31
|
id: context.id,
|
|
30
32
|
gateway,
|
|
33
|
+
sideEvents,
|
|
31
34
|
http: context.use(httpHostToken),
|
|
32
35
|
config,
|
|
33
36
|
});
|
|
@@ -35,6 +38,7 @@ export default defineAdapter({
|
|
|
35
38
|
return new SatoriWsEndpoint({
|
|
36
39
|
id: context.id,
|
|
37
40
|
gateway,
|
|
41
|
+
sideEvents,
|
|
38
42
|
config,
|
|
39
43
|
});
|
|
40
44
|
},
|
package/adapters/satori.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Convention entry: discover `adapters/satori.ts` → defineAdapter.
|
|
3
3
|
*/
|
|
4
4
|
import { defineAdapter } from 'zhin.js/adapter';
|
|
5
|
-
import { messageGatewayToken } from '@zhin.js/core/runtime';
|
|
5
|
+
import { messageGatewayToken, sideEventGatewayToken } from '@zhin.js/core/runtime';
|
|
6
6
|
import { httpHostToken } from '@zhin.js/host-http';
|
|
7
7
|
import { SatoriWebhookEndpoint, SatoriWsEndpoint } from '../src/endpoint.js';
|
|
8
8
|
import {
|
|
@@ -22,6 +22,7 @@ export type {
|
|
|
22
22
|
|
|
23
23
|
export default defineAdapter<SatoriAdapterConfig>({
|
|
24
24
|
capabilities: ['inbound', 'outbound'],
|
|
25
|
+
operations: ['recall'],
|
|
25
26
|
// Satori 协议 img/file 元素消费 url 与 base64 内联数据;无卡片交互面,交互段降级纯文本。
|
|
26
27
|
segments: {
|
|
27
28
|
outboundMedia: ['url', 'base64'],
|
|
@@ -30,6 +31,7 @@ export default defineAdapter<SatoriAdapterConfig>({
|
|
|
30
31
|
create(context) {
|
|
31
32
|
const config = resolveSatoriConfig(context.config);
|
|
32
33
|
const gateway = context.use(messageGatewayToken);
|
|
34
|
+
const sideEvents = context.use(sideEventGatewayToken);
|
|
33
35
|
// 注册到插件运行时状态(satori.endpoint list 的"运行中"数据源)
|
|
34
36
|
context.use(satoriRuntimeStateToken).endpoints.set(config.id, {
|
|
35
37
|
id: config.id,
|
|
@@ -39,6 +41,7 @@ export default defineAdapter<SatoriAdapterConfig>({
|
|
|
39
41
|
return new SatoriWebhookEndpoint({
|
|
40
42
|
id: context.id,
|
|
41
43
|
gateway,
|
|
44
|
+
sideEvents,
|
|
42
45
|
http: context.use(httpHostToken),
|
|
43
46
|
config,
|
|
44
47
|
});
|
|
@@ -46,6 +49,7 @@ export default defineAdapter<SatoriAdapterConfig>({
|
|
|
46
49
|
return new SatoriWsEndpoint({
|
|
47
50
|
id: context.id,
|
|
48
51
|
gateway,
|
|
52
|
+
sideEvents,
|
|
49
53
|
config,
|
|
50
54
|
});
|
|
51
55
|
},
|
package/lib/endpoint.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* SatoriEndpoint — WebSocket and webhook lifecycle, outbound, admit.
|
|
3
3
|
*/
|
|
4
|
-
import { type EndpointInstance, type EndpointManagement, type EndpointSendRequest } from 'zhin.js/adapter';
|
|
5
|
-
import type { MessageGateway } from '@zhin.js/core/runtime';
|
|
4
|
+
import { type EndpointControl, type EndpointInstance, type EndpointManagement, type EndpointSendRequest } from 'zhin.js/adapter';
|
|
5
|
+
import type { MessageGateway, SideEventGateway } from '@zhin.js/core/runtime';
|
|
6
6
|
import type { HttpHost } from '@zhin.js/host-http';
|
|
7
7
|
import type { CapabilityId } from 'zhin.js';
|
|
8
8
|
import { callSatoriApi, type ResolvedSatoriWebhookConfig, type ResolvedSatoriWsConfig, type SatoriEventBody, type SatoriLogin } from './protocol.js';
|
|
@@ -11,6 +11,7 @@ export type SatoriApiCaller = typeof callSatoriApi;
|
|
|
11
11
|
export interface SatoriWsEndpointOptions {
|
|
12
12
|
readonly id: CapabilityId;
|
|
13
13
|
readonly gateway: MessageGateway;
|
|
14
|
+
readonly sideEvents?: SideEventGateway;
|
|
14
15
|
readonly config: ResolvedSatoriWsConfig;
|
|
15
16
|
readonly createWebSocket?: CreateSatoriWebSocket;
|
|
16
17
|
readonly callApi?: SatoriApiCaller;
|
|
@@ -18,6 +19,7 @@ export interface SatoriWsEndpointOptions {
|
|
|
18
19
|
export declare class SatoriWsEndpoint implements EndpointInstance {
|
|
19
20
|
#private;
|
|
20
21
|
readonly management: EndpointManagement;
|
|
22
|
+
readonly control: EndpointControl;
|
|
21
23
|
constructor(options: SatoriWsEndpointOptions);
|
|
22
24
|
start(): Promise<void>;
|
|
23
25
|
open(): void;
|
|
@@ -26,13 +28,14 @@ export declare class SatoriWsEndpoint implements EndpointInstance {
|
|
|
26
28
|
send({ conversation, payload }: EndpointSendRequest): Promise<string>;
|
|
27
29
|
/** Test / internal: admit a gateway event when the endpoint is open. */
|
|
28
30
|
admit(body: SatoriEventBody): void;
|
|
29
|
-
recall(id: string): Promise<void>;
|
|
31
|
+
recall(id: string, fallbackChannelId?: string): Promise<void>;
|
|
30
32
|
/** Test helper: inject a READY login without a live socket. */
|
|
31
33
|
setLogin(login: SatoriLogin): void;
|
|
32
34
|
}
|
|
33
35
|
export interface SatoriWebhookEndpointOptions {
|
|
34
36
|
readonly id: CapabilityId;
|
|
35
37
|
readonly gateway: MessageGateway;
|
|
38
|
+
readonly sideEvents?: SideEventGateway;
|
|
36
39
|
readonly http: HttpHost;
|
|
37
40
|
readonly config: ResolvedSatoriWebhookConfig;
|
|
38
41
|
readonly callApi?: SatoriApiCaller;
|
|
@@ -40,6 +43,7 @@ export interface SatoriWebhookEndpointOptions {
|
|
|
40
43
|
export declare class SatoriWebhookEndpoint implements EndpointInstance {
|
|
41
44
|
#private;
|
|
42
45
|
readonly management: EndpointManagement;
|
|
46
|
+
readonly control: EndpointControl;
|
|
43
47
|
constructor(options: SatoriWebhookEndpointOptions);
|
|
44
48
|
/** Used by webhook handler. */
|
|
45
49
|
get isOpen(): boolean;
|
|
@@ -50,7 +54,7 @@ export declare class SatoriWebhookEndpoint implements EndpointInstance {
|
|
|
50
54
|
stop(): Promise<void>;
|
|
51
55
|
send({ conversation, payload }: EndpointSendRequest): Promise<string>;
|
|
52
56
|
admit(body: SatoriEventBody): void;
|
|
53
|
-
recall(id: string): Promise<void>;
|
|
57
|
+
recall(id: string, fallbackChannelId?: string): Promise<void>;
|
|
54
58
|
/** Test helper: inject login without a live webhook push. */
|
|
55
59
|
setLogin(login: SatoriLogin): void;
|
|
56
60
|
}
|
package/lib/endpoint.js
CHANGED
|
@@ -15,6 +15,9 @@ export class SatoriWsEndpoint {
|
|
|
15
15
|
#lastSn;
|
|
16
16
|
#open = false;
|
|
17
17
|
management = createSatoriEndpointManagement((resource, method, params) => this.#api(resource, method, params));
|
|
18
|
+
control = Object.freeze({
|
|
19
|
+
recall: (message) => this.recall(message.id, message.conversation.id),
|
|
20
|
+
});
|
|
18
21
|
constructor(options) {
|
|
19
22
|
this.#logger = getAdapterLogger('satori', options.config.id);
|
|
20
23
|
this.#options = options;
|
|
@@ -114,10 +117,10 @@ export class SatoriWsEndpoint {
|
|
|
114
117
|
}));
|
|
115
118
|
});
|
|
116
119
|
}
|
|
117
|
-
async recall(id) {
|
|
120
|
+
async recall(id, fallbackChannelId) {
|
|
118
121
|
const { channelId, messageId } = parseMessageRef(id);
|
|
119
122
|
await this.#api('message', 'delete', {
|
|
120
|
-
channel_id: channelId,
|
|
123
|
+
channel_id: channelId || fallbackChannelId || '',
|
|
121
124
|
message_id: messageId,
|
|
122
125
|
});
|
|
123
126
|
}
|
|
@@ -248,6 +251,9 @@ export class SatoriWebhookEndpoint {
|
|
|
248
251
|
#open = false;
|
|
249
252
|
#started = false;
|
|
250
253
|
management = createSatoriEndpointManagement((resource, method, params) => this.#api(resource, method, params));
|
|
254
|
+
control = Object.freeze({
|
|
255
|
+
recall: (message) => this.recall(message.id, message.conversation.id),
|
|
256
|
+
});
|
|
251
257
|
constructor(options) {
|
|
252
258
|
this.#logger = getAdapterLogger('satori', options.config.id);
|
|
253
259
|
this.#options = options;
|
|
@@ -343,10 +349,10 @@ export class SatoriWebhookEndpoint {
|
|
|
343
349
|
}));
|
|
344
350
|
});
|
|
345
351
|
}
|
|
346
|
-
async recall(id) {
|
|
352
|
+
async recall(id, fallbackChannelId) {
|
|
347
353
|
const { channelId, messageId } = parseMessageRef(id);
|
|
348
354
|
await this.#api('message', 'delete', {
|
|
349
|
-
channel_id: channelId,
|
|
355
|
+
channel_id: channelId || fallbackChannelId || '',
|
|
350
356
|
message_id: messageId,
|
|
351
357
|
});
|
|
352
358
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zhin.js/adapter-satori",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.0",
|
|
4
4
|
"description": "Zhin.js Satori adapter for Plugin Runtime (WebSocket client)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./lib/index.js",
|
|
@@ -39,10 +39,10 @@
|
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"ws": "^8.21.1",
|
|
42
|
-
"@zhin.js/adapter": "1.
|
|
43
|
-
"@zhin.js/core": "1.5.
|
|
44
|
-
"@zhin.js/host-http": "1.0.
|
|
45
|
-
"@zhin.js/im-contract": "1.0.
|
|
42
|
+
"@zhin.js/adapter": "1.2.0",
|
|
43
|
+
"@zhin.js/core": "1.5.13",
|
|
44
|
+
"@zhin.js/host-http": "1.0.12",
|
|
45
|
+
"@zhin.js/im-contract": "1.0.4",
|
|
46
46
|
"@zhin.js/logger": "1.0.76"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
@@ -50,14 +50,14 @@
|
|
|
50
50
|
"@types/ws": "^8.18.1",
|
|
51
51
|
"typescript": "^6.0.3",
|
|
52
52
|
"vitest": "^4.1.10",
|
|
53
|
-
"@zhin.js/host-http": "1.0.
|
|
54
|
-
"zhin.js": "6.0.
|
|
53
|
+
"@zhin.js/host-http": "1.0.12",
|
|
54
|
+
"zhin.js": "6.0.13"
|
|
55
55
|
},
|
|
56
56
|
"peerDependencies": {
|
|
57
|
-
"@zhin.js/adapter": "1.
|
|
58
|
-
"@zhin.js/command": "1.0.
|
|
59
|
-
"@zhin.js/core": "1.5.
|
|
60
|
-
"zhin.js": "6.0.
|
|
57
|
+
"@zhin.js/adapter": "1.2.0",
|
|
58
|
+
"@zhin.js/command": "1.0.15",
|
|
59
|
+
"@zhin.js/core": "1.5.13",
|
|
60
|
+
"zhin.js": "6.0.13"
|
|
61
61
|
},
|
|
62
62
|
"peerDependenciesMeta": {
|
|
63
63
|
"@zhin.js/command": {
|
package/src/endpoint.ts
CHANGED
|
@@ -5,13 +5,14 @@ import {
|
|
|
5
5
|
createEndpointLifecycle,
|
|
6
6
|
type EndpointChannel,
|
|
7
7
|
type EndpointConnectHandle,
|
|
8
|
+
type EndpointControl,
|
|
8
9
|
type EndpointGroup,
|
|
9
10
|
type EndpointInstance,
|
|
10
11
|
type EndpointLifecycle,
|
|
11
12
|
type EndpointManagement,
|
|
12
13
|
type EndpointSendRequest,
|
|
13
14
|
} from 'zhin.js/adapter';
|
|
14
|
-
import type { MessageGateway } from '@zhin.js/core/runtime';
|
|
15
|
+
import type { MessageGateway, SideEventGateway } from '@zhin.js/core/runtime';
|
|
15
16
|
import type { HttpHost, HttpRouteRegistration } from '@zhin.js/host-http';
|
|
16
17
|
import { formatCompact, getAdapterLogger } from '@zhin.js/logger';
|
|
17
18
|
import type { CapabilityId } from 'zhin.js';
|
|
@@ -48,6 +49,7 @@ export type SatoriApiCaller = typeof callSatoriApi;
|
|
|
48
49
|
export interface SatoriWsEndpointOptions {
|
|
49
50
|
readonly id: CapabilityId;
|
|
50
51
|
readonly gateway: MessageGateway;
|
|
52
|
+
readonly sideEvents?: SideEventGateway;
|
|
51
53
|
readonly config: ResolvedSatoriWsConfig;
|
|
52
54
|
readonly createWebSocket?: CreateSatoriWebSocket;
|
|
53
55
|
readonly callApi?: SatoriApiCaller;
|
|
@@ -65,6 +67,9 @@ export class SatoriWsEndpoint implements EndpointInstance {
|
|
|
65
67
|
readonly management: EndpointManagement = createSatoriEndpointManagement(
|
|
66
68
|
(resource, method, params) => this.#api(resource, method, params),
|
|
67
69
|
);
|
|
70
|
+
readonly control: EndpointControl = Object.freeze<EndpointControl>({
|
|
71
|
+
recall: (message) => this.recall(message.id, message.conversation.id),
|
|
72
|
+
});
|
|
68
73
|
|
|
69
74
|
constructor(options: SatoriWsEndpointOptions) {
|
|
70
75
|
this.#logger = getAdapterLogger('satori', options.config.id);
|
|
@@ -167,10 +172,10 @@ export class SatoriWsEndpoint implements EndpointInstance {
|
|
|
167
172
|
});
|
|
168
173
|
}
|
|
169
174
|
|
|
170
|
-
async recall(id: string): Promise<void> {
|
|
175
|
+
async recall(id: string, fallbackChannelId?: string): Promise<void> {
|
|
171
176
|
const { channelId, messageId } = parseMessageRef(id);
|
|
172
177
|
await this.#api('message', 'delete', {
|
|
173
|
-
channel_id: channelId,
|
|
178
|
+
channel_id: channelId || fallbackChannelId || '',
|
|
174
179
|
message_id: messageId,
|
|
175
180
|
});
|
|
176
181
|
}
|
|
@@ -307,6 +312,7 @@ export class SatoriWsEndpoint implements EndpointInstance {
|
|
|
307
312
|
export interface SatoriWebhookEndpointOptions {
|
|
308
313
|
readonly id: CapabilityId;
|
|
309
314
|
readonly gateway: MessageGateway;
|
|
315
|
+
readonly sideEvents?: SideEventGateway;
|
|
310
316
|
readonly http: HttpHost;
|
|
311
317
|
readonly config: ResolvedSatoriWebhookConfig;
|
|
312
318
|
readonly callApi?: SatoriApiCaller;
|
|
@@ -323,6 +329,9 @@ export class SatoriWebhookEndpoint implements EndpointInstance {
|
|
|
323
329
|
readonly management: EndpointManagement = createSatoriEndpointManagement(
|
|
324
330
|
(resource, method, params) => this.#api(resource, method, params),
|
|
325
331
|
);
|
|
332
|
+
readonly control: EndpointControl = Object.freeze<EndpointControl>({
|
|
333
|
+
recall: (message) => this.recall(message.id, message.conversation.id),
|
|
334
|
+
});
|
|
326
335
|
|
|
327
336
|
constructor(options: SatoriWebhookEndpointOptions) {
|
|
328
337
|
this.#logger = getAdapterLogger('satori', options.config.id);
|
|
@@ -423,10 +432,10 @@ export class SatoriWebhookEndpoint implements EndpointInstance {
|
|
|
423
432
|
});
|
|
424
433
|
}
|
|
425
434
|
|
|
426
|
-
async recall(id: string): Promise<void> {
|
|
435
|
+
async recall(id: string, fallbackChannelId?: string): Promise<void> {
|
|
427
436
|
const { channelId, messageId } = parseMessageRef(id);
|
|
428
437
|
await this.#api('message', 'delete', {
|
|
429
|
-
channel_id: channelId,
|
|
438
|
+
channel_id: channelId || fallbackChannelId || '',
|
|
430
439
|
message_id: messageId,
|
|
431
440
|
});
|
|
432
441
|
}
|