@zhin.js/core 1.5.14 → 1.5.16
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.
|
@@ -12,6 +12,8 @@ export declare const outboundMessageToken: import("@zhin.js/plugin-runtime").Tok
|
|
|
12
12
|
/** Generation-owned ingress hooks before ordinary dispatch and after it misses. */
|
|
13
13
|
export interface IngressRoute {
|
|
14
14
|
preRoute?(message: Message, lease: SnapshotLease, requester: PluginId, conversationSequence: number | undefined): Promise<boolean>;
|
|
15
|
+
/** A live pre-route handoff that must run before handlers and commands. */
|
|
16
|
+
shouldRouteBeforeDispatch?(message: Message): boolean;
|
|
15
17
|
route(message: Message, lease: SnapshotLease, requester: PluginId, conversationSequence: number | undefined): Promise<boolean>;
|
|
16
18
|
}
|
|
17
19
|
export declare const ingressRouteToken: import("@zhin.js/plugin-runtime").Token<IngressRoute>;
|
|
@@ -89,6 +91,8 @@ export declare class ImRuntime implements OutboundMessageService {
|
|
|
89
91
|
*/
|
|
90
92
|
onMessage(listener: (event: RuntimeMessageEvent) => void): () => void;
|
|
91
93
|
send(request: SendRequest): Promise<DeliveryReceipt>;
|
|
94
|
+
/** Sends through the exact generation lease that admitted the current operation. */
|
|
95
|
+
sendWithSnapshotLease(lease: SnapshotLease, request: SendRequest): Promise<DeliveryReceipt>;
|
|
92
96
|
receiveEndpointEvent(event: EndpointEvent, admission?: GenerationAdmissionGate): Promise<unknown>;
|
|
93
97
|
/** Console `endpoint.list` — empty until Adapter Feature projection is ready. */
|
|
94
98
|
listEndpoints(): readonly {
|
|
@@ -402,6 +402,13 @@ export class ImRuntime {
|
|
|
402
402
|
result = Object.freeze({ matched: true, command: 'pre-route', owner: requester });
|
|
403
403
|
return;
|
|
404
404
|
}
|
|
405
|
+
if (ingressRoute?.shouldRouteBeforeDispatch?.(message) === true) {
|
|
406
|
+
const handled = await ingressRoute.route(message, lease, requester, conversationSequence);
|
|
407
|
+
if (handled) {
|
|
408
|
+
result = Object.freeze({ matched: true, command: 'ai', owner: requester });
|
|
409
|
+
return;
|
|
410
|
+
}
|
|
411
|
+
}
|
|
405
412
|
await this.#runHandlers(lease.value, 'message.receive', [
|
|
406
413
|
withEndpointEventPayload(source, message),
|
|
407
414
|
]);
|
|
@@ -447,6 +454,13 @@ export class ImRuntime {
|
|
|
447
454
|
this.#release(lease);
|
|
448
455
|
}
|
|
449
456
|
}
|
|
457
|
+
/** Sends through the exact generation lease that admitted the current operation. */
|
|
458
|
+
async sendWithSnapshotLease(lease, request) {
|
|
459
|
+
if (!this.#snapshots?.owns(lease) || !lease.active) {
|
|
460
|
+
throw new Error('Outbound message generation lease expired');
|
|
461
|
+
}
|
|
462
|
+
return this.#sendWithSnapshot(request, lease.value);
|
|
463
|
+
}
|
|
450
464
|
async #receiveNotice(source) {
|
|
451
465
|
const notice = source.payload;
|
|
452
466
|
const event = conversationEventFromNotice(notice);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zhin.js/core",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.16",
|
|
4
4
|
"description": "Zhin机器人核心框架",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./lib/index.js",
|
|
@@ -75,10 +75,10 @@
|
|
|
75
75
|
"segment-matcher": "^1.0.5",
|
|
76
76
|
"smol-toml": "^1.7.1",
|
|
77
77
|
"yaml": "^2.9.0",
|
|
78
|
-
"@zhin.js/adapter": "1.2.
|
|
78
|
+
"@zhin.js/adapter": "1.2.2",
|
|
79
79
|
"@zhin.js/command": "1.0.16",
|
|
80
80
|
"@zhin.js/component": "1.0.13",
|
|
81
|
-
"@zhin.js/database": "1.0.
|
|
81
|
+
"@zhin.js/database": "1.0.81",
|
|
82
82
|
"@zhin.js/handler": "1.0.4",
|
|
83
83
|
"@zhin.js/im-contract": "1.0.4",
|
|
84
84
|
"@zhin.js/interaction": "1.0.1",
|
|
@@ -102,7 +102,7 @@
|
|
|
102
102
|
"@types/qrcode": "^1.5.6",
|
|
103
103
|
"ajv": "8.18.0",
|
|
104
104
|
"typescript": "^6.0.3",
|
|
105
|
-
"@zhin.js/ai": "1.5.
|
|
105
|
+
"@zhin.js/ai": "1.5.9"
|
|
106
106
|
},
|
|
107
107
|
"repository": {
|
|
108
108
|
"type": "git",
|