@xenosystem/agent-conversation 0.1.156 → 0.1.158
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/dist/components/agent/mainAssistant.d.ts.map +1 -1
- package/dist/components/agent/mainAssistant.js +2 -1
- package/dist/components/agent/mainAssistant.js.map +1 -1
- package/dist/platformApiTypes.d.ts +2 -0
- package/dist/platformApiTypes.d.ts.map +1 -1
- package/dist/stores/agentChatStore.d.ts +6 -1
- package/dist/stores/agentChatStore.d.ts.map +1 -1
- package/dist/stores/agentChatStore.js +56 -4
- package/dist/stores/agentChatStore.js.map +1 -1
- package/dist/stores/terminalConversationMessages.d.ts +24 -0
- package/dist/stores/terminalConversationMessages.d.ts.map +1 -0
- package/dist/stores/terminalConversationMessages.js +83 -0
- package/dist/stores/terminalConversationMessages.js.map +1 -0
- package/package.json +5 -5
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A conversation started in a terminal, as the app shows it.
|
|
3
|
+
*
|
|
4
|
+
* Turns come from two places. The host's log has every turn run anywhere (decision 0001), and the app's copy has what the
|
|
5
|
+
* person did here, which the log does not know about: a message edited or a restore undoes a turn in this copy and nowhere
|
|
6
|
+
* else. So the copy is never overruled. A turn missing from it is added only if it is NEW, meaning past the point in the
|
|
7
|
+
* log the app last read. A turn the app already saw and no longer has was removed on purpose, and stays out.
|
|
8
|
+
*
|
|
9
|
+
* Where the app has its own copy of a turn it keeps that copy, which carries what a transcript does not (attachments, a
|
|
10
|
+
* rating). A turn only the copy has is kept too. Text and tool cards are then filled from the event log by the usual
|
|
11
|
+
* projection, keyed on the assistant message id, which is the request id.
|
|
12
|
+
*/
|
|
13
|
+
import type { AgentConversationTranscriptItem } from '@xenosystem/agent-interface-contract';
|
|
14
|
+
import type { ChatMessage } from './agentChatStore.js';
|
|
15
|
+
export interface TerminalTurnsContext {
|
|
16
|
+
/** How far through the host's log the app has read: `transcriptSeenSequence` on the conversation. */
|
|
17
|
+
seenSequence?: number | undefined;
|
|
18
|
+
/** Reply ids held only by an inactive branch: turns the person edited away. Covers a read position saved too late. */
|
|
19
|
+
supersededIds?: ReadonlySet<string> | undefined;
|
|
20
|
+
}
|
|
21
|
+
export declare function terminalConversationMessages(saved: ChatMessage[], items: AgentConversationTranscriptItem[], context?: TerminalTurnsContext): ChatMessage[];
|
|
22
|
+
/** What the list shows for a conversation the app has no title for: the first thing the person typed, or its folder. */
|
|
23
|
+
export declare function terminalConversationTitle(items: AgentConversationTranscriptItem[], folder: string | undefined): string;
|
|
24
|
+
//# sourceMappingURL=terminalConversationMessages.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"terminalConversationMessages.d.ts","sourceRoot":"","sources":["../../src/stores/terminalConversationMessages.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,sCAAsC,CAAA;AAC3F,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AA4BtD,MAAM,WAAW,oBAAoB;IACnC,qGAAqG;IACrG,YAAY,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IACjC,sHAAsH;IACtH,aAAa,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,SAAS,CAAA;CAChD;AAED,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,WAAW,EAAE,EAAE,KAAK,EAAE,+BAA+B,EAAE,EAAE,OAAO,GAAE,oBAAyB,GAAG,WAAW,EAAE,CA4C9J;AAED,wHAAwH;AACxH,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,+BAA+B,EAAE,EAAE,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAKtH"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
const time = (value, fallback) => {
|
|
2
|
+
const parsed = value ? Date.parse(value) : Number.NaN;
|
|
3
|
+
return Number.isFinite(parsed) ? parsed : fallback;
|
|
4
|
+
};
|
|
5
|
+
/** The app's messages, grouped into turns: an assistant message and the user messages that led to it. */
|
|
6
|
+
function savedTurns(messages) {
|
|
7
|
+
const turns = new Map();
|
|
8
|
+
const others = [];
|
|
9
|
+
let pending = [];
|
|
10
|
+
for (const message of messages) {
|
|
11
|
+
if (message.role === 'user') {
|
|
12
|
+
pending.push(message);
|
|
13
|
+
continue;
|
|
14
|
+
}
|
|
15
|
+
if (message.isCommandResult) {
|
|
16
|
+
others.push([...pending, message]);
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
turns.set(message.id, [...pending, message]);
|
|
20
|
+
}
|
|
21
|
+
pending = [];
|
|
22
|
+
}
|
|
23
|
+
if (pending.length)
|
|
24
|
+
others.push(pending);
|
|
25
|
+
return { turns, others };
|
|
26
|
+
}
|
|
27
|
+
export function terminalConversationMessages(saved, items, context = {}) {
|
|
28
|
+
const { turns, others } = savedTurns(saved);
|
|
29
|
+
const users = new Map(items.filter((item) => item.kind === 'user').map((item) => [item.requestId, item]));
|
|
30
|
+
const inLog = new Set(items.flatMap((item) => (item.kind === 'assistant' ? [item.requestId] : [])));
|
|
31
|
+
const seen = context.seenSequence ?? 0;
|
|
32
|
+
const groups = [...others, ...[...turns].filter(([id]) => !inLog.has(id)).map(([, group]) => group)];
|
|
33
|
+
let clock = 0;
|
|
34
|
+
for (const item of items) {
|
|
35
|
+
if (item.kind === 'user')
|
|
36
|
+
continue;
|
|
37
|
+
if (item.kind === 'compaction') {
|
|
38
|
+
clock = time(item.timestamp, clock);
|
|
39
|
+
// Saved with the copy once it has been shown, so it is already among the others.
|
|
40
|
+
if (saved.some((message) => message.id === item.itemId))
|
|
41
|
+
continue;
|
|
42
|
+
groups.push([{ id: item.itemId, role: 'assistant', content: `Earlier turns were summarised.\n\n${item.summary}`, timestamp: clock, isCommandResult: true, hideToolbar: true }]);
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
const kept = turns.get(item.requestId);
|
|
46
|
+
if (kept) {
|
|
47
|
+
groups.push(kept);
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
const user = users.get(item.requestId);
|
|
51
|
+
// A turn with no recorded input predates decision 0001, so any read position is past it.
|
|
52
|
+
if (context.supersededIds?.has(item.requestId) || (user?.sequence ?? 0) <= seen && seen > 0)
|
|
53
|
+
continue;
|
|
54
|
+
clock = time(user?.timestamp ?? item.completedAt, clock);
|
|
55
|
+
groups.push([
|
|
56
|
+
...(user ? [{ id: user.itemId, role: 'user', content: user.text, timestamp: clock }] : []),
|
|
57
|
+
{
|
|
58
|
+
id: item.requestId,
|
|
59
|
+
role: 'assistant',
|
|
60
|
+
content: item.text,
|
|
61
|
+
timestamp: clock,
|
|
62
|
+
...(item.model ? { model: item.model } : {}),
|
|
63
|
+
...(item.error ? { error: item.error } : {}),
|
|
64
|
+
...(item.completedAt ? { endedAt: time(item.completedAt, clock) } : {}),
|
|
65
|
+
},
|
|
66
|
+
]);
|
|
67
|
+
}
|
|
68
|
+
// Stable: turns at one instant keep the transcript's order, and a turn is never split.
|
|
69
|
+
const first = (group) => group[0]?.timestamp ?? 0;
|
|
70
|
+
return groups
|
|
71
|
+
.map((group, index) => ({ group, index }))
|
|
72
|
+
.sort((a, b) => first(a.group) - first(b.group) || a.index - b.index)
|
|
73
|
+
.flatMap(({ group }) => group);
|
|
74
|
+
}
|
|
75
|
+
/** What the list shows for a conversation the app has no title for: the first thing the person typed, or its folder. */
|
|
76
|
+
export function terminalConversationTitle(items, folder) {
|
|
77
|
+
const first = items.find((item) => item.kind === 'user')?.text.replace(/\s+/g, ' ').trim();
|
|
78
|
+
if (first)
|
|
79
|
+
return first.length > 60 ? `${first.slice(0, 59)}…` : first;
|
|
80
|
+
const name = folder?.split(/[\\/]/).filter(Boolean).pop();
|
|
81
|
+
return name || 'Terminal conversation';
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=terminalConversationMessages.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"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,CAAC,IAAI,EAAE,CAAA;IAC1F,IAAI,KAAK;QAAE,OAAO,KAAK,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAA;IACtE,MAAM,IAAI,GAAG,MAAM,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,CAAA;IACzD,OAAO,IAAI,IAAI,uBAAuB,CAAA;AACxC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xenosystem/agent-conversation",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.158",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"description": "The XENO Agent conversation surface: the transcript, the composer, and the logic behind them.",
|
|
6
6
|
"type": "module",
|
|
@@ -42,10 +42,10 @@
|
|
|
42
42
|
"react-markdown": "^10.1.0",
|
|
43
43
|
"remark-gfm": "^4.0.1",
|
|
44
44
|
"zustand": "^5.0.2",
|
|
45
|
-
"@xenosystem/agent-interface-client": "0.1.
|
|
46
|
-
"@xenosystem/agent-interface-
|
|
47
|
-
"@xenosystem/agent-interface-
|
|
48
|
-
"@xenosystem/agent-interface-
|
|
45
|
+
"@xenosystem/agent-interface-client": "0.1.158",
|
|
46
|
+
"@xenosystem/agent-interface-hub-adapter": "0.1.158",
|
|
47
|
+
"@xenosystem/agent-interface-contract": "0.1.158",
|
|
48
|
+
"@xenosystem/agent-interface-core": "0.1.158"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
51
|
"react": "^19.0.0",
|