@zhin.js/adapter-milky 6.0.13 → 7.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 +46 -0
- package/adapters/milky.js +7 -1
- package/adapters/milky.ts +7 -1
- package/lib/sse-endpoint.d.ts +4 -2
- package/lib/sse-endpoint.js +2 -1
- package/lib/webhook-endpoint.d.ts +4 -2
- package/lib/webhook-endpoint.js +2 -0
- package/lib/ws-endpoint.d.ts +4 -2
- package/lib/ws-endpoint.js +2 -1
- package/lib/wss-endpoint.d.ts +4 -2
- package/lib/wss-endpoint.js +2 -0
- package/package.json +13 -13
- package/src/sse-endpoint.ts +5 -1
- package/src/webhook-endpoint.ts +9 -5
- package/src/ws-endpoint.ts +5 -1
- package/src/wss-endpoint.ts +9 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,51 @@
|
|
|
1
1
|
# @zhin.js/adapter-milky
|
|
2
2
|
|
|
3
|
+
## 7.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
|
+
- Updated dependencies [3dbf990]
|
|
11
|
+
- @zhin.js/host-http@1.0.12
|
|
12
|
+
- @zhin.js/adapter@1.2.0
|
|
13
|
+
- @zhin.js/core@1.5.13
|
|
14
|
+
- @zhin.js/agent@1.1.15
|
|
15
|
+
- zhin.js@6.0.13
|
|
16
|
+
|
|
17
|
+
## 6.0.14
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- 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.
|
|
22
|
+
- Updated dependencies [5969c5b]
|
|
23
|
+
- Updated dependencies [d336a3f]
|
|
24
|
+
- Updated dependencies [0c82a7e]
|
|
25
|
+
- Updated dependencies [b9217e4]
|
|
26
|
+
- Updated dependencies [5969c5b]
|
|
27
|
+
- Updated dependencies [5969c5b]
|
|
28
|
+
- Updated dependencies [974772e]
|
|
29
|
+
- Updated dependencies [5969c5b]
|
|
30
|
+
- Updated dependencies [5969c5b]
|
|
31
|
+
- Updated dependencies [2f786bd]
|
|
32
|
+
- Updated dependencies [63d89f9]
|
|
33
|
+
- Updated dependencies [71c7cdd]
|
|
34
|
+
- Updated dependencies [3cca0ea]
|
|
35
|
+
- Updated dependencies [1312ca0]
|
|
36
|
+
- Updated dependencies [985fa22]
|
|
37
|
+
- Updated dependencies [04b861d]
|
|
38
|
+
- Updated dependencies [a23d544]
|
|
39
|
+
- Updated dependencies [8cddabf]
|
|
40
|
+
- Updated dependencies [dbe5081]
|
|
41
|
+
- @zhin.js/im-contract@1.0.4
|
|
42
|
+
- @zhin.js/core@1.5.12
|
|
43
|
+
- @zhin.js/adapter@1.1.11
|
|
44
|
+
- @zhin.js/agent@1.1.14
|
|
45
|
+
- @zhin.js/host-http@1.0.11
|
|
46
|
+
- @zhin.js/command@1.0.15
|
|
47
|
+
- zhin.js@6.0.12
|
|
48
|
+
|
|
3
49
|
## 6.0.13
|
|
4
50
|
|
|
5
51
|
### Patch Changes
|
package/adapters/milky.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Convention entry: discover `adapters/milky.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 { MilkySseEndpoint, MilkyWebhookEndpoint, MilkyWssEndpoint, MilkyWsEndpoint, } from "../lib/endpoint.js";
|
|
9
9
|
import { resolveMilkyConfig, } from "../lib/protocol.js";
|
|
@@ -11,6 +11,7 @@ import { milkyRuntimeStateToken } from "../lib/milky-runtime-state.js";
|
|
|
11
11
|
export { MilkySseEndpoint, MilkyWebhookEndpoint, MilkyWssEndpoint, MilkyWsEndpoint, } from "../lib/endpoint.js";
|
|
12
12
|
export default defineAdapter({
|
|
13
13
|
capabilities: ['inbound', 'outbound'],
|
|
14
|
+
operations: ['recall'],
|
|
14
15
|
// Milky 协议资源 uri 消费 http(s):// 与 base64:// 形式;无卡片交互面,交互段降级纯文本。
|
|
15
16
|
segments: {
|
|
16
17
|
outboundMedia: ['url', 'base64'],
|
|
@@ -19,6 +20,7 @@ export default defineAdapter({
|
|
|
19
20
|
create(context) {
|
|
20
21
|
const config = resolveMilkyConfig(context.config);
|
|
21
22
|
const gateway = context.use(messageGatewayToken);
|
|
23
|
+
const sideEvents = context.use(sideEventGatewayToken);
|
|
22
24
|
// 注册到插件运行时状态(milky.endpoint list 的"运行中"数据源)
|
|
23
25
|
context.use(milkyRuntimeStateToken).endpoints.set(config.id, {
|
|
24
26
|
id: config.id,
|
|
@@ -28,6 +30,7 @@ export default defineAdapter({
|
|
|
28
30
|
return new MilkyWebhookEndpoint({
|
|
29
31
|
id: context.id,
|
|
30
32
|
gateway,
|
|
33
|
+
sideEvents,
|
|
31
34
|
http: context.use(httpHostToken),
|
|
32
35
|
config,
|
|
33
36
|
});
|
|
@@ -36,6 +39,7 @@ export default defineAdapter({
|
|
|
36
39
|
return new MilkyWssEndpoint({
|
|
37
40
|
id: context.id,
|
|
38
41
|
gateway,
|
|
42
|
+
sideEvents,
|
|
39
43
|
http: context.use(httpHostToken),
|
|
40
44
|
config,
|
|
41
45
|
});
|
|
@@ -44,12 +48,14 @@ export default defineAdapter({
|
|
|
44
48
|
return new MilkySseEndpoint({
|
|
45
49
|
id: context.id,
|
|
46
50
|
gateway,
|
|
51
|
+
sideEvents,
|
|
47
52
|
config,
|
|
48
53
|
});
|
|
49
54
|
}
|
|
50
55
|
return new MilkyWsEndpoint({
|
|
51
56
|
id: context.id,
|
|
52
57
|
gateway,
|
|
58
|
+
sideEvents,
|
|
53
59
|
config,
|
|
54
60
|
});
|
|
55
61
|
},
|
package/adapters/milky.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Convention entry: discover `adapters/milky.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 {
|
|
8
8
|
MilkySseEndpoint,
|
|
@@ -34,6 +34,7 @@ export type {
|
|
|
34
34
|
|
|
35
35
|
export default defineAdapter<MilkyAdapterConfig>({
|
|
36
36
|
capabilities: ['inbound', 'outbound'],
|
|
37
|
+
operations: ['recall'],
|
|
37
38
|
// Milky 协议资源 uri 消费 http(s):// 与 base64:// 形式;无卡片交互面,交互段降级纯文本。
|
|
38
39
|
segments: {
|
|
39
40
|
outboundMedia: ['url', 'base64'],
|
|
@@ -42,6 +43,7 @@ export default defineAdapter<MilkyAdapterConfig>({
|
|
|
42
43
|
create(context) {
|
|
43
44
|
const config = resolveMilkyConfig(context.config);
|
|
44
45
|
const gateway = context.use(messageGatewayToken);
|
|
46
|
+
const sideEvents = context.use(sideEventGatewayToken);
|
|
45
47
|
// 注册到插件运行时状态(milky.endpoint list 的"运行中"数据源)
|
|
46
48
|
context.use(milkyRuntimeStateToken).endpoints.set(config.id, {
|
|
47
49
|
id: config.id,
|
|
@@ -51,6 +53,7 @@ export default defineAdapter<MilkyAdapterConfig>({
|
|
|
51
53
|
return new MilkyWebhookEndpoint({
|
|
52
54
|
id: context.id,
|
|
53
55
|
gateway,
|
|
56
|
+
sideEvents,
|
|
54
57
|
http: context.use(httpHostToken),
|
|
55
58
|
config,
|
|
56
59
|
});
|
|
@@ -59,6 +62,7 @@ export default defineAdapter<MilkyAdapterConfig>({
|
|
|
59
62
|
return new MilkyWssEndpoint({
|
|
60
63
|
id: context.id,
|
|
61
64
|
gateway,
|
|
65
|
+
sideEvents,
|
|
62
66
|
http: context.use(httpHostToken),
|
|
63
67
|
config,
|
|
64
68
|
});
|
|
@@ -67,12 +71,14 @@ export default defineAdapter<MilkyAdapterConfig>({
|
|
|
67
71
|
return new MilkySseEndpoint({
|
|
68
72
|
id: context.id,
|
|
69
73
|
gateway,
|
|
74
|
+
sideEvents,
|
|
70
75
|
config,
|
|
71
76
|
});
|
|
72
77
|
}
|
|
73
78
|
return new MilkyWsEndpoint({
|
|
74
79
|
id: context.id,
|
|
75
80
|
gateway,
|
|
81
|
+
sideEvents,
|
|
76
82
|
config,
|
|
77
83
|
});
|
|
78
84
|
},
|
package/lib/sse-endpoint.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Milky SSE client endpoint — GET text/event-stream on /event.
|
|
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 { CapabilityId } from 'zhin.js';
|
|
7
7
|
import { callApi, type MilkyEvent, type MilkySseConfig } from './protocol.js';
|
|
8
8
|
import { type SseClientHandle } from './sse-client.js';
|
|
@@ -16,6 +16,7 @@ export type CreateMilkySseStream = (options: {
|
|
|
16
16
|
export interface MilkySseEndpointOptions {
|
|
17
17
|
readonly id: CapabilityId;
|
|
18
18
|
readonly gateway: MessageGateway;
|
|
19
|
+
readonly sideEvents?: SideEventGateway;
|
|
19
20
|
readonly config: MilkySseConfig;
|
|
20
21
|
readonly createSseStream?: CreateMilkySseStream;
|
|
21
22
|
readonly callApi?: typeof callApi;
|
|
@@ -23,6 +24,7 @@ export interface MilkySseEndpointOptions {
|
|
|
23
24
|
export declare class MilkySseEndpoint implements EndpointInstance {
|
|
24
25
|
#private;
|
|
25
26
|
readonly management: EndpointManagement;
|
|
27
|
+
readonly control: EndpointControl;
|
|
26
28
|
constructor(options: MilkySseEndpointOptions);
|
|
27
29
|
start(): Promise<void>;
|
|
28
30
|
open(): void;
|
package/lib/sse-endpoint.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Milky SSE client endpoint — GET text/event-stream on /event.
|
|
3
3
|
*/
|
|
4
|
-
import { createEndpointLifecycle, } from 'zhin.js/adapter';
|
|
4
|
+
import { createRecallEndpointControl, createEndpointLifecycle, } from 'zhin.js/adapter';
|
|
5
5
|
import { formatCompact, getAdapterLogger } from '@zhin.js/logger';
|
|
6
6
|
import { createMilkyEndpointManagement } from './endpoint-management.js';
|
|
7
7
|
import { registerMilkyAgentEndpoint } from './milky-agent-deps.js';
|
|
@@ -12,6 +12,7 @@ export class MilkySseEndpoint {
|
|
|
12
12
|
#options;
|
|
13
13
|
#callApi;
|
|
14
14
|
management = createMilkyEndpointManagement(this);
|
|
15
|
+
control = createRecallEndpointControl((id) => this.recallMessage(id));
|
|
15
16
|
#lifecycle;
|
|
16
17
|
#stream;
|
|
17
18
|
#open = false;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import type { MessageGateway } from '@zhin.js/core/runtime';
|
|
1
|
+
import { type EndpointControl, type EndpointInstance, type EndpointManagement, type EndpointSendRequest } from 'zhin.js/adapter';
|
|
2
|
+
import type { MessageGateway, SideEventGateway } from '@zhin.js/core/runtime';
|
|
3
3
|
import type { HttpHost } from '@zhin.js/host-http';
|
|
4
4
|
import type { CapabilityId } from 'zhin.js';
|
|
5
5
|
import { callApi, type MilkyEvent, type MilkyWebhookConfig } from './protocol.js';
|
|
6
6
|
export interface MilkyWebhookEndpointOptions {
|
|
7
7
|
readonly id: CapabilityId;
|
|
8
8
|
readonly gateway: MessageGateway;
|
|
9
|
+
readonly sideEvents?: SideEventGateway;
|
|
9
10
|
readonly http: HttpHost;
|
|
10
11
|
readonly config: MilkyWebhookConfig;
|
|
11
12
|
readonly callApi?: typeof callApi;
|
|
@@ -13,6 +14,7 @@ export interface MilkyWebhookEndpointOptions {
|
|
|
13
14
|
export declare class MilkyWebhookEndpoint implements EndpointInstance {
|
|
14
15
|
#private;
|
|
15
16
|
readonly management: EndpointManagement;
|
|
17
|
+
readonly control: EndpointControl;
|
|
16
18
|
constructor(options: MilkyWebhookEndpointOptions);
|
|
17
19
|
start(): Promise<void>;
|
|
18
20
|
open(): void;
|
package/lib/webhook-endpoint.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { createRecallEndpointControl, } from 'zhin.js/adapter';
|
|
1
2
|
import { formatCompact, getAdapterLogger } from '@zhin.js/logger';
|
|
2
3
|
import { readRequestBody, verifyMilkyAccessToken } from './milky-auth.js';
|
|
3
4
|
import { createMilkyEndpointManagement } from './endpoint-management.js';
|
|
@@ -8,6 +9,7 @@ export class MilkyWebhookEndpoint {
|
|
|
8
9
|
#options;
|
|
9
10
|
#callApi;
|
|
10
11
|
management = createMilkyEndpointManagement(this);
|
|
12
|
+
control = createRecallEndpointControl((id) => this.recallMessage(id));
|
|
11
13
|
#routeReleases = [];
|
|
12
14
|
#open = false;
|
|
13
15
|
#started = false;
|
package/lib/ws-endpoint.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { type EndpointInstance, type EndpointManagement, type EndpointSendRequest } from 'zhin.js/adapter';
|
|
2
|
-
import type { MessageGateway } from '@zhin.js/core/runtime';
|
|
1
|
+
import { type EndpointControl, type EndpointInstance, type EndpointManagement, type EndpointSendRequest } from 'zhin.js/adapter';
|
|
2
|
+
import type { MessageGateway, SideEventGateway } from '@zhin.js/core/runtime';
|
|
3
3
|
import type { CapabilityId } from 'zhin.js';
|
|
4
4
|
import { callApi, type MilkyEvent, type MilkyWsConfig } from './protocol.js';
|
|
5
5
|
import type { MilkyWsCreateOptions, MilkyWsSocket } from './ws-types.js';
|
|
6
6
|
export interface MilkyWsEndpointOptions {
|
|
7
7
|
readonly id: CapabilityId;
|
|
8
8
|
readonly gateway: MessageGateway;
|
|
9
|
+
readonly sideEvents?: SideEventGateway;
|
|
9
10
|
readonly config: MilkyWsConfig;
|
|
10
11
|
readonly createWebSocket?: (url: string, options: MilkyWsCreateOptions) => MilkyWsSocket;
|
|
11
12
|
readonly callApi?: typeof callApi;
|
|
@@ -13,6 +14,7 @@ export interface MilkyWsEndpointOptions {
|
|
|
13
14
|
export declare class MilkyWsEndpoint implements EndpointInstance {
|
|
14
15
|
#private;
|
|
15
16
|
readonly management: EndpointManagement;
|
|
17
|
+
readonly control: EndpointControl;
|
|
16
18
|
constructor(options: MilkyWsEndpointOptions);
|
|
17
19
|
start(): Promise<void>;
|
|
18
20
|
open(): void;
|
package/lib/ws-endpoint.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Milky WS client endpoint — outbound connect to Milky protocol server.
|
|
3
3
|
*/
|
|
4
4
|
import WebSocket from 'ws';
|
|
5
|
-
import { createEndpointLifecycle, } from 'zhin.js/adapter';
|
|
5
|
+
import { createRecallEndpointControl, createEndpointLifecycle, } from 'zhin.js/adapter';
|
|
6
6
|
import { formatCompact, getAdapterLogger } from '@zhin.js/logger';
|
|
7
7
|
import { createMilkyEndpointManagement } from './endpoint-management.js';
|
|
8
8
|
import { registerMilkyAgentEndpoint } from './milky-agent-deps.js';
|
|
@@ -13,6 +13,7 @@ export class MilkyWsEndpoint {
|
|
|
13
13
|
#options;
|
|
14
14
|
#callApi;
|
|
15
15
|
management = createMilkyEndpointManagement(this);
|
|
16
|
+
control = createRecallEndpointControl((id) => this.recallMessage(id));
|
|
16
17
|
#lifecycle;
|
|
17
18
|
#ws;
|
|
18
19
|
#open = false;
|
package/lib/wss-endpoint.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import type { MessageGateway } from '@zhin.js/core/runtime';
|
|
1
|
+
import { type EndpointControl, type EndpointInstance, type EndpointManagement, type EndpointSendRequest } from 'zhin.js/adapter';
|
|
2
|
+
import type { MessageGateway, SideEventGateway } from '@zhin.js/core/runtime';
|
|
3
3
|
import type { HttpHost } from '@zhin.js/host-http';
|
|
4
4
|
import type { CapabilityId } from 'zhin.js';
|
|
5
5
|
import { callApi, type MilkyEvent, type MilkyWssConfig } from './protocol.js';
|
|
6
6
|
export interface MilkyWssEndpointOptions {
|
|
7
7
|
readonly id: CapabilityId;
|
|
8
8
|
readonly gateway: MessageGateway;
|
|
9
|
+
readonly sideEvents?: SideEventGateway;
|
|
9
10
|
readonly http: HttpHost;
|
|
10
11
|
readonly config: MilkyWssConfig;
|
|
11
12
|
readonly callApi?: typeof callApi;
|
|
@@ -13,6 +14,7 @@ export interface MilkyWssEndpointOptions {
|
|
|
13
14
|
export declare class MilkyWssEndpoint implements EndpointInstance {
|
|
14
15
|
#private;
|
|
15
16
|
readonly management: EndpointManagement;
|
|
17
|
+
readonly control: EndpointControl;
|
|
16
18
|
constructor(options: MilkyWssEndpointOptions);
|
|
17
19
|
start(): Promise<void>;
|
|
18
20
|
open(): void;
|
package/lib/wss-endpoint.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* Milky reverse WSS endpoint — httpHostToken WS upgrade inbound + baseUrl HTTP API outbound.
|
|
3
3
|
*/
|
|
4
4
|
import { clearInterval } from 'node:timers';
|
|
5
|
+
import { createRecallEndpointControl, } from 'zhin.js/adapter';
|
|
5
6
|
import { formatCompact, getAdapterLogger } from '@zhin.js/logger';
|
|
6
7
|
import { verifyMilkyAccessToken } from './milky-auth.js';
|
|
7
8
|
import { createMilkyEndpointManagement } from './endpoint-management.js';
|
|
@@ -13,6 +14,7 @@ export class MilkyWssEndpoint {
|
|
|
13
14
|
#options;
|
|
14
15
|
#callApi;
|
|
15
16
|
management = createMilkyEndpointManagement(this);
|
|
17
|
+
control = createRecallEndpointControl((id) => this.recallMessage(id));
|
|
16
18
|
#ws;
|
|
17
19
|
#wsRelease;
|
|
18
20
|
#heartbeatTimer;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zhin.js/adapter-milky",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.0",
|
|
4
4
|
"description": "Zhin.js Milky adapter for Plugin Runtime (WebSocket client)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./lib/index.js",
|
|
@@ -40,10 +40,10 @@
|
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"ws": "^8.21.1",
|
|
43
|
-
"@zhin.js/adapter": "1.
|
|
44
|
-
"@zhin.js/core": "1.5.
|
|
45
|
-
"@zhin.js/host-http": "1.0.
|
|
46
|
-
"@zhin.js/im-contract": "1.0.
|
|
43
|
+
"@zhin.js/adapter": "1.2.0",
|
|
44
|
+
"@zhin.js/core": "1.5.13",
|
|
45
|
+
"@zhin.js/host-http": "1.0.12",
|
|
46
|
+
"@zhin.js/im-contract": "1.0.4",
|
|
47
47
|
"@zhin.js/logger": "1.0.76"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
@@ -52,17 +52,17 @@
|
|
|
52
52
|
"typescript": "^6.0.3",
|
|
53
53
|
"vitest": "^4.1.10",
|
|
54
54
|
"zod": "^4.4.3",
|
|
55
|
-
"@zhin.js/agent": "1.1.
|
|
56
|
-
"@zhin.js/host-http": "1.0.
|
|
57
|
-
"zhin.js": "6.0.
|
|
55
|
+
"@zhin.js/agent": "1.1.15",
|
|
56
|
+
"@zhin.js/host-http": "1.0.12",
|
|
57
|
+
"zhin.js": "6.0.13"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
60
60
|
"zod": "^4.0.0",
|
|
61
|
-
"@zhin.js/adapter": "1.
|
|
62
|
-
"@zhin.js/agent": "1.1.
|
|
63
|
-
"@zhin.js/command": "1.0.
|
|
64
|
-
"@zhin.js/core": "1.5.
|
|
65
|
-
"zhin.js": "6.0.
|
|
61
|
+
"@zhin.js/adapter": "1.2.0",
|
|
62
|
+
"@zhin.js/agent": "1.1.15",
|
|
63
|
+
"@zhin.js/command": "1.0.15",
|
|
64
|
+
"@zhin.js/core": "1.5.13",
|
|
65
|
+
"zhin.js": "6.0.13"
|
|
66
66
|
},
|
|
67
67
|
"peerDependenciesMeta": {
|
|
68
68
|
"@zhin.js/agent": {
|
package/src/sse-endpoint.ts
CHANGED
|
@@ -2,14 +2,16 @@
|
|
|
2
2
|
* Milky SSE client endpoint — GET text/event-stream on /event.
|
|
3
3
|
*/
|
|
4
4
|
import {
|
|
5
|
+
createRecallEndpointControl,
|
|
5
6
|
createEndpointLifecycle,
|
|
6
7
|
type EndpointConnectHandle,
|
|
8
|
+
type EndpointControl,
|
|
7
9
|
type EndpointInstance,
|
|
8
10
|
type EndpointLifecycle,
|
|
9
11
|
type EndpointManagement,
|
|
10
12
|
type EndpointSendRequest,
|
|
11
13
|
} from 'zhin.js/adapter';
|
|
12
|
-
import type { MessageGateway } from '@zhin.js/core/runtime';
|
|
14
|
+
import type { MessageGateway, SideEventGateway } from '@zhin.js/core/runtime';
|
|
13
15
|
import { formatCompact, getAdapterLogger } from '@zhin.js/logger';
|
|
14
16
|
import type { CapabilityId } from 'zhin.js';
|
|
15
17
|
import { createMilkyEndpointManagement } from './endpoint-management.js';
|
|
@@ -46,6 +48,7 @@ export type CreateMilkySseStream = (options: {
|
|
|
46
48
|
export interface MilkySseEndpointOptions {
|
|
47
49
|
readonly id: CapabilityId;
|
|
48
50
|
readonly gateway: MessageGateway;
|
|
51
|
+
readonly sideEvents?: SideEventGateway;
|
|
49
52
|
readonly config: MilkySseConfig;
|
|
50
53
|
readonly createSseStream?: CreateMilkySseStream;
|
|
51
54
|
readonly callApi?: typeof callApi;
|
|
@@ -57,6 +60,7 @@ export class MilkySseEndpoint implements EndpointInstance {
|
|
|
57
60
|
readonly #options: MilkySseEndpointOptions;
|
|
58
61
|
readonly #callApi: typeof callApi;
|
|
59
62
|
readonly management: EndpointManagement = createMilkyEndpointManagement(this);
|
|
63
|
+
readonly control: EndpointControl = createRecallEndpointControl((id) => this.recallMessage(id));
|
|
60
64
|
readonly #lifecycle: EndpointLifecycle;
|
|
61
65
|
#stream?: SseClientHandle;
|
|
62
66
|
#open = false;
|
package/src/webhook-endpoint.ts
CHANGED
|
@@ -2,12 +2,14 @@
|
|
|
2
2
|
* Milky webhook endpoint — httpHostToken POST inbound + baseUrl HTTP API outbound.
|
|
3
3
|
*/
|
|
4
4
|
import type { IncomingMessage, ServerResponse } from 'node:http';
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
import {
|
|
6
|
+
createRecallEndpointControl,
|
|
7
|
+
type EndpointControl,
|
|
8
|
+
type EndpointInstance,
|
|
9
|
+
type EndpointManagement,
|
|
10
|
+
type EndpointSendRequest,
|
|
9
11
|
} from 'zhin.js/adapter';
|
|
10
|
-
import type { MessageGateway } from '@zhin.js/core/runtime';
|
|
12
|
+
import type { MessageGateway, SideEventGateway } from '@zhin.js/core/runtime';
|
|
11
13
|
import type { HttpHost, HttpRouteRegistration } from '@zhin.js/host-http';
|
|
12
14
|
import { formatCompact, getAdapterLogger } from '@zhin.js/logger';
|
|
13
15
|
import type { CapabilityId } from 'zhin.js';
|
|
@@ -36,6 +38,7 @@ import {
|
|
|
36
38
|
export interface MilkyWebhookEndpointOptions {
|
|
37
39
|
readonly id: CapabilityId;
|
|
38
40
|
readonly gateway: MessageGateway;
|
|
41
|
+
readonly sideEvents?: SideEventGateway;
|
|
39
42
|
readonly http: HttpHost;
|
|
40
43
|
readonly config: MilkyWebhookConfig;
|
|
41
44
|
readonly callApi?: typeof callApi;
|
|
@@ -47,6 +50,7 @@ export class MilkyWebhookEndpoint implements EndpointInstance {
|
|
|
47
50
|
readonly #options: MilkyWebhookEndpointOptions;
|
|
48
51
|
readonly #callApi: typeof callApi;
|
|
49
52
|
readonly management: EndpointManagement = createMilkyEndpointManagement(this);
|
|
53
|
+
readonly control: EndpointControl = createRecallEndpointControl((id) => this.recallMessage(id));
|
|
50
54
|
#routeReleases: HttpRouteRegistration[] = [];
|
|
51
55
|
#open = false;
|
|
52
56
|
#started = false;
|
package/src/ws-endpoint.ts
CHANGED
|
@@ -3,14 +3,16 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import WebSocket from 'ws';
|
|
5
5
|
import {
|
|
6
|
+
createRecallEndpointControl,
|
|
6
7
|
createEndpointLifecycle,
|
|
7
8
|
type EndpointConnectHandle,
|
|
9
|
+
type EndpointControl,
|
|
8
10
|
type EndpointInstance,
|
|
9
11
|
type EndpointLifecycle,
|
|
10
12
|
type EndpointManagement,
|
|
11
13
|
type EndpointSendRequest,
|
|
12
14
|
} from 'zhin.js/adapter';
|
|
13
|
-
import type { MessageGateway } from '@zhin.js/core/runtime';
|
|
15
|
+
import type { MessageGateway, SideEventGateway } from '@zhin.js/core/runtime';
|
|
14
16
|
import { formatCompact, getAdapterLogger } from '@zhin.js/logger';
|
|
15
17
|
import type { CapabilityId } from 'zhin.js';
|
|
16
18
|
import { createMilkyEndpointManagement } from './endpoint-management.js';
|
|
@@ -41,6 +43,7 @@ const WS_OPEN = 1;
|
|
|
41
43
|
export interface MilkyWsEndpointOptions {
|
|
42
44
|
readonly id: CapabilityId;
|
|
43
45
|
readonly gateway: MessageGateway;
|
|
46
|
+
readonly sideEvents?: SideEventGateway;
|
|
44
47
|
readonly config: MilkyWsConfig;
|
|
45
48
|
readonly createWebSocket?: (
|
|
46
49
|
url: string,
|
|
@@ -55,6 +58,7 @@ export class MilkyWsEndpoint implements EndpointInstance {
|
|
|
55
58
|
readonly #options: MilkyWsEndpointOptions;
|
|
56
59
|
readonly #callApi: typeof callApi;
|
|
57
60
|
readonly management: EndpointManagement = createMilkyEndpointManagement(this);
|
|
61
|
+
readonly control: EndpointControl = createRecallEndpointControl((id) => this.recallMessage(id));
|
|
58
62
|
readonly #lifecycle: EndpointLifecycle;
|
|
59
63
|
#ws?: MilkyWsSocket;
|
|
60
64
|
#open = false;
|
package/src/wss-endpoint.ts
CHANGED
|
@@ -2,12 +2,14 @@
|
|
|
2
2
|
* Milky reverse WSS endpoint — httpHostToken WS upgrade inbound + baseUrl HTTP API outbound.
|
|
3
3
|
*/
|
|
4
4
|
import { clearInterval } from 'node:timers';
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
import {
|
|
6
|
+
createRecallEndpointControl,
|
|
7
|
+
type EndpointControl,
|
|
8
|
+
type EndpointInstance,
|
|
9
|
+
type EndpointManagement,
|
|
10
|
+
type EndpointSendRequest,
|
|
9
11
|
} from 'zhin.js/adapter';
|
|
10
|
-
import type { MessageGateway } from '@zhin.js/core/runtime';
|
|
12
|
+
import type { MessageGateway, SideEventGateway } from '@zhin.js/core/runtime';
|
|
11
13
|
import type { HttpHost, WsConnection } from '@zhin.js/host-http';
|
|
12
14
|
import { formatCompact, getAdapterLogger } from '@zhin.js/logger';
|
|
13
15
|
import type { CapabilityId } from 'zhin.js';
|
|
@@ -39,6 +41,7 @@ const WS_OPEN = 1;
|
|
|
39
41
|
export interface MilkyWssEndpointOptions {
|
|
40
42
|
readonly id: CapabilityId;
|
|
41
43
|
readonly gateway: MessageGateway;
|
|
44
|
+
readonly sideEvents?: SideEventGateway;
|
|
42
45
|
readonly http: HttpHost;
|
|
43
46
|
readonly config: MilkyWssConfig;
|
|
44
47
|
readonly callApi?: typeof callApi;
|
|
@@ -50,6 +53,7 @@ export class MilkyWssEndpoint implements EndpointInstance {
|
|
|
50
53
|
readonly #options: MilkyWssEndpointOptions;
|
|
51
54
|
readonly #callApi: typeof callApi;
|
|
52
55
|
readonly management: EndpointManagement = createMilkyEndpointManagement(this);
|
|
56
|
+
readonly control: EndpointControl = createRecallEndpointControl((id) => this.recallMessage(id));
|
|
53
57
|
#ws?: MilkyWsSocket;
|
|
54
58
|
#wsRelease?: () => void;
|
|
55
59
|
#heartbeatTimer?: NodeJS.Timeout;
|