@prur/dsh-chat-service 0.1.17 → 0.2.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/lib/events.d.ts +9 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +9 -0
- package/package.json +2 -2
package/lib/events.d.ts
CHANGED
|
@@ -11,6 +11,15 @@
|
|
|
11
11
|
import type { Context } from '@deepseek-ai/cordis';
|
|
12
12
|
/** The three chat events a client may receive on the downlink. */
|
|
13
13
|
export type ChatDownlinkEvent = 'chat/message' | 'chat/chunk' | 'chat/status';
|
|
14
|
+
/** Cross-plugin cordis event emitted when a chat turn completes (B4 E2E push hook). */
|
|
15
|
+
export interface ChatTurnEndEvent {
|
|
16
|
+
conversationId: string;
|
|
17
|
+
}
|
|
18
|
+
declare module '@deepseek-ai/cordis' {
|
|
19
|
+
interface Events {
|
|
20
|
+
'chat/turn-end'(evt: ChatTurnEndEvent): void;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
14
23
|
/**
|
|
15
24
|
* Downlink frame: the full `server-request` envelope the DSH downlink
|
|
16
25
|
* transport uses (exact same shape as `/api/events.host` remote-event
|
package/lib/index.d.ts
CHANGED
|
@@ -54,6 +54,8 @@ export declare class ChatService extends TypertRemoteService {
|
|
|
54
54
|
private readonly runners;
|
|
55
55
|
private readonly bus;
|
|
56
56
|
private readonly gateway;
|
|
57
|
+
/** Cordis context for emitting cross-plugin events (e.g. chat turn completion for push). */
|
|
58
|
+
private _ctx;
|
|
57
59
|
constructor(ctx: Context, config: ChatServiceConfig);
|
|
58
60
|
/** Re-run queued sends and settle half-finished conversations on startup. */
|
|
59
61
|
private recover;
|
package/lib/index.js
CHANGED
|
@@ -140,8 +140,11 @@ let ChatService = (() => {
|
|
|
140
140
|
runners = new Map();
|
|
141
141
|
bus = new ChatEventBus();
|
|
142
142
|
gateway;
|
|
143
|
+
/** Cordis context for emitting cross-plugin events (e.g. chat turn completion for push). */
|
|
144
|
+
_ctx;
|
|
143
145
|
constructor(ctx, config) {
|
|
144
146
|
super(ctx, 'chat');
|
|
147
|
+
this._ctx = ctx;
|
|
145
148
|
this.gateway = new ChatEventsGateway(ctx, config.trustedHosts, config.apiToken);
|
|
146
149
|
this.bus.subscribe(frame => this.gateway.broadcast(frame));
|
|
147
150
|
// Recover pending queues after a host restart: a half-finished turn can
|
|
@@ -564,6 +567,12 @@ let ChatService = (() => {
|
|
|
564
567
|
}
|
|
565
568
|
emitStatus(conversationId, status) {
|
|
566
569
|
this.bus.publish('chat/status', [conversationId, status]);
|
|
570
|
+
// B4 E2E: on a real turn completion (running→false, not user-aborted), broadcast a
|
|
571
|
+
// cross-plugin cordis event so the push-bridge can emit a wake-up push carrying the
|
|
572
|
+
// conversationId (client routes to the Chat surface).
|
|
573
|
+
if (status.running === false && status.reason !== 'aborted') {
|
|
574
|
+
this._ctx.emit('chat/turn-end', { conversationId });
|
|
575
|
+
}
|
|
567
576
|
}
|
|
568
577
|
};
|
|
569
578
|
})();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prur/dsh-chat-service",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Typert Remote namespace exposing a plain streaming model chat (no agent loop) to DSH Mobile clients",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"@deepseek-ai/schemastery": "^3.18.1",
|
|
36
36
|
"ws": "^8.21.0",
|
|
37
37
|
"zod": "^4.4.3",
|
|
38
|
-
"@prur/dsh-client-connection-mobile": "^0.
|
|
38
|
+
"@prur/dsh-client-connection-mobile": "^0.2.0"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
41
|
"@deepseek-ai/cordis": "^4.0.1",
|