@xenosystem/agent-conversation 0.1.156 → 0.1.157

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.
@@ -0,0 +1,14 @@
1
+ /**
2
+ * A conversation started in a terminal, as the app shows it.
3
+ *
4
+ * The app never saw its turns, so the host's transcript is the truth (decision 0001): it says which turns exist and in
5
+ * what order, and a turn the terminal rewound away is gone here too. Where the app has its own copy of a turn it keeps
6
+ * that copy, which carries what a transcript does not (attachments, a rating). Text and tool cards are then filled from
7
+ * the event log by the usual projection, keyed on the assistant message id, which is the request id.
8
+ */
9
+ import type { AgentConversationTranscriptItem } from '@xenosystem/agent-interface-contract';
10
+ import type { ChatMessage } from './agentChatStore.js';
11
+ export declare function terminalConversationMessages(saved: ChatMessage[], items: AgentConversationTranscriptItem[]): ChatMessage[];
12
+ /** What the list shows for a conversation the app has no title for: the first thing the person typed, or its folder. */
13
+ export declare function terminalConversationTitle(items: AgentConversationTranscriptItem[], folder: string | undefined): string;
14
+ //# sourceMappingURL=terminalConversationMessages.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"terminalConversationMessages.d.ts","sourceRoot":"","sources":["../../src/stores/terminalConversationMessages.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,sCAAsC,CAAA;AAC3F,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AA4BtD,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,WAAW,EAAE,EAAE,KAAK,EAAE,+BAA+B,EAAE,GAAG,WAAW,EAAE,CAsC1H;AAED,wHAAwH;AACxH,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,+BAA+B,EAAE,EAAE,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAKtH"}
@@ -0,0 +1,75 @@
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) {
28
+ const { turns, others } = savedTurns(saved);
29
+ const users = new Map(items.filter((item) => item.kind === 'user').map((item) => [item.requestId, item]));
30
+ const groups = [...others];
31
+ let clock = 0;
32
+ for (const item of items) {
33
+ if (item.kind === 'user')
34
+ continue;
35
+ if (item.kind === 'compaction') {
36
+ clock = time(item.timestamp, clock);
37
+ groups.push([{ id: item.itemId, role: 'assistant', content: `Earlier turns were summarised.\n\n${item.summary}`, timestamp: clock, isCommandResult: true, hideToolbar: true }]);
38
+ continue;
39
+ }
40
+ const kept = turns.get(item.requestId);
41
+ if (kept) {
42
+ groups.push(kept);
43
+ continue;
44
+ }
45
+ const user = users.get(item.requestId);
46
+ clock = time(user?.timestamp ?? item.completedAt, clock);
47
+ groups.push([
48
+ ...(user ? [{ id: user.itemId, role: 'user', content: user.text, timestamp: clock }] : []),
49
+ {
50
+ id: item.requestId,
51
+ role: 'assistant',
52
+ content: item.text,
53
+ timestamp: clock,
54
+ ...(item.model ? { model: item.model } : {}),
55
+ ...(item.error ? { error: item.error } : {}),
56
+ ...(item.completedAt ? { endedAt: time(item.completedAt, clock) } : {}),
57
+ },
58
+ ]);
59
+ }
60
+ // Stable: turns at one instant keep the transcript's order, and a turn is never split.
61
+ const first = (group) => group[0]?.timestamp ?? 0;
62
+ return groups
63
+ .map((group, index) => ({ group, index }))
64
+ .sort((a, b) => first(a.group) - first(b.group) || a.index - b.index)
65
+ .flatMap(({ group }) => group);
66
+ }
67
+ /** What the list shows for a conversation the app has no title for: the first thing the person typed, or its folder. */
68
+ export function terminalConversationTitle(items, folder) {
69
+ const first = items.find((item) => item.kind === 'user')?.text.replace(/\s+/g, ' ').trim();
70
+ if (first)
71
+ return first.length > 60 ? `${first.slice(0, 59)}…` : first;
72
+ const name = folder?.split(/[\\/]/).filter(Boolean).pop();
73
+ return name || 'Terminal conversation';
74
+ }
75
+ //# sourceMappingURL=terminalConversationMessages.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"terminalConversationMessages.js","sourceRoot":"","sources":["../../src/stores/terminalConversationMessages.ts"],"names":[],"mappings":"AAWA,MAAM,IAAI,GAAG,CAAC,KAAyB,EAAE,QAAgB,EAAE,EAAE;IAC3D,MAAM,MAAM,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAA;IACrD,OAAO,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAA;AACpD,CAAC,CAAA;AAED,yGAAyG;AACzG,SAAS,UAAU,CAAC,QAAuB;IACzC,MAAM,KAAK,GAAG,IAAI,GAAG,EAAyB,CAAA;IAC9C,MAAM,MAAM,GAAoB,EAAE,CAAA;IAClC,IAAI,OAAO,GAAkB,EAAE,CAAA;IAC/B,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;QAC/B,IAAI,OAAO,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;YAC5B,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;YACrB,SAAQ;QACV,CAAC;QACD,IAAI,OAAO,CAAC,eAAe,EAAE,CAAC;YAC5B,MAAM,CAAC,IAAI,CAAC,CAAC,GAAG,OAAO,EAAE,OAAO,CAAC,CAAC,CAAA;QACpC,CAAC;aAAM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"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.156",
46
- "@xenosystem/agent-interface-contract": "0.1.156",
47
- "@xenosystem/agent-interface-core": "0.1.156",
48
- "@xenosystem/agent-interface-hub-adapter": "0.1.156"
45
+ "@xenosystem/agent-interface-client": "0.1.157",
46
+ "@xenosystem/agent-interface-contract": "0.1.157",
47
+ "@xenosystem/agent-interface-core": "0.1.157",
48
+ "@xenosystem/agent-interface-hub-adapter": "0.1.157"
49
49
  },
50
50
  "peerDependencies": {
51
51
  "react": "^19.0.0",