@crazx/dsh-api-session-controller 0.1.6-alpha.1.zw.3 → 0.1.6-alpha.2.zw.2
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/README.i18n.yaml +2 -2
- package/README.md +15 -3
- package/README.zh.md +15 -3
- package/lib/client.js +428 -471
- package/lib/index.js +16 -47
- package/lib/typert.host.js +178 -160
- package/lib/typert.remote-client.js +167 -149
- package/lib/types/agent.d.ts +1 -1
- package/lib/types/agent.js +8 -1
- package/lib/types/client/contract/sessions.d.ts +55 -20
- package/lib/types/client/contract/snapshot.d.ts +0 -14
- package/lib/types/client/index.d.ts +11 -2
- package/lib/types/client/index.js +16 -5
- package/lib/types/client/scope.d.ts +13 -3
- package/lib/types/client/scope.js +15 -22
- package/lib/types/client/sessions/lineage.d.ts +1 -4
- package/lib/types/client/sessions/lineage.js +1 -3
- package/lib/types/client/sessions/manager.d.ts +28 -49
- package/lib/types/client/sessions/manager.js +75 -174
- package/lib/types/client/sessions/projection-store.d.ts +5 -11
- package/lib/types/client/sessions/projection-store.js +6 -14
- package/lib/types/client/sessions/service.d.ts +34 -119
- package/lib/types/client/sessions/service.js +259 -244
- package/lib/types/client/sessions/session.d.ts +7 -20
- package/lib/types/client/sessions/session.js +29 -33
- package/lib/types/commands.d.ts +2 -2
- package/lib/types/commands.js +10 -4
- package/lib/types/control.d.ts +1 -1
- package/lib/types/control.js +1 -41
- package/lib/types/index.d.ts +2 -2
- package/lib/types/index.js +1 -1
- package/lib/types/types.d.ts +3 -17
- package/package.json +70 -70
- package/lib/types/client/sessions/queue-mirror.d.ts +0 -26
- package/lib/types/client/sessions/queue-mirror.js +0 -61
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
const QUEUE_PREVIEW_CHARS = 200;
|
|
2
|
-
// Attachment blocks are excluded: queue presentation renders them from
|
|
3
|
-
// `content`, so the text preview covers only what has no visual form.
|
|
4
|
-
function previewOf(content) {
|
|
5
|
-
const flat = content
|
|
6
|
-
.filter(block => block.type !== 'image' && block.type !== 'file')
|
|
7
|
-
.map(block => (block.type === 'text' ? block.text : `[${block.type}]`))
|
|
8
|
-
.join(' ').replace(/\s+/g, ' ').trim();
|
|
9
|
-
const chars = Array.from(flat);
|
|
10
|
-
return chars.length > QUEUE_PREVIEW_CHARS ? `${chars.slice(0, QUEUE_PREVIEW_CHARS).join('')}…` : flat;
|
|
11
|
-
}
|
|
12
|
-
function textOf(content) {
|
|
13
|
-
if (!content.every(block => block.type === 'text'))
|
|
14
|
-
return null;
|
|
15
|
-
return content.map(block => block.text).join('');
|
|
16
|
-
}
|
|
17
|
-
/** Authoritative transient queue projection and durable steering handoff. */
|
|
18
|
-
export class SessionQueueMirror {
|
|
19
|
-
current = [];
|
|
20
|
-
/**
|
|
21
|
-
* Return the current immutable queue projection.
|
|
22
|
-
* @returns current queue rows.
|
|
23
|
-
*/
|
|
24
|
-
snapshot() {
|
|
25
|
-
return this.current;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Replace from one authoritative stream queue frame.
|
|
29
|
-
* @param items - complete host queue snapshot.
|
|
30
|
-
*/
|
|
31
|
-
replace(items) {
|
|
32
|
-
this.current = items.map((item) => {
|
|
33
|
-
const content = item.message.content;
|
|
34
|
-
return {
|
|
35
|
-
id: item.id,
|
|
36
|
-
messageId: item.message.id,
|
|
37
|
-
placement: item.placement,
|
|
38
|
-
...(item.rpcId === undefined ? {} : { rpcId: item.rpcId }),
|
|
39
|
-
content,
|
|
40
|
-
preview: previewOf(content),
|
|
41
|
-
text: textOf(content),
|
|
42
|
-
};
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Retire a transient steering row once its durable message enters the log.
|
|
47
|
-
* @param event - newly contiguous durable Session event.
|
|
48
|
-
* @returns whether the projection changed.
|
|
49
|
-
*/
|
|
50
|
-
acceptDurable(event) {
|
|
51
|
-
if (event.type !== 'user/message')
|
|
52
|
-
return false;
|
|
53
|
-
const messageId = event.data.id;
|
|
54
|
-
const index = this.current.findIndex(item => item.placement === 'steering' && item.messageId === messageId);
|
|
55
|
-
if (index < 0)
|
|
56
|
-
return false;
|
|
57
|
-
this.current = this.current.filter((_item, candidate) => candidate !== index);
|
|
58
|
-
return true;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
//# sourceMappingURL=queue-mirror.js.map
|