@flamingo-stack/openframe-frontend-core 0.0.609 → 0.0.610-2115.5924.1
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/chat-protocol/card-marker.d.ts +31 -0
- package/dist/chat-protocol/card-marker.d.ts.map +1 -0
- package/dist/chat-protocol/events.d.ts +21 -2
- package/dist/chat-protocol/events.d.ts.map +1 -1
- package/dist/chat-protocol/index.cjs +211 -9
- package/dist/chat-protocol/index.cjs.map +1 -1
- package/dist/chat-protocol/index.js +211 -9
- package/dist/chat-protocol/index.js.map +1 -1
- package/dist/chat-protocol/nats-decoder.d.ts.map +1 -1
- package/dist/chat-protocol/source-metadata.d.ts +56 -0
- package/dist/chat-protocol/source-metadata.d.ts.map +1 -0
- package/dist/{chunk-LA2W5L6K.js → chunk-25YIHMZ6.js} +2 -2
- package/dist/{chunk-6MLRFM3T.js → chunk-2QBXG74C.js} +5 -5
- package/dist/{chunk-3N4FXBVJ.cjs → chunk-2YMDDD5V.cjs} +3 -3
- package/dist/{chunk-3N4FXBVJ.cjs.map → chunk-2YMDDD5V.cjs.map} +1 -1
- package/dist/{chunk-JOCVQZGT.js → chunk-37CAZTLP.js} +5 -5
- package/dist/{chunk-D3DTC7SZ.cjs → chunk-C4KQ2XPK.cjs} +15 -15
- package/dist/{chunk-D3DTC7SZ.cjs.map → chunk-C4KQ2XPK.cjs.map} +1 -1
- package/dist/{chunk-CZTOSG7Q.cjs → chunk-EANAFFAD.cjs} +22 -22
- package/dist/{chunk-CZTOSG7Q.cjs.map → chunk-EANAFFAD.cjs.map} +1 -1
- package/dist/{chunk-BSMPCPOZ.js → chunk-F2C2U7CP.js} +590 -299
- package/dist/chunk-F2C2U7CP.js.map +1 -0
- package/dist/{chunk-O2M4T34Q.cjs → chunk-FASOANK7.cjs} +4 -4
- package/dist/{chunk-O2M4T34Q.cjs.map → chunk-FASOANK7.cjs.map} +1 -1
- package/dist/{chunk-JKM5FH63.js → chunk-FS3CTGIR.js} +3 -3
- package/dist/{chunk-45XXK2VU.cjs → chunk-GFAHCXIL.cjs} +10 -10
- package/dist/{chunk-45XXK2VU.cjs.map → chunk-GFAHCXIL.cjs.map} +1 -1
- package/dist/{chunk-SEW25Y2W.cjs → chunk-GNLV326I.cjs} +10 -10
- package/dist/{chunk-SEW25Y2W.cjs.map → chunk-GNLV326I.cjs.map} +1 -1
- package/dist/{chunk-DKNXAJMP.cjs → chunk-HKJ3WKGW.cjs} +159 -159
- package/dist/{chunk-DKNXAJMP.cjs.map → chunk-HKJ3WKGW.cjs.map} +1 -1
- package/dist/{chunk-HGVW7OHI.js → chunk-HQSCJYCF.js} +2 -2
- package/dist/{chunk-QX4ANESW.js → chunk-HZS4TV34.js} +6 -6
- package/dist/{chunk-B3UXNGVM.js → chunk-IBMHEOBV.js} +3 -3
- package/dist/{chunk-BUXGWBTF.js → chunk-MGXSJI23.js} +2 -2
- package/dist/{chunk-B7LYKBCD.js → chunk-O6PO5BHE.js} +5 -5
- package/dist/{chunk-C7CTEUU7.js → chunk-OIKZDXNW.js} +2 -2
- package/dist/{chunk-TJ3GFULR.js → chunk-OJZW3GE2.js} +3 -3
- package/dist/{chunk-L2JWC5VS.cjs → chunk-OVVKVIMH.cjs} +43 -43
- package/dist/{chunk-L2JWC5VS.cjs.map → chunk-OVVKVIMH.cjs.map} +1 -1
- package/dist/{chunk-VCYRJY7J.js → chunk-Q2CNCBMK.js} +4 -4
- package/dist/{chunk-NJUSDREV.cjs → chunk-Q3APHZK5.cjs} +22 -22
- package/dist/{chunk-NJUSDREV.cjs.map → chunk-Q3APHZK5.cjs.map} +1 -1
- package/dist/{chunk-TCEALWE3.cjs → chunk-QE2Z6WME.cjs} +33 -33
- package/dist/{chunk-TCEALWE3.cjs.map → chunk-QE2Z6WME.cjs.map} +1 -1
- package/dist/{chunk-OTYV6SDN.js → chunk-R2UDEMKK.js} +3 -3
- package/dist/{chunk-JR7I2AGL.js → chunk-ROOIHDLS.js} +3 -3
- package/dist/{chunk-3XNMDLGB.cjs → chunk-THCB7NHV.cjs} +9 -9
- package/dist/{chunk-3XNMDLGB.cjs.map → chunk-THCB7NHV.cjs.map} +1 -1
- package/dist/{chunk-GMOBT5NP.cjs → chunk-THCSSPXU.cjs} +70 -70
- package/dist/{chunk-GMOBT5NP.cjs.map → chunk-THCSSPXU.cjs.map} +1 -1
- package/dist/{chunk-FYG7QNAO.cjs → chunk-UFFVMZDL.cjs} +5 -5
- package/dist/{chunk-FYG7QNAO.cjs.map → chunk-UFFVMZDL.cjs.map} +1 -1
- package/dist/{chunk-MVBRMQGU.js → chunk-V6TINNLD.js} +2 -2
- package/dist/{chunk-ZRLFBLME.cjs → chunk-WJQOYSR3.cjs} +3 -3
- package/dist/{chunk-ZRLFBLME.cjs.map → chunk-WJQOYSR3.cjs.map} +1 -1
- package/dist/{chunk-XNDTYTVT.cjs → chunk-YXTAV2E3.cjs} +974 -683
- package/dist/chunk-YXTAV2E3.cjs.map +1 -0
- package/dist/{chunk-RZM6FPOT.cjs → chunk-ZDLCWNM6.cjs} +25 -25
- package/dist/{chunk-RZM6FPOT.cjs.map → chunk-ZDLCWNM6.cjs.map} +1 -1
- package/dist/components/case-studies/index.cjs +9 -9
- package/dist/components/case-studies/index.js +3 -3
- package/dist/components/chat/chat-message-enhanced.d.ts.map +1 -1
- package/dist/components/chat/chat-message-list.d.ts.map +1 -1
- package/dist/components/chat/embeddable-chat.d.ts.map +1 -1
- package/dist/components/chat/hooks/use-sse-chat-adapter.d.ts +5 -28
- package/dist/components/chat/hooks/use-sse-chat-adapter.d.ts.map +1 -1
- package/dist/components/chat/index.cjs +2 -2
- package/dist/components/chat/index.js +1 -1
- package/dist/components/chat/remark-card-links.d.ts +5 -4
- package/dist/components/chat/remark-card-links.d.ts.map +1 -1
- package/dist/components/chat/stream/chat-stream-reducer.d.ts.map +1 -1
- package/dist/components/chat/tool-execution-display.d.ts.map +1 -1
- package/dist/components/chat/types/component.types.d.ts +27 -0
- package/dist/components/chat/types/component.types.d.ts.map +1 -1
- package/dist/components/chat/types/message.types.d.ts +81 -1
- package/dist/components/chat/types/message.types.d.ts.map +1 -1
- package/dist/components/chat/types/unified-chat-state.types.d.ts +12 -3
- package/dist/components/chat/types/unified-chat-state.types.d.ts.map +1 -1
- package/dist/components/chat/utils/cited-sources.d.ts +24 -0
- package/dist/components/chat/utils/cited-sources.d.ts.map +1 -0
- package/dist/components/chat/utils/host-message.d.ts +41 -0
- package/dist/components/chat/utils/host-message.d.ts.map +1 -0
- package/dist/components/chat/utils/process-historical-messages.d.ts.map +1 -1
- package/dist/components/contact/index.cjs +4 -4
- package/dist/components/contact/index.js +3 -3
- package/dist/components/docs/index.cjs +7 -7
- package/dist/components/docs/index.js +6 -6
- package/dist/components/embeds/index.cjs +4 -4
- package/dist/components/embeds/index.js +3 -3
- package/dist/components/faq/index.cjs +4 -4
- package/dist/components/faq/index.js +3 -3
- package/dist/components/features/index.cjs +3 -3
- package/dist/components/features/index.js +2 -2
- package/dist/components/help-center-pages/index.cjs +23 -23
- package/dist/components/help-center-pages/index.js +14 -14
- package/dist/components/index.cjs +38 -38
- package/dist/components/index.js +13 -13
- package/dist/components/meeting-scheduler/index.cjs +24 -24
- package/dist/components/meeting-scheduler/index.js +2 -2
- package/dist/components/navigation/index.cjs +6 -6
- package/dist/components/navigation/index.js +5 -5
- package/dist/components/onboarding-guides/index.cjs +6 -6
- package/dist/components/onboarding-guides/index.js +5 -5
- package/dist/components/tickets/index.cjs +7 -7
- package/dist/components/tickets/index.js +6 -6
- package/dist/components/ui/index.cjs +3 -3
- package/dist/components/ui/index.js +2 -2
- package/dist/index.cjs +7 -7
- package/dist/index.js +6 -6
- package/dist/utils/index.cjs.map +1 -1
- package/dist/utils/index.js.map +1 -1
- package/package.json +1 -1
- package/src/chat-protocol/__tests__/card-marker.test.ts +63 -0
- package/src/chat-protocol/__tests__/source-metadata.test.ts +243 -0
- package/src/chat-protocol/card-marker.ts +40 -0
- package/src/chat-protocol/events.ts +22 -1
- package/src/chat-protocol/nats-decoder.ts +12 -0
- package/src/chat-protocol/source-metadata.ts +336 -0
- package/src/components/chat/__tests__/tool-execution-display.test.tsx +70 -0
- package/src/components/chat/chat-message-enhanced.tsx +37 -12
- package/src/components/chat/chat-message-list.tsx +14 -1
- package/src/components/chat/embeddable-chat.tsx +47 -87
- package/src/components/chat/hooks/use-sse-chat-adapter.ts +5 -28
- package/src/components/chat/remark-card-links.ts +14 -12
- package/src/components/chat/stream/chat-stream-reducer.ts +48 -3
- package/src/components/chat/tool-execution-display.tsx +18 -4
- package/src/components/chat/types/component.types.ts +27 -0
- package/src/components/chat/types/message.types.ts +83 -0
- package/src/components/chat/types/unified-chat-state.types.ts +12 -3
- package/src/components/chat/utils/__tests__/cited-sources.test.ts +80 -0
- package/src/components/chat/utils/__tests__/host-message.test.ts +92 -0
- package/src/components/chat/utils/__tests__/process-historical-messages-sources.test.ts +138 -0
- package/src/components/chat/utils/cited-sources.ts +61 -0
- package/src/components/chat/utils/host-message.ts +87 -0
- package/src/components/chat/utils/process-historical-messages.ts +25 -0
- package/dist/chunk-BSMPCPOZ.js.map +0 -1
- package/dist/chunk-XNDTYTVT.cjs.map +0 -1
- /package/dist/{chunk-LA2W5L6K.js.map → chunk-25YIHMZ6.js.map} +0 -0
- /package/dist/{chunk-6MLRFM3T.js.map → chunk-2QBXG74C.js.map} +0 -0
- /package/dist/{chunk-JOCVQZGT.js.map → chunk-37CAZTLP.js.map} +0 -0
- /package/dist/{chunk-JKM5FH63.js.map → chunk-FS3CTGIR.js.map} +0 -0
- /package/dist/{chunk-HGVW7OHI.js.map → chunk-HQSCJYCF.js.map} +0 -0
- /package/dist/{chunk-QX4ANESW.js.map → chunk-HZS4TV34.js.map} +0 -0
- /package/dist/{chunk-B3UXNGVM.js.map → chunk-IBMHEOBV.js.map} +0 -0
- /package/dist/{chunk-BUXGWBTF.js.map → chunk-MGXSJI23.js.map} +0 -0
- /package/dist/{chunk-B7LYKBCD.js.map → chunk-O6PO5BHE.js.map} +0 -0
- /package/dist/{chunk-C7CTEUU7.js.map → chunk-OIKZDXNW.js.map} +0 -0
- /package/dist/{chunk-TJ3GFULR.js.map → chunk-OJZW3GE2.js.map} +0 -0
- /package/dist/{chunk-VCYRJY7J.js.map → chunk-Q2CNCBMK.js.map} +0 -0
- /package/dist/{chunk-OTYV6SDN.js.map → chunk-R2UDEMKK.js.map} +0 -0
- /package/dist/{chunk-JR7I2AGL.js.map → chunk-ROOIHDLS.js.map} +0 -0
- /package/dist/{chunk-MVBRMQGU.js.map → chunk-V6TINNLD.js.map} +0 -0
|
@@ -97,7 +97,10 @@ import type { ChatDialogCapabilities, UnifiedChatState } from './types/unified-c
|
|
|
97
97
|
import { formatChatAttachmentMarkdownForBubble } from './utils/chat-attachment-markdown';
|
|
98
98
|
import { resolveHrefForRuntime } from './utils/chat-nav-resolution';
|
|
99
99
|
import { chatChipClass } from './utils/chip-styles';
|
|
100
|
+
import { FALLBACK_TOP_RETRIEVED, splitCitedSources } from './utils/cited-sources';
|
|
100
101
|
import { executeNavigation } from './utils/execute-navigation';
|
|
102
|
+
import { flattenAssistantContent } from './utils/flatten-assistant-content';
|
|
103
|
+
import { mapHostMessage, pruneTimestampCache } from './utils/host-message';
|
|
101
104
|
import { resolveIcon } from './utils/icon-library';
|
|
102
105
|
import { computeIsNewTab, newTabAnchorAttrs } from './utils/nav-anchor-props';
|
|
103
106
|
import { formatSingularLookupInvocation } from './utils/slash-dispatch-utils';
|
|
@@ -435,12 +438,6 @@ const mentionTokenOf = (key: string, markerByType: Map<string, string>): string
|
|
|
435
438
|
return `${markerByType.get(type) ?? type.toLowerCase()}:${id}`;
|
|
436
439
|
};
|
|
437
440
|
|
|
438
|
-
/**
|
|
439
|
-
* Fallback fan-out when the model didn't cite any source. Show the top-N
|
|
440
|
-
* retrieved sources instead of zero chips. Mirrors Perplexity's behavior.
|
|
441
|
-
*/
|
|
442
|
-
const FALLBACK_TOP_RETRIEVED = 3;
|
|
443
|
-
|
|
444
441
|
/** Persists the user's rail collapse choice across drawer open/close + reloads. */
|
|
445
442
|
const RAIL_COLLAPSED_STORAGE_KEY = 'mingo-chat-history-collapsed';
|
|
446
443
|
|
|
@@ -1539,56 +1536,12 @@ function EmbeddableChatInner({
|
|
|
1539
1536
|
: undefined;
|
|
1540
1537
|
const guideUserAvatar = activeMode === 'guide' ? identityUser?.avatarUrl?.trim() || undefined : undefined;
|
|
1541
1538
|
|
|
1542
|
-
// Map
|
|
1539
|
+
// Map the host's rows → the lib's Message type. The mapping itself lives in
|
|
1540
|
+
// `mapHostMessage`, which is where its pass-through list is pinned by tests.
|
|
1543
1541
|
const messages: Message[] = useMemo(() => {
|
|
1544
|
-
const
|
|
1545
|
-
const
|
|
1546
|
-
|
|
1547
|
-
const mapped = rawMessages.map(m => {
|
|
1548
|
-
seenIds.add(m.id);
|
|
1549
|
-
let timestamp: Date;
|
|
1550
|
-
if (m.timestamp != null) {
|
|
1551
|
-
timestamp = new Date(m.timestamp);
|
|
1552
|
-
} else {
|
|
1553
|
-
const cached = cache.get(m.id);
|
|
1554
|
-
timestamp = cached ?? new Date();
|
|
1555
|
-
if (!cached) cache.set(m.id, timestamp);
|
|
1556
|
-
}
|
|
1557
|
-
|
|
1558
|
-
return {
|
|
1559
|
-
id: m.id,
|
|
1560
|
-
role: m.role,
|
|
1561
|
-
// Host-supplied per-message name/avatar win (e.g. the signed-in user's
|
|
1562
|
-
// full name + photo on a `user` bubble); fall back to the role default
|
|
1563
|
-
// when the host doesn't provide them.
|
|
1564
|
-
name: m.name ?? (m.role === 'assistant' ? 'Mingo' : (guideUserName ?? 'You')),
|
|
1565
|
-
avatar: m.avatar ?? (m.role === 'user' ? (guideUserAvatar ?? null) : null),
|
|
1566
|
-
// Forward the host's authorType so user bubbles get the same accent
|
|
1567
|
-
// name color as the standalone /mingo page (user → 'admin').
|
|
1568
|
-
...(m.authorType ? { authorType: m.authorType } : {}),
|
|
1569
|
-
content: m.segments && m.segments.length > 0 ? m.segments : m.content,
|
|
1570
|
-
timestamp,
|
|
1571
|
-
assistantType: m.role === 'assistant' ? ('mingo' as const) : undefined,
|
|
1572
|
-
// `hidden` is load-bearing, NOT cosmetic: it carries synthetic rows
|
|
1573
|
-
// (e.g. an auto-continuation directive) that the LLM must see but the
|
|
1574
|
-
// reader must not. Dropping it here made the raw directive text render
|
|
1575
|
-
// as an ordinary bubble. This field-by-field rebuild has to forward it
|
|
1576
|
-
// explicitly — see `Message.hidden` and `chat-message-list`'s skip.
|
|
1577
|
-
...(m.hidden ? { hidden: true } : {}),
|
|
1578
|
-
...(m.scrollAnchor ? { scrollAnchor: m.scrollAnchor } : {}),
|
|
1579
|
-
// Forward attached context items so the user bubble renders its chips.
|
|
1580
|
-
...(m.contextItems && m.contextItems.length > 0 ? { contextItems: m.contextItems } : {}),
|
|
1581
|
-
};
|
|
1582
|
-
});
|
|
1583
|
-
|
|
1584
|
-
// Drop cached fallbacks for messages no longer present so the map can't
|
|
1585
|
-
// grow unbounded across a long-lived session.
|
|
1586
|
-
if (cache.size > seenIds.size) {
|
|
1587
|
-
for (const id of cache.keys()) {
|
|
1588
|
-
if (!seenIds.has(id)) cache.delete(id);
|
|
1589
|
-
}
|
|
1590
|
-
}
|
|
1591
|
-
|
|
1542
|
+
const options = { userName: guideUserName, userAvatar: guideUserAvatar, timestampCache };
|
|
1543
|
+
const mapped = rawMessages.map(m => mapHostMessage(m, options));
|
|
1544
|
+
pruneTimestampCache(timestampCache, new Set(rawMessages.map(m => m.id)));
|
|
1592
1545
|
return mapped;
|
|
1593
1546
|
}, [rawMessages, guideUserName, guideUserAvatar, timestampCache]);
|
|
1594
1547
|
|
|
@@ -1836,24 +1789,44 @@ function EmbeddableChatInner({
|
|
|
1836
1789
|
return out;
|
|
1837
1790
|
}, [commandsById, enabledSet]);
|
|
1838
1791
|
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1792
|
+
/**
|
|
1793
|
+
* Source chips, under the answer that cited them.
|
|
1794
|
+
*
|
|
1795
|
+
* Per message, not once per thread. The strip names where THAT answer came
|
|
1796
|
+
* from, and a conversation holds several answers — pinning one strip to the
|
|
1797
|
+
* bottom of the thread attributes the newest answer's sources to whichever
|
|
1798
|
+
* answer the reader is looking at. Both transports produce them now, so this
|
|
1799
|
+
* is no longer a Guide-mode-only affordance either.
|
|
1800
|
+
*/
|
|
1801
|
+
const renderMessageSources = useCallback(
|
|
1802
|
+
(message: Message, index: number) => {
|
|
1803
|
+
if (message.role !== 'assistant') return null;
|
|
1804
|
+
// Suppressed only on the answer still being written: the citation markers
|
|
1805
|
+
// the order is derived from arrive WITH the text, so a strip rendered
|
|
1806
|
+
// mid-turn reshuffles under the reader as more sentences land.
|
|
1807
|
+
//
|
|
1808
|
+
// Scoped to the trailing row on purpose. `chatLoading` is a property of
|
|
1809
|
+
// the THREAD, so testing it alone pulls the strips off every earlier
|
|
1810
|
+
// answer too — a reader scrolled up watches finished citations blink out
|
|
1811
|
+
// for the duration of an unrelated turn.
|
|
1812
|
+
if (chatLoading && index === messages.length - 1) return null;
|
|
1813
|
+
const { cited, uncited } = splitCitedSources(message.sources, flattenAssistantContent(message.content));
|
|
1814
|
+
if (cited.length === 0 && uncited.length === 0) return null;
|
|
1815
|
+
return (
|
|
1816
|
+
<div className="pb-2">
|
|
1817
|
+
<SourceChips
|
|
1818
|
+
cited={cited}
|
|
1819
|
+
uncited={uncited}
|
|
1820
|
+
baseRoute={resolvedBaseRoute}
|
|
1821
|
+
chipBasePlatform={chipBasePlatform}
|
|
1822
|
+
onClose={handleNavigationClose}
|
|
1823
|
+
onDiscuss={discussRef}
|
|
1824
|
+
/>
|
|
1825
|
+
</div>
|
|
1826
|
+
);
|
|
1827
|
+
},
|
|
1828
|
+
[chatLoading, messages.length, resolvedBaseRoute, chipBasePlatform, handleNavigationClose, discussRef],
|
|
1829
|
+
);
|
|
1857
1830
|
|
|
1858
1831
|
// Host node for in-panel Radix portals (see the body wrapper below).
|
|
1859
1832
|
const [portalHost, setPortalHost] = useState<HTMLDivElement | null>(null);
|
|
@@ -2434,6 +2407,7 @@ function EmbeddableChatInner({
|
|
|
2434
2407
|
resolveContextIcon={resolveContextIcon}
|
|
2435
2408
|
renderContextItem={renderContextItem}
|
|
2436
2409
|
renderMention={renderMention}
|
|
2410
|
+
renderAfterMessage={renderMessageSources}
|
|
2437
2411
|
// Gated on `chatLoading` for the same reason the composer
|
|
2438
2412
|
// is: no second send while a turn is in flight. Passive
|
|
2439
2413
|
// demo hosts (previewMode) stay read-only.
|
|
@@ -2471,20 +2445,6 @@ function EmbeddableChatInner({
|
|
|
2471
2445
|
onLoadMore={loadMoreMessages}
|
|
2472
2446
|
/>
|
|
2473
2447
|
)}
|
|
2474
|
-
{lastSources &&
|
|
2475
|
-
(lastSources.cited.length > 0 || lastSources.uncited.length > 0) &&
|
|
2476
|
-
!chatLoading && (
|
|
2477
|
-
<div className="flex-shrink-0 pb-2">
|
|
2478
|
-
<SourceChips
|
|
2479
|
-
cited={lastSources.cited}
|
|
2480
|
-
uncited={lastSources.uncited}
|
|
2481
|
-
baseRoute={resolvedBaseRoute}
|
|
2482
|
-
chipBasePlatform={chipBasePlatform}
|
|
2483
|
-
onClose={handleNavigationClose}
|
|
2484
|
-
onDiscuss={discussRef}
|
|
2485
|
-
/>
|
|
2486
|
-
</div>
|
|
2487
|
-
)}
|
|
2488
2448
|
</div>
|
|
2489
2449
|
) : activeMode === 'mingo' ? (
|
|
2490
2450
|
/* Figma node 7532:222444 — default (Mingo-mode) empty state:
|
|
@@ -62,7 +62,7 @@ import { createChatDialogStore } from '../stream/chat-dialog-store';
|
|
|
62
62
|
import type { ChatDialogStore } from '../stream/chat-dialog-store';
|
|
63
63
|
import type { ChatStreamReducerOptions } from '../stream/chat-stream-reducer';
|
|
64
64
|
import { useChatStreamReducer } from '../stream/use-chat-stream-reducer';
|
|
65
|
-
import type { Message, MessageSegment } from '../types/message.types';
|
|
65
|
+
import type { ChatSource, Message, MessageSegment } from '../types/message.types';
|
|
66
66
|
import type {
|
|
67
67
|
ChatDialogCapabilities,
|
|
68
68
|
FetchDialogsParams,
|
|
@@ -121,33 +121,10 @@ const noopBumpMetaTick = (): void => {};
|
|
|
121
121
|
* hub-side platform-utils, not in lib). */
|
|
122
122
|
export type DocSource = string;
|
|
123
123
|
|
|
124
|
-
export
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
documentType: string;
|
|
129
|
-
externalUrl?: string;
|
|
130
|
-
/** Platform that owns the destination at `externalUrl`. */
|
|
131
|
-
targetPlatform?: string | null;
|
|
132
|
-
/** Primary-key value for single-row chips. */
|
|
133
|
-
id?: string;
|
|
134
|
-
/** Per-row items for grouped chips. */
|
|
135
|
-
items?: Array<{
|
|
136
|
-
id: string;
|
|
137
|
-
documentType: string;
|
|
138
|
-
name: string;
|
|
139
|
-
externalUrl?: string;
|
|
140
|
-
targetPlatform?: string | null;
|
|
141
|
-
/** In-app doc-tree path for markdown / data-room-doc rows so the
|
|
142
|
-
* grouped chip's anchor can trigger an in-page doc-tree swap via
|
|
143
|
-
* `handleChatNavClick` (parity with single-row chips + cards). */
|
|
144
|
-
path?: string | null;
|
|
145
|
-
}>;
|
|
146
|
-
/** RagTableConfig.id for this source. */
|
|
147
|
-
sourceRepo?: string;
|
|
148
|
-
/** Optional display label override returned by the chat API. */
|
|
149
|
-
label?: string;
|
|
150
|
-
}
|
|
124
|
+
/** Re-export: `ChatSource` moved to `message.types` when the NATS transport
|
|
125
|
+
* started producing it too. Kept so existing `use-sse-chat-adapter` imports
|
|
126
|
+
* keep resolving. */
|
|
127
|
+
export type { ChatSource };
|
|
151
128
|
|
|
152
129
|
export interface DocChatMessage {
|
|
153
130
|
id: string;
|
|
@@ -15,24 +15,26 @@
|
|
|
15
15
|
* Per v6.1 §B.2.6: "implement as a `react-markdown` `components.text` override
|
|
16
16
|
* OR a remark plugin. NOT a regex-on-raw-text pre-pass (which loses formatting)."
|
|
17
17
|
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
18
|
+
* Marker grammar: `chat-protocol/card-marker.ts`, shared with the pre-scan in
|
|
19
|
+
* `chat-message-enhanced.tsx` and with the metadata decoder. It must be the
|
|
20
|
+
* same grammar in all three: this plugin is what turns a marker into a card, so
|
|
21
|
+
* a marker the pre-scan accepts and this one rejects is split out of the text
|
|
22
|
+
* and then never rendered — the reader is left with the literal `[card://…]`.
|
|
22
23
|
*/
|
|
23
24
|
|
|
24
25
|
import type { Root, Text, Link } from 'mdast';
|
|
25
26
|
import type { Plugin } from 'unified';
|
|
26
27
|
import { visit, SKIP } from 'unist-util-visit';
|
|
27
28
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
//
|
|
31
|
-
//
|
|
32
|
-
//
|
|
33
|
-
// syntax anywhere else (regular links
|
|
34
|
-
// so
|
|
35
|
-
|
|
29
|
+
import { createCardMarkerScanner } from '../../chat-protocol/card-marker';
|
|
30
|
+
|
|
31
|
+
// The closer is `]` per spec, but `)` is tolerated too — the LLM occasionally
|
|
32
|
+
// drifts to `)` after long dashed UUID ids (bracket-balancing noise on opaque
|
|
33
|
+
// tokens; reproduced in production with podcast UUIDs). `[card://type:id)` is
|
|
34
|
+
// not valid markdown syntax anywhere else (regular links are `[text](url)`, not
|
|
35
|
+
// `[text)`), so the wider closer has no false positives. Both that and the id
|
|
36
|
+
// charset now live in the shared grammar.
|
|
37
|
+
const CARD_REGEX = createCardMarkerScanner();
|
|
36
38
|
|
|
37
39
|
export const remarkCardLinks: Plugin<[], Root> = () => {
|
|
38
40
|
return (tree: Root) => {
|
|
@@ -60,6 +60,7 @@ import {
|
|
|
60
60
|
type ParticipantEvent,
|
|
61
61
|
type UsageEvent,
|
|
62
62
|
} from '../../../chat-protocol/events';
|
|
63
|
+
import { mergeSourceMetadata, type SourceMetadata } from '../../../chat-protocol/source-metadata';
|
|
63
64
|
import type {
|
|
64
65
|
ApprovalBatchSegment,
|
|
65
66
|
ApprovalRequestSegment,
|
|
@@ -755,22 +756,56 @@ export function createChatStreamReducer(options: ChatStreamReducerOptions = {}):
|
|
|
755
756
|
return [...next.slice(0, -1), { ...last, streamSeq: seq }];
|
|
756
757
|
}
|
|
757
758
|
|
|
759
|
+
/**
|
|
760
|
+
* Source metadata accumulated for the CURRENT turn.
|
|
761
|
+
*
|
|
762
|
+
* The chunk is published when a remote tool returns, so it lands inside the
|
|
763
|
+
* turn but usually BEFORE the answer text the reader will see it under —
|
|
764
|
+
* sometimes before the assistant bubble exists at all. Holding it here and
|
|
765
|
+
* stamping it on every trailing-assistant write is what makes the arrival
|
|
766
|
+
* order stop mattering.
|
|
767
|
+
*
|
|
768
|
+
* Reset at `turn-start`, so metadata can never leak onto the next answer.
|
|
769
|
+
* Losing a chunk that somehow arrived outside a turn is the better failure of
|
|
770
|
+
* the two: a stale citation strip under an unrelated answer is a wrong
|
|
771
|
+
* statement about where that answer came from.
|
|
772
|
+
*/
|
|
773
|
+
let turnSourceMetadata: SourceMetadata | null = null;
|
|
774
|
+
|
|
775
|
+
/** Stamp the turn's metadata onto the trailing assistant bubble. A no-op
|
|
776
|
+
* when there is none yet — the next write through here picks it up. */
|
|
777
|
+
function stampTrailingAssistantSourceMetadata(next: UnifiedChatMessage[]): UnifiedChatMessage[] {
|
|
778
|
+
const metadata = turnSourceMetadata;
|
|
779
|
+
if (!metadata) return next;
|
|
780
|
+
const last = next[next.length - 1];
|
|
781
|
+
if (!last || last.role !== 'assistant') return next;
|
|
782
|
+
if (last.sources === metadata.sources && last.refs === metadata.refs) return next;
|
|
783
|
+
return [...next.slice(0, -1), { ...last, ...metadata }];
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
/** The two stamps every trailing-assistant write needs, in one place — a
|
|
787
|
+
* write that skips either loses the seq the merge decides with, or the
|
|
788
|
+
* citations the answer was built from. */
|
|
789
|
+
function commitTrailingAssistant(next: UnifiedChatMessage[], seq: number | undefined): UnifiedChatMessage[] {
|
|
790
|
+
return stampTrailingAssistantSourceMetadata(stampTrailingAssistantSeq(next, seq));
|
|
791
|
+
}
|
|
792
|
+
|
|
758
793
|
function applySegmentsToState(segments: MessageSegment[], meta?: SegmentsUpdateMetadata): void {
|
|
759
794
|
const seq = meta?.streamSeq;
|
|
760
795
|
// Standalone compaction updates carry the accumulator's cumulative
|
|
761
796
|
// array — apply only the compaction segment (upsert) or interleaved
|
|
762
797
|
// continuation text would duplicate.
|
|
763
798
|
if (meta?.append && meta.isCompacting) {
|
|
764
|
-
setMessagesInternal(
|
|
799
|
+
setMessagesInternal(commitTrailingAssistant(upsertTrailingCompaction(messages, segments), seq));
|
|
765
800
|
return;
|
|
766
801
|
}
|
|
767
802
|
// Post-MESSAGE_END continuation fragments append into the existing
|
|
768
803
|
// bubble; replacing would wipe the completed reply.
|
|
769
804
|
if (meta?.append) {
|
|
770
|
-
setMessagesInternal(
|
|
805
|
+
setMessagesInternal(commitTrailingAssistant(appendToTrailingAssistant(messages, segments), seq));
|
|
771
806
|
return;
|
|
772
807
|
}
|
|
773
|
-
setMessagesInternal(
|
|
808
|
+
setMessagesInternal(commitTrailingAssistant(updateTrailingAssistant(messages, segments), seq));
|
|
774
809
|
}
|
|
775
810
|
|
|
776
811
|
function applyStreamStartToState(): void {
|
|
@@ -969,6 +1004,7 @@ export function createChatStreamReducer(options: ChatStreamReducerOptions = {}):
|
|
|
969
1004
|
isInStream = true;
|
|
970
1005
|
hasEverStreamed = true;
|
|
971
1006
|
turnStartedAt = Date.now();
|
|
1007
|
+
turnSourceMetadata = null;
|
|
972
1008
|
emit('onStreamStart');
|
|
973
1009
|
applyStreamStartToState();
|
|
974
1010
|
accumulator.resetSegments();
|
|
@@ -984,6 +1020,15 @@ export function createChatStreamReducer(options: ChatStreamReducerOptions = {}):
|
|
|
984
1020
|
break;
|
|
985
1021
|
}
|
|
986
1022
|
|
|
1023
|
+
// Per-answer source metadata. Applied to the trailing assistant bubble
|
|
1024
|
+
// immediately when there is one, and held for the next write when the
|
|
1025
|
+
// chunk beat the answer text to the reducer.
|
|
1026
|
+
case 'sources': {
|
|
1027
|
+
turnSourceMetadata = mergeSourceMetadata(turnSourceMetadata, event);
|
|
1028
|
+
setMessagesInternal(stampTrailingAssistantSourceMetadata(messages));
|
|
1029
|
+
break;
|
|
1030
|
+
}
|
|
1031
|
+
|
|
987
1032
|
case 'metadata': {
|
|
988
1033
|
// Legacy `parseChunkToAction` action shape, reconstructed for the
|
|
989
1034
|
// callback contract.
|
|
@@ -53,6 +53,19 @@ const ToolExecutionDisplay = forwardRef<HTMLDivElement, ToolExecutionDisplayProp
|
|
|
53
53
|
}, [message.parameters, variant]);
|
|
54
54
|
|
|
55
55
|
const hasResult = isExecuted && typeof message.result === 'string' && message.result.length > 0;
|
|
56
|
+
|
|
57
|
+
// A remote (MCP) read-only tool deliberately publishes NO parameters and NO
|
|
58
|
+
// result — the backend hides both, and sends a human title instead. There is
|
|
59
|
+
// therefore nothing behind the chevron, and offering one is a promise the
|
|
60
|
+
// row cannot keep: the reader expands it and gets an empty box. Render the
|
|
61
|
+
// title as a status line instead, the same static shape the client view uses.
|
|
62
|
+
//
|
|
63
|
+
// Keyed on the absent `integratedToolType`, which is what marks a tool as
|
|
64
|
+
// remote rather than one of ours — and guarded on there being a title to
|
|
65
|
+
// show, so a title-less row keeps the old behaviour rather than collapsing
|
|
66
|
+
// to a blank line.
|
|
67
|
+
const isConciseRemoteRead = !message.integratedToolType && !!previewText && argEntries.length === 0 && !hasResult;
|
|
68
|
+
const isStaticRow = isClientView || isConciseRemoteRead;
|
|
56
69
|
const hasBody = argEntries.length > 0 || hasResult || isExecuting;
|
|
57
70
|
|
|
58
71
|
const renderStatusIcon = () => {
|
|
@@ -82,7 +95,7 @@ const ToolExecutionDisplay = forwardRef<HTMLDivElement, ToolExecutionDisplayProp
|
|
|
82
95
|
{previewText}
|
|
83
96
|
</div>
|
|
84
97
|
<div className="flex h-5 w-5 shrink-0 items-center justify-center">{renderStatusIcon()}</div>
|
|
85
|
-
{!
|
|
98
|
+
{!isStaticRow && (
|
|
86
99
|
<div className="flex h-5 w-5 shrink-0 items-center justify-center">
|
|
87
100
|
<ExpandChevron expanded={expanded} />
|
|
88
101
|
</div>
|
|
@@ -101,9 +114,10 @@ const ToolExecutionDisplay = forwardRef<HTMLDivElement, ToolExecutionDisplayProp
|
|
|
101
114
|
)}
|
|
102
115
|
{...props}
|
|
103
116
|
>
|
|
104
|
-
{
|
|
105
|
-
//
|
|
106
|
-
//
|
|
117
|
+
{isStaticRow ? (
|
|
118
|
+
// Static, non-expandable row — no chevron, no body. Two cases reach
|
|
119
|
+
// here: the Fae end-user view (command/args/result are admin-only
|
|
120
|
+
// detail) and a remote read-only tool (there IS no detail).
|
|
107
121
|
<div className="flex w-full items-start gap-[var(--spacing-system-xs)] p-[var(--spacing-system-s)] text-left">
|
|
108
122
|
{headerContent}
|
|
109
123
|
</div>
|
|
@@ -195,6 +195,20 @@ export interface ChatMessageEnhancedProps extends Omit<HTMLAttributes<HTMLDivEle
|
|
|
195
195
|
* back to plain text title-only.
|
|
196
196
|
*/
|
|
197
197
|
renderEntityCard?: (reference: ChatRef) => ReactNode;
|
|
198
|
+
/**
|
|
199
|
+
* References this answer's metadata described, used to expand the
|
|
200
|
+
* `[card://type:id]` markers in its body.
|
|
201
|
+
*
|
|
202
|
+
* A marker on the wire carries only a type and an id, so without these a card
|
|
203
|
+
* has to be hydrated by id through a per-entity API — which the host may not
|
|
204
|
+
* have for entities that live on another platform. Supplying the reference
|
|
205
|
+
* here is what lets such a card render with a real title and link instead of
|
|
206
|
+
* falling back to its raw id.
|
|
207
|
+
*
|
|
208
|
+
* Presence is NOT a render list: only markers actually written into the body
|
|
209
|
+
* render, and the metadata routinely describes more than the model cited.
|
|
210
|
+
*/
|
|
211
|
+
refs?: ChatRef[];
|
|
198
212
|
/**
|
|
199
213
|
* Host-provided anchor component for markdown links. When supplied, the
|
|
200
214
|
* `<a>` override in the markdown renderer delegates to this component
|
|
@@ -296,6 +310,19 @@ export interface ChatMessageListProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
296
310
|
/** Host-provided renderer for inline entity cards. Forwarded verbatim
|
|
297
311
|
* to every message's ChatMessageEnhanced. v6.1 §B.2.7. */
|
|
298
312
|
renderEntityCard?: (reference: ChatRef) => ReactNode;
|
|
313
|
+
/**
|
|
314
|
+
* Content owned by ONE message, rendered directly beneath it.
|
|
315
|
+
*
|
|
316
|
+
* For anything whose subject is that specific answer rather than the thread —
|
|
317
|
+
* the source chips a Guide answer cites, today. Rendering such content once at
|
|
318
|
+
* the bottom of the thread instead is a quiet lie in a multi-answer
|
|
319
|
+
* conversation: it attributes the newest answer's sources to whichever answer
|
|
320
|
+
* the reader is actually looking at.
|
|
321
|
+
*
|
|
322
|
+
* Return `null` for messages that own nothing. Hidden and pending-placeholder
|
|
323
|
+
* messages never reach it — they do not render at all.
|
|
324
|
+
*/
|
|
325
|
+
renderAfterMessage?: (message: Message, index: number) => ReactNode;
|
|
299
326
|
/** Host-provided anchor for markdown links. Forwarded verbatim to every
|
|
300
327
|
* message's ChatMessageEnhanced. Owns the unified click rule
|
|
301
328
|
* (same-origin soft nav, cross-origin new tab). */
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* Contains all message structures, segments, and content types
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
+
import type { ChatRef } from '../chat-ref.types';
|
|
6
7
|
import type { AssistantType, AuthorType, ChatApprovalStatus, MessageOwner } from './chat.types';
|
|
7
8
|
|
|
8
9
|
// ========== Message Type Definitions ==========
|
|
@@ -11,6 +12,15 @@ export const MESSAGE_TYPE = {
|
|
|
11
12
|
TEXT: 'TEXT',
|
|
12
13
|
THINKING: 'THINKING',
|
|
13
14
|
ASK: 'ASK',
|
|
15
|
+
/** Per-answer source metadata (documents, videos, entity cards).
|
|
16
|
+
*
|
|
17
|
+
* TWO names for ONE payload, on purpose. `SOURCES` is the contract the
|
|
18
|
+
* backend is moving to; `GUIDE` is the envelope it ships in today, reused
|
|
19
|
+
* from Guide Mode v2 so a released frontend keeps working during the v2→v3
|
|
20
|
+
* rollout. Both decode through the same path, so dropping `GUIDE` later is a
|
|
21
|
+
* deletion here and nothing else. */
|
|
22
|
+
GUIDE: 'GUIDE',
|
|
23
|
+
SOURCES: 'SOURCES',
|
|
14
24
|
EXECUTING_TOOL: 'EXECUTING_TOOL',
|
|
15
25
|
EXECUTED_TOOL: 'EXECUTED_TOOL',
|
|
16
26
|
APPROVAL_REQUEST: 'APPROVAL_REQUEST',
|
|
@@ -391,6 +401,55 @@ export interface ThinkingMessageData extends MessageDataBase {
|
|
|
391
401
|
text?: string;
|
|
392
402
|
}
|
|
393
403
|
|
|
404
|
+
/**
|
|
405
|
+
* A document cited by an assistant answer, rendered as a chip under it.
|
|
406
|
+
*
|
|
407
|
+
* Lives here, beside `Message`, because BOTH transports produce it now: the SSE
|
|
408
|
+
* adapter reads it off the per-turn metadata frame, and the NATS path decodes it
|
|
409
|
+
* out of a `GUIDE`/`SOURCES` chunk. It used to be declared inside
|
|
410
|
+
* `use-sse-chat-adapter`, which made "a Guide answer's citations" structurally a
|
|
411
|
+
* property of one transport — `use-sse-chat-adapter` still re-exports the name
|
|
412
|
+
* so existing imports keep working.
|
|
413
|
+
*/
|
|
414
|
+
export interface ChatSource {
|
|
415
|
+
/** 1-based citation number. `[1]` in the answer text refers to this. */
|
|
416
|
+
index: number;
|
|
417
|
+
name: string;
|
|
418
|
+
path: string;
|
|
419
|
+
documentType: string;
|
|
420
|
+
externalUrl?: string;
|
|
421
|
+
/** Platform that owns the destination at `externalUrl`. */
|
|
422
|
+
targetPlatform?: string | null;
|
|
423
|
+
/** Primary-key value for single-row chips. */
|
|
424
|
+
id?: string;
|
|
425
|
+
/** Per-row items for grouped chips. */
|
|
426
|
+
items?: Array<{
|
|
427
|
+
id: string;
|
|
428
|
+
documentType: string;
|
|
429
|
+
name: string;
|
|
430
|
+
externalUrl?: string;
|
|
431
|
+
targetPlatform?: string | null;
|
|
432
|
+
/** In-app doc-tree path for markdown / data-room-doc rows so the
|
|
433
|
+
* grouped chip's anchor can trigger an in-page doc-tree swap via
|
|
434
|
+
* `handleChatNavClick` (parity with single-row chips + cards). */
|
|
435
|
+
path?: string | null;
|
|
436
|
+
}>;
|
|
437
|
+
/** RagTableConfig.id for this source. */
|
|
438
|
+
sourceRepo?: string;
|
|
439
|
+
/** Optional display label override returned by the chat API. */
|
|
440
|
+
label?: string;
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
/** Persisted source-metadata row. `payload` is the SAME object the live chunk
|
|
444
|
+
* carries, so history and realtime share one decoder (`sourceMetadataEvent`)
|
|
445
|
+
* and cannot drift apart. Left as an open record here rather than typed
|
|
446
|
+
* structurally: it is unvalidated wire data, and the decoder is what turns it
|
|
447
|
+
* into `ChatSource[]` / `ChatRef[]`. */
|
|
448
|
+
export interface SourceMetadataMessageData extends MessageDataBase {
|
|
449
|
+
type: 'GUIDE' | 'SOURCES';
|
|
450
|
+
payload?: unknown;
|
|
451
|
+
}
|
|
452
|
+
|
|
394
453
|
/** Persisted `ASK` row (GraphQL `AskData`). `text` is the intro sentence, which
|
|
395
454
|
* history replays as a text segment ahead of the card — same split the live
|
|
396
455
|
* `ASK` chunk carries. */
|
|
@@ -533,6 +592,7 @@ export type MessageData =
|
|
|
533
592
|
| TextMessageData
|
|
534
593
|
| ThinkingMessageData
|
|
535
594
|
| AskMessageData
|
|
595
|
+
| SourceMetadataMessageData
|
|
536
596
|
| ExecutingToolMessageData
|
|
537
597
|
| ExecutedToolMessageData
|
|
538
598
|
| ApprovalRequestMessageData
|
|
@@ -582,6 +642,12 @@ export interface ProcessedMessage {
|
|
|
582
642
|
* `streamSeq` so the history/realtime merge can do per-role seq coverage.
|
|
583
643
|
* Absent when the source row(s) carried no seq. */
|
|
584
644
|
streamSeq?: number;
|
|
645
|
+
/** Documents this answer cited — see `Message.sources`, the same field.
|
|
646
|
+
* Replayed from the turn's persisted `GUIDE`/`SOURCES` row, so a reloaded
|
|
647
|
+
* answer carries the citations the live one did. */
|
|
648
|
+
sources?: ChatSource[];
|
|
649
|
+
/** Entity references this answer's metadata described — see `Message.refs`. */
|
|
650
|
+
refs?: ChatRef[];
|
|
585
651
|
}
|
|
586
652
|
|
|
587
653
|
// ========== Base Message Interface ==========
|
|
@@ -633,4 +699,21 @@ export interface Message {
|
|
|
633
699
|
* bubble like "(continue per protocol)" between the approval card
|
|
634
700
|
* and the AI's follow-up. */
|
|
635
701
|
hidden?: boolean;
|
|
702
|
+
/**
|
|
703
|
+
* Documents this answer cited, rendered as chips beneath it.
|
|
704
|
+
*
|
|
705
|
+
* Per MESSAGE, not per conversation: an answer's citations belong to the
|
|
706
|
+
* answer, and a thread can hold several answers that each cited something
|
|
707
|
+
* different. Ordering is a rendering concern — see `splitCitedSources`.
|
|
708
|
+
*/
|
|
709
|
+
sources?: ChatSource[];
|
|
710
|
+
/**
|
|
711
|
+
* Entity references this answer's metadata described — videos and cards.
|
|
712
|
+
*
|
|
713
|
+
* Presence here does NOT mean "render it": only the `[card://type:id]`
|
|
714
|
+
* markers actually written into the answer text are rendered, and these
|
|
715
|
+
* supply the data those markers expand with. The metadata frame routinely
|
|
716
|
+
* describes more than the model chose to cite.
|
|
717
|
+
*/
|
|
718
|
+
refs?: ChatRef[];
|
|
636
719
|
}
|
|
@@ -17,12 +17,11 @@
|
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
19
|
import type { ChatRef } from '../chat-ref.types';
|
|
20
|
-
import type { ChatSource } from '../hooks/use-sse-chat-adapter';
|
|
21
20
|
import type { ChatAttachment } from '../utils/chat-attachment-markdown';
|
|
22
21
|
import type { AuthorType } from './chat.types';
|
|
23
22
|
import type { DialogItem } from './component.types';
|
|
24
23
|
import type { ChatContextItem } from './context-item.types';
|
|
25
|
-
import type { MessageSegment, ScrollAnchor } from './message.types';
|
|
24
|
+
import type { ChatSource, MessageSegment, ScrollAnchor } from './message.types';
|
|
26
25
|
|
|
27
26
|
// ─── Dialog-list host contract (shared by the NATS + SSE adapters) ───────────
|
|
28
27
|
|
|
@@ -230,8 +229,18 @@ export interface UnifiedChatMessage {
|
|
|
230
229
|
*/
|
|
231
230
|
timestamp?: Date | string | number;
|
|
232
231
|
|
|
233
|
-
/**
|
|
232
|
+
/**
|
|
233
|
+
* Documents this answer cited, rendered as chips beneath it. Produced by
|
|
234
|
+
* BOTH transports now — SSE reads them off the per-turn metadata frame, NATS
|
|
235
|
+
* decodes them out of a `GUIDE`/`SOURCES` chunk.
|
|
236
|
+
*/
|
|
234
237
|
sources?: ChatSource[];
|
|
238
|
+
/**
|
|
239
|
+
* Entity references this answer's metadata described — videos and cards.
|
|
240
|
+
* Data for the `[card://type:id]` markers in the body, not a render list:
|
|
241
|
+
* only markers actually present in the text are rendered.
|
|
242
|
+
*/
|
|
243
|
+
refs?: ChatRef[];
|
|
235
244
|
|
|
236
245
|
/**
|
|
237
246
|
* Per-message viewport-positioning hint. Common to both modes; the
|