@jini-ai/chat 0.3.9 → 0.3.11
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/core/assistant-content.d.ts +29 -0
- package/dist/core/assistant-content.js +41 -0
- package/dist/core/compact-events.d.ts +23 -0
- package/dist/core/compact-events.js +23 -0
- package/dist/core/events.d.ts +2 -0
- package/dist/core/index.d.ts +4 -0
- package/dist/core/index.js +4 -0
- package/dist/core/run-activity.d.ts +88 -0
- package/dist/core/run-activity.js +153 -0
- package/dist/core/tool-output.d.ts +13 -0
- package/dist/core/tool-output.js +24 -0
- package/dist/react/components/Markdown.js +21 -7
- package/dist/react/components/McpUiSurfaceCard.d.ts +9 -1
- package/dist/react/components/McpUiSurfaceCard.js +43 -2
- package/dist/react/components/MessageRow.js +28 -7
- package/dist/react/components/ToolCard.js +6 -6
- package/dist/react/ext-event-renderer-registry.d.ts +39 -1
- package/dist/react/ext-event-renderer-registry.js +23 -4
- package/dist/react/features/chat-pane/components/ChatPane.js +5 -4
- package/dist/react/features/chat-pane/hooks/useChatPaneRuntimeInventory.hooks.d.ts +18 -1
- package/dist/react/features/chat-pane/hooks/useChatPaneRuntimeInventory.hooks.js +158 -17
- package/dist/react/features/chat-pane/styles.d.ts +1 -1
- package/dist/react/features/chat-pane/styles.js +7 -2
- package/dist/react/hooks/useConversation.js +13 -11
- package/dist/react/hooks/useExtEventGroups.d.ts +13 -1
- package/dist/react/hooks/useExtEventGroups.js +38 -9
- package/dist/react/hooks/useRunActivity.d.ts +12 -0
- package/dist/react/hooks/useRunActivity.js +44 -0
- package/dist/react/index.d.ts +3 -3
- package/dist/react/index.js +2 -2
- package/dist/react/message-blocks.d.ts +6 -1
- package/dist/react/message-blocks.js +14 -13
- package/package.json +4 -4
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { assistantContentFromEvents, legacyAssistantContentFromEvents } from '../core/index.js';
|
|
1
2
|
/**
|
|
2
3
|
* Rebuilds an assistant message as ordered blocks, or returns `null` if that cannot be done
|
|
3
4
|
* losslessly.
|
|
@@ -6,10 +7,11 @@
|
|
|
6
7
|
* @param content - The message's `content`, expected to equal the concatenated text events.
|
|
7
8
|
* @param rows - The tool timeline rows, already deduped and paired by `useToolTimeline`. Only rows
|
|
8
9
|
* present here are emitted, so a row the timeline chose to drop stays dropped.
|
|
10
|
+
* @param slotOf - The render slot an ext event belongs to (default: its `name`).
|
|
9
11
|
* @returns Ordered blocks, or `null` to signal "render the flat layout instead".
|
|
10
12
|
* @complexity O(n + m) in the event and row counts.
|
|
11
13
|
*/
|
|
12
|
-
export function interleaveMessageBlocks(events, content, rows) {
|
|
14
|
+
export function interleaveMessageBlocks(events, content, rows, slotOf = (ev) => ev.name) {
|
|
13
15
|
if (!events || events.length === 0)
|
|
14
16
|
return null;
|
|
15
17
|
const hasExtEvent = events.some((ev) => ev.kind === 'ext');
|
|
@@ -17,17 +19,14 @@ export function interleaveMessageBlocks(events, content, rows) {
|
|
|
17
19
|
return null;
|
|
18
20
|
// The reconstruction is only trustworthy if the text events are demonstrably the source `content`
|
|
19
21
|
// was built from. Anything else and the offsets below are fiction.
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
concatenated += ev.text;
|
|
24
|
-
}
|
|
25
|
-
if (concatenated !== content)
|
|
22
|
+
// Both producers' shapes count: today's (a paragraph break between steps, see
|
|
23
|
+
// `assistantContentFromEvents`) and the old plain concatenation older saved rows carry.
|
|
24
|
+
if (content !== assistantContentFromEvents(events) && content !== legacyAssistantContentFromEvents(events))
|
|
26
25
|
return null;
|
|
27
26
|
const rowById = new Map(rows.map((row) => [row.id, row]));
|
|
28
27
|
const blocks = [];
|
|
29
28
|
const emitted = new Set();
|
|
30
|
-
const
|
|
29
|
+
const emittedExtSlots = new Set();
|
|
31
30
|
let buffer = '';
|
|
32
31
|
const flushText = () => {
|
|
33
32
|
if (buffer.length === 0)
|
|
@@ -41,13 +40,15 @@ export function interleaveMessageBlocks(events, content, rows) {
|
|
|
41
40
|
continue;
|
|
42
41
|
}
|
|
43
42
|
if (ev.kind === 'ext') {
|
|
44
|
-
// One block per
|
|
45
|
-
//
|
|
46
|
-
|
|
43
|
+
// One block per SLOT, at its first occurrence — later events in the same slot fold into it
|
|
44
|
+
// (`useExtEventGroups`'s job in `MessageRow.tsx`), not a second block. A slot is the `name`
|
|
45
|
+
// unless its renderer keys events into separate surfaces (see `ExtEventSlotKey`).
|
|
46
|
+
const slot = slotOf(ev);
|
|
47
|
+
if (emittedExtSlots.has(slot))
|
|
47
48
|
continue;
|
|
48
|
-
|
|
49
|
+
emittedExtSlots.add(slot);
|
|
49
50
|
flushText();
|
|
50
|
-
blocks.push({ kind: 'ext', name: ev.name, key: `ext-${
|
|
51
|
+
blocks.push({ kind: 'ext', name: ev.name, slot, key: `ext-${slot}` });
|
|
51
52
|
continue;
|
|
52
53
|
}
|
|
53
54
|
if (ev.kind !== 'tool_use')
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jini-ai/chat",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.11",
|
|
4
4
|
"description": "Jini's chat/artifact frontend, consolidated into one package with two subpaths: framework-free chat vocabulary and pure parsers in `/core`, headless hooks + presentational components + slots in `/react`. Import only the layer you need.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -63,10 +63,10 @@
|
|
|
63
63
|
"dependencies": {
|
|
64
64
|
"@mcp-ui/client": "7.1.1",
|
|
65
65
|
"@mcp-ui/server": "6.1.0",
|
|
66
|
-
"@jini-ai/protocol": "0.3.0",
|
|
67
66
|
"@jini-ai/agentic": "0.3.7",
|
|
68
|
-
"@jini-ai/
|
|
69
|
-
"@jini-ai/
|
|
67
|
+
"@jini-ai/platform": "0.3.0",
|
|
68
|
+
"@jini-ai/protocol": "0.3.1",
|
|
69
|
+
"@jini-ai/ui": "0.3.14"
|
|
70
70
|
},
|
|
71
71
|
"peerDependencies": {
|
|
72
72
|
"react": "^18.3.0 || ^19.0.0",
|