@flamingo-stack/openframe-frontend-core 0.0.609-snapshot.20260908170120 → 0.0.609
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/events.d.ts +2 -21
- package/dist/chat-protocol/events.d.ts.map +1 -1
- package/dist/chat-protocol/index.cjs +9 -211
- package/dist/chat-protocol/index.cjs.map +1 -1
- package/dist/chat-protocol/index.js +9 -211
- package/dist/chat-protocol/index.js.map +1 -1
- package/dist/chat-protocol/nats-decoder.d.ts.map +1 -1
- package/dist/{chunk-2YMDDD5V.cjs → chunk-3N4FXBVJ.cjs} +3 -3
- package/dist/{chunk-2YMDDD5V.cjs.map → chunk-3N4FXBVJ.cjs.map} +1 -1
- package/dist/{chunk-THCB7NHV.cjs → chunk-3XNMDLGB.cjs} +9 -9
- package/dist/{chunk-THCB7NHV.cjs.map → chunk-3XNMDLGB.cjs.map} +1 -1
- package/dist/{chunk-GFAHCXIL.cjs → chunk-45XXK2VU.cjs} +10 -10
- package/dist/{chunk-GFAHCXIL.cjs.map → chunk-45XXK2VU.cjs.map} +1 -1
- package/dist/{chunk-2QBXG74C.js → chunk-6MLRFM3T.js} +5 -5
- package/dist/{chunk-IBMHEOBV.js → chunk-B3UXNGVM.js} +3 -3
- package/dist/{chunk-O6PO5BHE.js → chunk-B7LYKBCD.js} +5 -5
- package/dist/{chunk-F2C2U7CP.js → chunk-BSMPCPOZ.js} +299 -590
- package/dist/chunk-BSMPCPOZ.js.map +1 -0
- package/dist/{chunk-MGXSJI23.js → chunk-BUXGWBTF.js} +2 -2
- package/dist/{chunk-OIKZDXNW.js → chunk-C7CTEUU7.js} +2 -2
- package/dist/{chunk-EANAFFAD.cjs → chunk-CZTOSG7Q.cjs} +22 -22
- package/dist/{chunk-EANAFFAD.cjs.map → chunk-CZTOSG7Q.cjs.map} +1 -1
- package/dist/{chunk-C4KQ2XPK.cjs → chunk-D3DTC7SZ.cjs} +15 -15
- package/dist/{chunk-C4KQ2XPK.cjs.map → chunk-D3DTC7SZ.cjs.map} +1 -1
- package/dist/{chunk-HKJ3WKGW.cjs → chunk-DKNXAJMP.cjs} +159 -159
- package/dist/{chunk-HKJ3WKGW.cjs.map → chunk-DKNXAJMP.cjs.map} +1 -1
- package/dist/{chunk-UFFVMZDL.cjs → chunk-FYG7QNAO.cjs} +5 -5
- package/dist/{chunk-UFFVMZDL.cjs.map → chunk-FYG7QNAO.cjs.map} +1 -1
- package/dist/{chunk-THCSSPXU.cjs → chunk-GMOBT5NP.cjs} +70 -70
- package/dist/{chunk-THCSSPXU.cjs.map → chunk-GMOBT5NP.cjs.map} +1 -1
- package/dist/{chunk-HQSCJYCF.js → chunk-HGVW7OHI.js} +2 -2
- package/dist/{chunk-FS3CTGIR.js → chunk-JKM5FH63.js} +3 -3
- package/dist/{chunk-37CAZTLP.js → chunk-JOCVQZGT.js} +5 -5
- package/dist/{chunk-ROOIHDLS.js → chunk-JR7I2AGL.js} +3 -3
- package/dist/{chunk-OVVKVIMH.cjs → chunk-L2JWC5VS.cjs} +43 -43
- package/dist/{chunk-OVVKVIMH.cjs.map → chunk-L2JWC5VS.cjs.map} +1 -1
- package/dist/{chunk-25YIHMZ6.js → chunk-LA2W5L6K.js} +2 -2
- package/dist/{chunk-V6TINNLD.js → chunk-MVBRMQGU.js} +2 -2
- package/dist/{chunk-Q3APHZK5.cjs → chunk-NJUSDREV.cjs} +22 -22
- package/dist/{chunk-Q3APHZK5.cjs.map → chunk-NJUSDREV.cjs.map} +1 -1
- package/dist/{chunk-FASOANK7.cjs → chunk-O2M4T34Q.cjs} +4 -4
- package/dist/{chunk-FASOANK7.cjs.map → chunk-O2M4T34Q.cjs.map} +1 -1
- package/dist/{chunk-R2UDEMKK.js → chunk-OTYV6SDN.js} +3 -3
- package/dist/{chunk-HZS4TV34.js → chunk-QX4ANESW.js} +6 -6
- package/dist/{chunk-ZDLCWNM6.cjs → chunk-RZM6FPOT.cjs} +25 -25
- package/dist/{chunk-ZDLCWNM6.cjs.map → chunk-RZM6FPOT.cjs.map} +1 -1
- package/dist/{chunk-GNLV326I.cjs → chunk-SEW25Y2W.cjs} +10 -10
- package/dist/{chunk-GNLV326I.cjs.map → chunk-SEW25Y2W.cjs.map} +1 -1
- package/dist/{chunk-QE2Z6WME.cjs → chunk-TCEALWE3.cjs} +33 -33
- package/dist/{chunk-QE2Z6WME.cjs.map → chunk-TCEALWE3.cjs.map} +1 -1
- package/dist/{chunk-OJZW3GE2.js → chunk-TJ3GFULR.js} +3 -3
- package/dist/{chunk-Q2CNCBMK.js → chunk-VCYRJY7J.js} +4 -4
- package/dist/{chunk-YXTAV2E3.cjs → chunk-XNDTYTVT.cjs} +683 -974
- package/dist/chunk-XNDTYTVT.cjs.map +1 -0
- package/dist/{chunk-WJQOYSR3.cjs → chunk-ZRLFBLME.cjs} +3 -3
- package/dist/{chunk-WJQOYSR3.cjs.map → chunk-ZRLFBLME.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 +28 -5
- 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 +4 -5
- 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 +0 -27
- package/dist/components/chat/types/component.types.d.ts.map +1 -1
- package/dist/components/chat/types/message.types.d.ts +1 -81
- package/dist/components/chat/types/message.types.d.ts.map +1 -1
- package/dist/components/chat/types/unified-chat-state.types.d.ts +3 -12
- package/dist/components/chat/types/unified-chat-state.types.d.ts.map +1 -1
- 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/events.ts +1 -22
- package/src/chat-protocol/nats-decoder.ts +0 -12
- package/src/components/chat/chat-message-enhanced.tsx +12 -37
- package/src/components/chat/chat-message-list.tsx +1 -14
- package/src/components/chat/embeddable-chat.tsx +87 -47
- package/src/components/chat/hooks/use-sse-chat-adapter.ts +28 -5
- package/src/components/chat/remark-card-links.ts +12 -14
- package/src/components/chat/stream/chat-stream-reducer.ts +3 -48
- package/src/components/chat/tool-execution-display.tsx +4 -18
- package/src/components/chat/types/component.types.ts +0 -27
- package/src/components/chat/types/message.types.ts +0 -83
- package/src/components/chat/types/unified-chat-state.types.ts +3 -12
- package/src/components/chat/utils/process-historical-messages.ts +0 -25
- package/dist/chat-protocol/card-marker.d.ts +0 -31
- package/dist/chat-protocol/card-marker.d.ts.map +0 -1
- package/dist/chat-protocol/source-metadata.d.ts +0 -56
- package/dist/chat-protocol/source-metadata.d.ts.map +0 -1
- package/dist/chunk-F2C2U7CP.js.map +0 -1
- package/dist/chunk-YXTAV2E3.cjs.map +0 -1
- package/dist/components/chat/utils/cited-sources.d.ts +0 -24
- package/dist/components/chat/utils/cited-sources.d.ts.map +0 -1
- package/dist/components/chat/utils/host-message.d.ts +0 -41
- package/dist/components/chat/utils/host-message.d.ts.map +0 -1
- package/src/chat-protocol/__tests__/card-marker.test.ts +0 -63
- package/src/chat-protocol/__tests__/source-metadata.test.ts +0 -243
- package/src/chat-protocol/card-marker.ts +0 -40
- package/src/chat-protocol/source-metadata.ts +0 -336
- package/src/components/chat/__tests__/tool-execution-display.test.tsx +0 -70
- package/src/components/chat/utils/__tests__/cited-sources.test.ts +0 -80
- package/src/components/chat/utils/__tests__/host-message.test.ts +0 -92
- package/src/components/chat/utils/__tests__/process-historical-messages-sources.test.ts +0 -138
- package/src/components/chat/utils/cited-sources.ts +0 -61
- package/src/components/chat/utils/host-message.ts +0 -87
- /package/dist/{chunk-2QBXG74C.js.map → chunk-6MLRFM3T.js.map} +0 -0
- /package/dist/{chunk-IBMHEOBV.js.map → chunk-B3UXNGVM.js.map} +0 -0
- /package/dist/{chunk-O6PO5BHE.js.map → chunk-B7LYKBCD.js.map} +0 -0
- /package/dist/{chunk-MGXSJI23.js.map → chunk-BUXGWBTF.js.map} +0 -0
- /package/dist/{chunk-OIKZDXNW.js.map → chunk-C7CTEUU7.js.map} +0 -0
- /package/dist/{chunk-HQSCJYCF.js.map → chunk-HGVW7OHI.js.map} +0 -0
- /package/dist/{chunk-FS3CTGIR.js.map → chunk-JKM5FH63.js.map} +0 -0
- /package/dist/{chunk-37CAZTLP.js.map → chunk-JOCVQZGT.js.map} +0 -0
- /package/dist/{chunk-ROOIHDLS.js.map → chunk-JR7I2AGL.js.map} +0 -0
- /package/dist/{chunk-25YIHMZ6.js.map → chunk-LA2W5L6K.js.map} +0 -0
- /package/dist/{chunk-V6TINNLD.js.map → chunk-MVBRMQGU.js.map} +0 -0
- /package/dist/{chunk-R2UDEMKK.js.map → chunk-OTYV6SDN.js.map} +0 -0
- /package/dist/{chunk-HZS4TV34.js.map → chunk-QX4ANESW.js.map} +0 -0
- /package/dist/{chunk-OJZW3GE2.js.map → chunk-TJ3GFULR.js.map} +0 -0
- /package/dist/{chunk-Q2CNCBMK.js.map → chunk-VCYRJY7J.js.map} +0 -0
|
@@ -195,20 +195,6 @@ 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[];
|
|
212
198
|
/**
|
|
213
199
|
* Host-provided anchor component for markdown links. When supplied, the
|
|
214
200
|
* `<a>` override in the markdown renderer delegates to this component
|
|
@@ -310,19 +296,6 @@ export interface ChatMessageListProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
310
296
|
/** Host-provided renderer for inline entity cards. Forwarded verbatim
|
|
311
297
|
* to every message's ChatMessageEnhanced. v6.1 §B.2.7. */
|
|
312
298
|
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;
|
|
326
299
|
/** Host-provided anchor for markdown links. Forwarded verbatim to every
|
|
327
300
|
* message's ChatMessageEnhanced. Owns the unified click rule
|
|
328
301
|
* (same-origin soft nav, cross-origin new tab). */
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
* Contains all message structures, segments, and content types
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import type { ChatRef } from '../chat-ref.types';
|
|
7
6
|
import type { AssistantType, AuthorType, ChatApprovalStatus, MessageOwner } from './chat.types';
|
|
8
7
|
|
|
9
8
|
// ========== Message Type Definitions ==========
|
|
@@ -12,15 +11,6 @@ export const MESSAGE_TYPE = {
|
|
|
12
11
|
TEXT: 'TEXT',
|
|
13
12
|
THINKING: 'THINKING',
|
|
14
13
|
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',
|
|
24
14
|
EXECUTING_TOOL: 'EXECUTING_TOOL',
|
|
25
15
|
EXECUTED_TOOL: 'EXECUTED_TOOL',
|
|
26
16
|
APPROVAL_REQUEST: 'APPROVAL_REQUEST',
|
|
@@ -401,55 +391,6 @@ export interface ThinkingMessageData extends MessageDataBase {
|
|
|
401
391
|
text?: string;
|
|
402
392
|
}
|
|
403
393
|
|
|
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
|
-
|
|
453
394
|
/** Persisted `ASK` row (GraphQL `AskData`). `text` is the intro sentence, which
|
|
454
395
|
* history replays as a text segment ahead of the card — same split the live
|
|
455
396
|
* `ASK` chunk carries. */
|
|
@@ -592,7 +533,6 @@ export type MessageData =
|
|
|
592
533
|
| TextMessageData
|
|
593
534
|
| ThinkingMessageData
|
|
594
535
|
| AskMessageData
|
|
595
|
-
| SourceMetadataMessageData
|
|
596
536
|
| ExecutingToolMessageData
|
|
597
537
|
| ExecutedToolMessageData
|
|
598
538
|
| ApprovalRequestMessageData
|
|
@@ -642,12 +582,6 @@ export interface ProcessedMessage {
|
|
|
642
582
|
* `streamSeq` so the history/realtime merge can do per-role seq coverage.
|
|
643
583
|
* Absent when the source row(s) carried no seq. */
|
|
644
584
|
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[];
|
|
651
585
|
}
|
|
652
586
|
|
|
653
587
|
// ========== Base Message Interface ==========
|
|
@@ -699,21 +633,4 @@ export interface Message {
|
|
|
699
633
|
* bubble like "(continue per protocol)" between the approval card
|
|
700
634
|
* and the AI's follow-up. */
|
|
701
635
|
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[];
|
|
719
636
|
}
|
|
@@ -17,11 +17,12 @@
|
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
19
|
import type { ChatRef } from '../chat-ref.types';
|
|
20
|
+
import type { ChatSource } from '../hooks/use-sse-chat-adapter';
|
|
20
21
|
import type { ChatAttachment } from '../utils/chat-attachment-markdown';
|
|
21
22
|
import type { AuthorType } from './chat.types';
|
|
22
23
|
import type { DialogItem } from './component.types';
|
|
23
24
|
import type { ChatContextItem } from './context-item.types';
|
|
24
|
-
import type {
|
|
25
|
+
import type { MessageSegment, ScrollAnchor } from './message.types';
|
|
25
26
|
|
|
26
27
|
// ─── Dialog-list host contract (shared by the NATS + SSE adapters) ───────────
|
|
27
28
|
|
|
@@ -229,18 +230,8 @@ export interface UnifiedChatMessage {
|
|
|
229
230
|
*/
|
|
230
231
|
timestamp?: Date | string | number;
|
|
231
232
|
|
|
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
|
-
*/
|
|
233
|
+
/** Guide/SSE-only: document citations. Undefined in Mingo mode. */
|
|
237
234
|
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[];
|
|
244
235
|
|
|
245
236
|
/**
|
|
246
237
|
* Per-message viewport-positioning hint. Common to both modes; the
|
|
@@ -34,7 +34,6 @@ import {
|
|
|
34
34
|
// One normalizer for ask rows, shared with the live decoder — history and the
|
|
35
35
|
// stream must agree on which options are usable.
|
|
36
36
|
import { normalizeAskOptions } from '../../../chat-protocol/nats-decoder';
|
|
37
|
-
import { mergeSourceMetadata, sourceMetadataEvent, type SourceMetadata } from '../../../chat-protocol/source-metadata';
|
|
38
37
|
import { applyApprovalStatusToSegment } from '../stream/message-mutations';
|
|
39
38
|
import {
|
|
40
39
|
MESSAGE_TYPE,
|
|
@@ -122,13 +121,6 @@ export function decodeHistoricalMessageData(data: MessageData): ChatStreamEvent
|
|
|
122
121
|
}
|
|
123
122
|
return null;
|
|
124
123
|
|
|
125
|
-
// Persisted source metadata, through the SAME decoder the live chunk uses
|
|
126
|
-
// (`sourceMetadataEvent`). That shared parse is the whole reason a reloaded
|
|
127
|
-
// answer renders identically to the one the reader watched arrive.
|
|
128
|
-
case MESSAGE_TYPE.GUIDE:
|
|
129
|
-
case MESSAGE_TYPE.SOURCES:
|
|
130
|
-
return 'payload' in data ? sourceMetadataEvent(data.payload) : null;
|
|
131
|
-
|
|
132
124
|
// Same completeness gate as the live decoder (`decodeNatsChunk`): a
|
|
133
125
|
// persisted row without a question or without options is not a card the
|
|
134
126
|
// user can answer, so it replays as nothing rather than as empty chrome.
|
|
@@ -604,12 +596,6 @@ export function processHistoricalMessages(
|
|
|
604
596
|
// MAX persisted seq across the rows grouped into the current assistant turn
|
|
605
597
|
// — carried onto the flushed message's streamSeq for per-role merge coverage.
|
|
606
598
|
let currentAssistantStreamSeq: number | undefined;
|
|
607
|
-
// Source metadata for the current assistant turn. It is persisted as its OWN
|
|
608
|
-
// row (the backend saves it when the remote tool returns, before the answer
|
|
609
|
-
// text exists), so it arrives as a separate history message that groups into
|
|
610
|
-
// the same turn — and has to be carried across the group rather than applied
|
|
611
|
-
// where it was read.
|
|
612
|
-
let currentAssistantSourceMetadata: SourceMetadata | null = null;
|
|
613
599
|
|
|
614
600
|
/**
|
|
615
601
|
* Flush the current assistant message to processedMessages.
|
|
@@ -628,7 +614,6 @@ export function processHistoricalMessages(
|
|
|
628
614
|
timestamp: currentAssistantTimestamp || new Date(),
|
|
629
615
|
avatar: assistantAvatar,
|
|
630
616
|
...(currentAssistantStreamSeq !== undefined ? { streamSeq: currentAssistantStreamSeq } : {}),
|
|
631
|
-
...(currentAssistantSourceMetadata ?? {}),
|
|
632
617
|
});
|
|
633
618
|
accumulator.resetSegments();
|
|
634
619
|
}
|
|
@@ -643,10 +628,6 @@ export function processHistoricalMessages(
|
|
|
643
628
|
currentAssistantTimestamp = null;
|
|
644
629
|
lastAssistantId = null;
|
|
645
630
|
currentAssistantStreamSeq = undefined;
|
|
646
|
-
// Reset UNCONDITIONALLY, for the same reason the seq above is: a turn whose
|
|
647
|
-
// only row was metadata renders nothing, and leaving it set would stamp the
|
|
648
|
-
// NEXT answer with citations that belong to this one.
|
|
649
|
-
currentAssistantSourceMetadata = null;
|
|
650
631
|
};
|
|
651
632
|
|
|
652
633
|
messages.forEach((msg, index) => {
|
|
@@ -713,12 +694,6 @@ export function processHistoricalMessages(
|
|
|
713
694
|
messageDataArray.forEach(data => {
|
|
714
695
|
const event = decodeHistoricalMessageData(data);
|
|
715
696
|
if (!event) return;
|
|
716
|
-
// Metadata is a property OF the turn, not a segment in it — it never
|
|
717
|
-
// reaches the accumulator, which would have nothing to do with it.
|
|
718
|
-
if (event.type === 'sources') {
|
|
719
|
-
currentAssistantSourceMetadata = mergeSourceMetadata(currentAssistantSourceMetadata, event);
|
|
720
|
-
return;
|
|
721
|
-
}
|
|
722
697
|
applyHistoryEvent(
|
|
723
698
|
event,
|
|
724
699
|
accumulator,
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The `[card://<type>:<id>]` marker grammar — ONE definition, two readers.
|
|
3
|
-
*
|
|
4
|
-
* The model writes these markers into the answer body, and the metadata frame
|
|
5
|
-
* describes the same references separately. Two parsers therefore have to agree
|
|
6
|
-
* on what counts as a marker: the payload decoder (`source-metadata.ts`) and the
|
|
7
|
-
* body renderer (`chat-message-enhanced.tsx`). When they disagree the failure is
|
|
8
|
-
* silent and one-sided — the stricter side drops a reference the other accepted,
|
|
9
|
-
* and the reader is left looking at raw `[card://…]` text in a sentence.
|
|
10
|
-
*
|
|
11
|
-
* The id half is deliberately permissive: the backend validates it as "anything
|
|
12
|
-
* but `]` and newlines", and a client that narrows that is the side that breaks.
|
|
13
|
-
* `)` is excluded on top because the body form also terminates on it (a marker
|
|
14
|
-
* written as a markdown link target).
|
|
15
|
-
*
|
|
16
|
-
* Server-safe: no React, no browser APIs.
|
|
17
|
-
*/
|
|
18
|
-
/**
|
|
19
|
-
* A marker standing ALONE, anchored — for validating a `ref` field in the
|
|
20
|
-
* metadata payload, where the whole string must be the marker and nothing else.
|
|
21
|
-
*/
|
|
22
|
-
export declare const CARD_REFERENCE: RegExp;
|
|
23
|
-
/**
|
|
24
|
-
* A marker EMBEDDED in answer text, unanchored and global.
|
|
25
|
-
*
|
|
26
|
-
* Terminates on `]` or `)` so a marker used as a markdown link target
|
|
27
|
-
* (`[card://x:y](…)`) is matched too. Being global, it carries `lastIndex`
|
|
28
|
-
* state — reset it before each scan.
|
|
29
|
-
*/
|
|
30
|
-
export declare function createCardMarkerScanner(): RegExp;
|
|
31
|
-
//# sourceMappingURL=card-marker.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"card-marker.d.ts","sourceRoot":"","sources":["../../src/chat-protocol/card-marker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAQH;;;GAGG;AACH,eAAO,MAAM,cAAc,QAA2D,CAAC;AAEvF;;;;;;GAMG;AACH,wBAAgB,uBAAuB,IAAI,MAAM,CAEhD"}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Source-metadata payload → `{ sources, refs }`.
|
|
3
|
-
*
|
|
4
|
-
* ONE decoder for two arrival paths: the live `GUIDE`/`SOURCES` NATS chunk and
|
|
5
|
-
* the persisted row of the same name in dialog history. That is the whole point
|
|
6
|
-
* of putting it here rather than in either consumer — a reloaded thread has to
|
|
7
|
-
* render identically to the live turn, and two parsers is exactly how that stops
|
|
8
|
-
* being true.
|
|
9
|
-
*
|
|
10
|
-
* Everything is validated, and anything that fails is DROPPED rather than
|
|
11
|
-
* repaired: this payload is assembled from a remote MCP server's tool output,
|
|
12
|
-
* so a malformed row means an upstream contract slip, and rendering a chip with
|
|
13
|
-
* a blank title or a link to a non-https URL is worse than rendering nothing.
|
|
14
|
-
*
|
|
15
|
-
* Server-safe: no React, no browser APIs beyond `URL`.
|
|
16
|
-
*/
|
|
17
|
-
import type { ChatRef } from '../components/chat/chat-ref.types';
|
|
18
|
-
import type { ChatSource } from '../components/chat/types/message.types';
|
|
19
|
-
import type { SourcesEvent } from './events';
|
|
20
|
-
/**
|
|
21
|
-
* A YouTube video id, from either a bare id or any of the watch/short/embed URL
|
|
22
|
-
* shapes. Returns the ID, never a URL — the player takes an id.
|
|
23
|
-
*/
|
|
24
|
-
export declare function youtubeVideoId(value: unknown): string | undefined;
|
|
25
|
-
/**
|
|
26
|
-
* Decode one source-metadata payload into its event, or `null` when there is
|
|
27
|
-
* nothing usable in it.
|
|
28
|
-
*
|
|
29
|
-
* Returning `null` for an empty result matters: the reducer stamps this onto a
|
|
30
|
-
* message, and an event carrying two empty arrays would overwrite metadata that
|
|
31
|
-
* an earlier chunk of the same turn had already supplied.
|
|
32
|
-
*/
|
|
33
|
-
export declare function sourceMetadataEvent(payload: unknown): SourcesEvent | null;
|
|
34
|
-
/** What one assistant answer carries: its citations and its expandable refs. */
|
|
35
|
-
export interface SourceMetadata {
|
|
36
|
-
sources?: ChatSource[];
|
|
37
|
-
refs?: ChatRef[];
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Fold one decoded chunk into an answer's accumulated metadata.
|
|
41
|
-
*
|
|
42
|
-
* A single turn can call several remote tools, each returning its own metadata,
|
|
43
|
-
* so this merges rather than replaces — and it is shared by the live reducer and
|
|
44
|
-
* the history replay precisely because those two must agree on what a reloaded
|
|
45
|
-
* answer shows.
|
|
46
|
-
*
|
|
47
|
-
* First writer wins per identity (`index` for a source, `type:id` for a ref),
|
|
48
|
-
* the same rule the decoder applies within one payload.
|
|
49
|
-
*
|
|
50
|
-
* KNOWN LIMIT: citation numbers are assigned per tool result, so two tool calls
|
|
51
|
-
* in one turn can both claim `[1]`. The later source is dropped rather than
|
|
52
|
-
* renumbered — by then the numbers are already written into the answer text,
|
|
53
|
-
* and renumbering would point `[1]` at a document the sentence is not about.
|
|
54
|
-
*/
|
|
55
|
-
export declare function mergeSourceMetadata(previous: SourceMetadata | null, event: SourcesEvent): SourceMetadata;
|
|
56
|
-
//# sourceMappingURL=source-metadata.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"source-metadata.d.ts","sourceRoot":"","sources":["../../src/chat-protocol/source-metadata.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mCAAmC,CAAC;AACjE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wCAAwC,CAAC;AAEzE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAsC7C;;;GAGG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAkBjE;AAqMD;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,GAAG,YAAY,GAAG,IAAI,CAYzE;AAED,gFAAgF;AAChF,MAAM,WAAW,cAAc;IAC7B,OAAO,CAAC,EAAE,UAAU,EAAE,CAAC;IACvB,IAAI,CAAC,EAAE,OAAO,EAAE,CAAC;CAClB;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,cAAc,GAAG,IAAI,EAAE,KAAK,EAAE,YAAY,GAAG,cAAc,CAcxG"}
|