@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.
Files changed (153) hide show
  1. package/dist/chat-protocol/events.d.ts +2 -21
  2. package/dist/chat-protocol/events.d.ts.map +1 -1
  3. package/dist/chat-protocol/index.cjs +9 -211
  4. package/dist/chat-protocol/index.cjs.map +1 -1
  5. package/dist/chat-protocol/index.js +9 -211
  6. package/dist/chat-protocol/index.js.map +1 -1
  7. package/dist/chat-protocol/nats-decoder.d.ts.map +1 -1
  8. package/dist/{chunk-2YMDDD5V.cjs → chunk-3N4FXBVJ.cjs} +3 -3
  9. package/dist/{chunk-2YMDDD5V.cjs.map → chunk-3N4FXBVJ.cjs.map} +1 -1
  10. package/dist/{chunk-THCB7NHV.cjs → chunk-3XNMDLGB.cjs} +9 -9
  11. package/dist/{chunk-THCB7NHV.cjs.map → chunk-3XNMDLGB.cjs.map} +1 -1
  12. package/dist/{chunk-GFAHCXIL.cjs → chunk-45XXK2VU.cjs} +10 -10
  13. package/dist/{chunk-GFAHCXIL.cjs.map → chunk-45XXK2VU.cjs.map} +1 -1
  14. package/dist/{chunk-2QBXG74C.js → chunk-6MLRFM3T.js} +5 -5
  15. package/dist/{chunk-IBMHEOBV.js → chunk-B3UXNGVM.js} +3 -3
  16. package/dist/{chunk-O6PO5BHE.js → chunk-B7LYKBCD.js} +5 -5
  17. package/dist/{chunk-F2C2U7CP.js → chunk-BSMPCPOZ.js} +299 -590
  18. package/dist/chunk-BSMPCPOZ.js.map +1 -0
  19. package/dist/{chunk-MGXSJI23.js → chunk-BUXGWBTF.js} +2 -2
  20. package/dist/{chunk-OIKZDXNW.js → chunk-C7CTEUU7.js} +2 -2
  21. package/dist/{chunk-EANAFFAD.cjs → chunk-CZTOSG7Q.cjs} +22 -22
  22. package/dist/{chunk-EANAFFAD.cjs.map → chunk-CZTOSG7Q.cjs.map} +1 -1
  23. package/dist/{chunk-C4KQ2XPK.cjs → chunk-D3DTC7SZ.cjs} +15 -15
  24. package/dist/{chunk-C4KQ2XPK.cjs.map → chunk-D3DTC7SZ.cjs.map} +1 -1
  25. package/dist/{chunk-HKJ3WKGW.cjs → chunk-DKNXAJMP.cjs} +159 -159
  26. package/dist/{chunk-HKJ3WKGW.cjs.map → chunk-DKNXAJMP.cjs.map} +1 -1
  27. package/dist/{chunk-UFFVMZDL.cjs → chunk-FYG7QNAO.cjs} +5 -5
  28. package/dist/{chunk-UFFVMZDL.cjs.map → chunk-FYG7QNAO.cjs.map} +1 -1
  29. package/dist/{chunk-THCSSPXU.cjs → chunk-GMOBT5NP.cjs} +70 -70
  30. package/dist/{chunk-THCSSPXU.cjs.map → chunk-GMOBT5NP.cjs.map} +1 -1
  31. package/dist/{chunk-HQSCJYCF.js → chunk-HGVW7OHI.js} +2 -2
  32. package/dist/{chunk-FS3CTGIR.js → chunk-JKM5FH63.js} +3 -3
  33. package/dist/{chunk-37CAZTLP.js → chunk-JOCVQZGT.js} +5 -5
  34. package/dist/{chunk-ROOIHDLS.js → chunk-JR7I2AGL.js} +3 -3
  35. package/dist/{chunk-OVVKVIMH.cjs → chunk-L2JWC5VS.cjs} +43 -43
  36. package/dist/{chunk-OVVKVIMH.cjs.map → chunk-L2JWC5VS.cjs.map} +1 -1
  37. package/dist/{chunk-25YIHMZ6.js → chunk-LA2W5L6K.js} +2 -2
  38. package/dist/{chunk-V6TINNLD.js → chunk-MVBRMQGU.js} +2 -2
  39. package/dist/{chunk-Q3APHZK5.cjs → chunk-NJUSDREV.cjs} +22 -22
  40. package/dist/{chunk-Q3APHZK5.cjs.map → chunk-NJUSDREV.cjs.map} +1 -1
  41. package/dist/{chunk-FASOANK7.cjs → chunk-O2M4T34Q.cjs} +4 -4
  42. package/dist/{chunk-FASOANK7.cjs.map → chunk-O2M4T34Q.cjs.map} +1 -1
  43. package/dist/{chunk-R2UDEMKK.js → chunk-OTYV6SDN.js} +3 -3
  44. package/dist/{chunk-HZS4TV34.js → chunk-QX4ANESW.js} +6 -6
  45. package/dist/{chunk-ZDLCWNM6.cjs → chunk-RZM6FPOT.cjs} +25 -25
  46. package/dist/{chunk-ZDLCWNM6.cjs.map → chunk-RZM6FPOT.cjs.map} +1 -1
  47. package/dist/{chunk-GNLV326I.cjs → chunk-SEW25Y2W.cjs} +10 -10
  48. package/dist/{chunk-GNLV326I.cjs.map → chunk-SEW25Y2W.cjs.map} +1 -1
  49. package/dist/{chunk-QE2Z6WME.cjs → chunk-TCEALWE3.cjs} +33 -33
  50. package/dist/{chunk-QE2Z6WME.cjs.map → chunk-TCEALWE3.cjs.map} +1 -1
  51. package/dist/{chunk-OJZW3GE2.js → chunk-TJ3GFULR.js} +3 -3
  52. package/dist/{chunk-Q2CNCBMK.js → chunk-VCYRJY7J.js} +4 -4
  53. package/dist/{chunk-YXTAV2E3.cjs → chunk-XNDTYTVT.cjs} +683 -974
  54. package/dist/chunk-XNDTYTVT.cjs.map +1 -0
  55. package/dist/{chunk-WJQOYSR3.cjs → chunk-ZRLFBLME.cjs} +3 -3
  56. package/dist/{chunk-WJQOYSR3.cjs.map → chunk-ZRLFBLME.cjs.map} +1 -1
  57. package/dist/components/case-studies/index.cjs +9 -9
  58. package/dist/components/case-studies/index.js +3 -3
  59. package/dist/components/chat/chat-message-enhanced.d.ts.map +1 -1
  60. package/dist/components/chat/chat-message-list.d.ts.map +1 -1
  61. package/dist/components/chat/embeddable-chat.d.ts.map +1 -1
  62. package/dist/components/chat/hooks/use-sse-chat-adapter.d.ts +28 -5
  63. package/dist/components/chat/hooks/use-sse-chat-adapter.d.ts.map +1 -1
  64. package/dist/components/chat/index.cjs +2 -2
  65. package/dist/components/chat/index.js +1 -1
  66. package/dist/components/chat/remark-card-links.d.ts +4 -5
  67. package/dist/components/chat/remark-card-links.d.ts.map +1 -1
  68. package/dist/components/chat/stream/chat-stream-reducer.d.ts.map +1 -1
  69. package/dist/components/chat/tool-execution-display.d.ts.map +1 -1
  70. package/dist/components/chat/types/component.types.d.ts +0 -27
  71. package/dist/components/chat/types/component.types.d.ts.map +1 -1
  72. package/dist/components/chat/types/message.types.d.ts +1 -81
  73. package/dist/components/chat/types/message.types.d.ts.map +1 -1
  74. package/dist/components/chat/types/unified-chat-state.types.d.ts +3 -12
  75. package/dist/components/chat/types/unified-chat-state.types.d.ts.map +1 -1
  76. package/dist/components/chat/utils/process-historical-messages.d.ts.map +1 -1
  77. package/dist/components/contact/index.cjs +4 -4
  78. package/dist/components/contact/index.js +3 -3
  79. package/dist/components/docs/index.cjs +7 -7
  80. package/dist/components/docs/index.js +6 -6
  81. package/dist/components/embeds/index.cjs +4 -4
  82. package/dist/components/embeds/index.js +3 -3
  83. package/dist/components/faq/index.cjs +4 -4
  84. package/dist/components/faq/index.js +3 -3
  85. package/dist/components/features/index.cjs +3 -3
  86. package/dist/components/features/index.js +2 -2
  87. package/dist/components/help-center-pages/index.cjs +23 -23
  88. package/dist/components/help-center-pages/index.js +14 -14
  89. package/dist/components/index.cjs +38 -38
  90. package/dist/components/index.js +13 -13
  91. package/dist/components/meeting-scheduler/index.cjs +24 -24
  92. package/dist/components/meeting-scheduler/index.js +2 -2
  93. package/dist/components/navigation/index.cjs +6 -6
  94. package/dist/components/navigation/index.js +5 -5
  95. package/dist/components/onboarding-guides/index.cjs +6 -6
  96. package/dist/components/onboarding-guides/index.js +5 -5
  97. package/dist/components/tickets/index.cjs +7 -7
  98. package/dist/components/tickets/index.js +6 -6
  99. package/dist/components/ui/index.cjs +3 -3
  100. package/dist/components/ui/index.js +2 -2
  101. package/dist/index.cjs +7 -7
  102. package/dist/index.js +6 -6
  103. package/dist/utils/index.cjs.map +1 -1
  104. package/dist/utils/index.js.map +1 -1
  105. package/package.json +1 -1
  106. package/src/chat-protocol/events.ts +1 -22
  107. package/src/chat-protocol/nats-decoder.ts +0 -12
  108. package/src/components/chat/chat-message-enhanced.tsx +12 -37
  109. package/src/components/chat/chat-message-list.tsx +1 -14
  110. package/src/components/chat/embeddable-chat.tsx +87 -47
  111. package/src/components/chat/hooks/use-sse-chat-adapter.ts +28 -5
  112. package/src/components/chat/remark-card-links.ts +12 -14
  113. package/src/components/chat/stream/chat-stream-reducer.ts +3 -48
  114. package/src/components/chat/tool-execution-display.tsx +4 -18
  115. package/src/components/chat/types/component.types.ts +0 -27
  116. package/src/components/chat/types/message.types.ts +0 -83
  117. package/src/components/chat/types/unified-chat-state.types.ts +3 -12
  118. package/src/components/chat/utils/process-historical-messages.ts +0 -25
  119. package/dist/chat-protocol/card-marker.d.ts +0 -31
  120. package/dist/chat-protocol/card-marker.d.ts.map +0 -1
  121. package/dist/chat-protocol/source-metadata.d.ts +0 -56
  122. package/dist/chat-protocol/source-metadata.d.ts.map +0 -1
  123. package/dist/chunk-F2C2U7CP.js.map +0 -1
  124. package/dist/chunk-YXTAV2E3.cjs.map +0 -1
  125. package/dist/components/chat/utils/cited-sources.d.ts +0 -24
  126. package/dist/components/chat/utils/cited-sources.d.ts.map +0 -1
  127. package/dist/components/chat/utils/host-message.d.ts +0 -41
  128. package/dist/components/chat/utils/host-message.d.ts.map +0 -1
  129. package/src/chat-protocol/__tests__/card-marker.test.ts +0 -63
  130. package/src/chat-protocol/__tests__/source-metadata.test.ts +0 -243
  131. package/src/chat-protocol/card-marker.ts +0 -40
  132. package/src/chat-protocol/source-metadata.ts +0 -336
  133. package/src/components/chat/__tests__/tool-execution-display.test.tsx +0 -70
  134. package/src/components/chat/utils/__tests__/cited-sources.test.ts +0 -80
  135. package/src/components/chat/utils/__tests__/host-message.test.ts +0 -92
  136. package/src/components/chat/utils/__tests__/process-historical-messages-sources.test.ts +0 -138
  137. package/src/components/chat/utils/cited-sources.ts +0 -61
  138. package/src/components/chat/utils/host-message.ts +0 -87
  139. /package/dist/{chunk-2QBXG74C.js.map → chunk-6MLRFM3T.js.map} +0 -0
  140. /package/dist/{chunk-IBMHEOBV.js.map → chunk-B3UXNGVM.js.map} +0 -0
  141. /package/dist/{chunk-O6PO5BHE.js.map → chunk-B7LYKBCD.js.map} +0 -0
  142. /package/dist/{chunk-MGXSJI23.js.map → chunk-BUXGWBTF.js.map} +0 -0
  143. /package/dist/{chunk-OIKZDXNW.js.map → chunk-C7CTEUU7.js.map} +0 -0
  144. /package/dist/{chunk-HQSCJYCF.js.map → chunk-HGVW7OHI.js.map} +0 -0
  145. /package/dist/{chunk-FS3CTGIR.js.map → chunk-JKM5FH63.js.map} +0 -0
  146. /package/dist/{chunk-37CAZTLP.js.map → chunk-JOCVQZGT.js.map} +0 -0
  147. /package/dist/{chunk-ROOIHDLS.js.map → chunk-JR7I2AGL.js.map} +0 -0
  148. /package/dist/{chunk-25YIHMZ6.js.map → chunk-LA2W5L6K.js.map} +0 -0
  149. /package/dist/{chunk-V6TINNLD.js.map → chunk-MVBRMQGU.js.map} +0 -0
  150. /package/dist/{chunk-R2UDEMKK.js.map → chunk-OTYV6SDN.js.map} +0 -0
  151. /package/dist/{chunk-HZS4TV34.js.map → chunk-QX4ANESW.js.map} +0 -0
  152. /package/dist/{chunk-OJZW3GE2.js.map → chunk-TJ3GFULR.js.map} +0 -0
  153. /package/dist/{chunk-Q2CNCBMK.js.map → chunk-VCYRJY7J.js.map} +0 -0
@@ -41,8 +41,8 @@ var CHAT_OWNER_ADMIN = "ADMIN";
41
41
  // src/chat-protocol/encode.ts
42
42
  var encoder = new TextEncoder();
43
43
  var SENTINEL_BYTES_RE = /[\u0000\u001E\u001F]/g;
44
- function stripSentinelBytes(text2) {
45
- return text2.replace(SENTINEL_BYTES_RE, "");
44
+ function stripSentinelBytes(text) {
45
+ return text.replace(SENTINEL_BYTES_RE, "");
46
46
  }
47
47
  function encodeLeadingFrame(frame) {
48
48
  return encoder.encode(JSON.stringify(frame) + FRAME_TERMINATOR);
@@ -50,16 +50,16 @@ function encodeLeadingFrame(frame) {
50
50
  function encodeEndOfLeading() {
51
51
  return encoder.encode(END_OF_LEADING);
52
52
  }
53
- function encodeTextDelta(text2) {
54
- return encoder.encode(stripSentinelBytes(text2));
53
+ function encodeTextDelta(text) {
54
+ return encoder.encode(stripSentinelBytes(text));
55
55
  }
56
56
  function encodeTrailingUsageFrame(frame) {
57
57
  return encoder.encode(TRAILER_SENTINEL + JSON.stringify(frame));
58
58
  }
59
59
 
60
60
  // src/chat-protocol/leading-frames.ts
61
- function escapeThinkingTags(text2) {
62
- return text2.replace(/</g, "&lt;");
61
+ function escapeThinkingTags(text) {
62
+ return text.replace(/</g, "&lt;");
63
63
  }
64
64
  function frameStr(value) {
65
65
  return typeof value === "string" ? value : void 0;
@@ -170,11 +170,11 @@ function isFrameObject(value) {
170
170
  }
171
171
  function frameTelemetry(value) {
172
172
  if (!isFrameObject(value)) return void 0;
173
- const { cards: cards2, chips, sentences, answerLen } = value;
174
- if (typeof cards2 !== "number" || typeof chips !== "number" || typeof sentences !== "number" || typeof answerLen !== "number") {
173
+ const { cards, chips, sentences, answerLen } = value;
174
+ if (typeof cards !== "number" || typeof chips !== "number" || typeof sentences !== "number" || typeof answerLen !== "number") {
175
175
  return void 0;
176
176
  }
177
- return { cards: cards2, chips, sentences, answerLen };
177
+ return { cards, chips, sentences, answerLen };
178
178
  }
179
179
  function createSseFrameDecoder() {
180
180
  const textDecoder = new TextDecoder();
@@ -285,15 +285,6 @@ var MESSAGE_TYPE = {
285
285
  TEXT: "TEXT",
286
286
  THINKING: "THINKING",
287
287
  ASK: "ASK",
288
- /** Per-answer source metadata (documents, videos, entity cards).
289
- *
290
- * TWO names for ONE payload, on purpose. `SOURCES` is the contract the
291
- * backend is moving to; `GUIDE` is the envelope it ships in today, reused
292
- * from Guide Mode v2 so a released frontend keeps working during the v2→v3
293
- * rollout. Both decode through the same path, so dropping `GUIDE` later is a
294
- * deletion here and nothing else. */
295
- GUIDE: "GUIDE",
296
- SOURCES: "SOURCES",
297
288
  EXECUTING_TOOL: "EXECUTING_TOOL",
298
289
  EXECUTED_TOOL: "EXECUTED_TOOL",
299
290
  APPROVAL_REQUEST: "APPROVAL_REQUEST",
@@ -314,11 +305,6 @@ var MESSAGE_TYPE = {
314
305
  DIALOG_CLOSED: "DIALOG_CLOSED"
315
306
  };
316
307
 
317
- // src/chat-protocol/card-marker.ts
318
- var CARD_TYPE = "[a-zA-Z0-9_-]+";
319
- var CARD_ID = "[^\\]\\r\\n)]+";
320
- var CARD_REFERENCE = new RegExp(`^\\[card://(${CARD_TYPE}):(${CARD_ID})\\]$`);
321
-
322
308
  // src/chat-protocol/wire-narrow.ts
323
309
  function isRecord(value) {
324
310
  return typeof value === "object" && value !== null;
@@ -327,184 +313,6 @@ function unwrapEnvelope(payload) {
327
313
  return isRecord(payload) && "data" in payload ? payload.data : payload;
328
314
  }
329
315
 
330
- // src/chat-protocol/source-metadata.ts
331
- var YOUTUBE_ID = /^[A-Za-z0-9_-]{11}$/;
332
- var VIDEO_URL_KEYS = ["videoUrl", "highlightVideoUrl", "videoPoster", "highlightVideoPoster"];
333
- function text(value) {
334
- if (typeof value !== "string") return void 0;
335
- const trimmed = value.trim();
336
- return trimmed || void 0;
337
- }
338
- function nullableText(value) {
339
- return value === null ? null : text(value);
340
- }
341
- function httpsUrl(value) {
342
- const candidate = text(value);
343
- if (!candidate) return void 0;
344
- try {
345
- return new URL(candidate).protocol === "https:" ? candidate : void 0;
346
- } catch {
347
- return void 0;
348
- }
349
- }
350
- function youtubeVideoId(value) {
351
- const candidate = text(value);
352
- if (!candidate) return void 0;
353
- if (YOUTUBE_ID.test(candidate)) return candidate;
354
- const url = httpsUrl(candidate);
355
- if (!url) return void 0;
356
- const parsed = new URL(url);
357
- const hostname = parsed.hostname.toLowerCase();
358
- const isYoutubeHost = hostname === "youtu.be" || hostname === "youtube.com" || hostname.endsWith(".youtube.com");
359
- if (!isYoutubeHost) return void 0;
360
- const fromPath = hostname === "youtu.be" ? parsed.pathname.split("/").filter(Boolean)[0] : /^\/(?:embed|v|shorts)\/([A-Za-z0-9_-]{11})(?:\/|$)/.exec(parsed.pathname)?.[1];
361
- const id = fromPath ?? parsed.searchParams.get("v") ?? void 0;
362
- return id && YOUTUBE_ID.test(id) ? id : void 0;
363
- }
364
- function sourceItems(value) {
365
- if (!Array.isArray(value)) return void 0;
366
- const items = value.filter(isRecord).flatMap((item) => {
367
- const id = text(item.id);
368
- const documentType = text(item.documentType);
369
- const name = text(item.name);
370
- if (!id || !documentType || !name) return [];
371
- const externalUrl = httpsUrl(item.externalUrl);
372
- const targetPlatform = nullableText(item.targetPlatform);
373
- const path = nullableText(item.path);
374
- return [
375
- {
376
- id,
377
- documentType,
378
- name,
379
- ...externalUrl ? { externalUrl } : {},
380
- ...targetPlatform !== void 0 ? { targetPlatform } : {},
381
- ...path !== void 0 ? { path } : {}
382
- }
383
- ];
384
- });
385
- return items.length > 0 ? items : void 0;
386
- }
387
- function sources(value) {
388
- if (!Array.isArray(value)) return [];
389
- const claimed = /* @__PURE__ */ new Set();
390
- const decoded = [];
391
- for (const candidate of value) {
392
- if (!isRecord(candidate)) continue;
393
- const index = candidate.index;
394
- const name = text(candidate.name);
395
- const isUsableIndex = typeof index === "number" && Number.isInteger(index) && index > 0 && !claimed.has(index);
396
- if (!isUsableIndex || !name) continue;
397
- claimed.add(index);
398
- const path = text(candidate.path);
399
- const documentType = text(candidate.documentType);
400
- const externalUrl = httpsUrl(candidate.externalUrl);
401
- const targetPlatform = nullableText(candidate.targetPlatform);
402
- const id = text(candidate.id);
403
- const sourceRepo = text(candidate.sourceRepo);
404
- const label = text(candidate.label);
405
- const items = sourceItems(candidate.items);
406
- decoded.push({
407
- index,
408
- name,
409
- // Both are typed non-optional on `ChatSource` and predate this decoder;
410
- // '' is the established "no value" for them across the SSE path.
411
- path: path ?? "",
412
- documentType: documentType ?? "",
413
- ...externalUrl ? { externalUrl } : {},
414
- ...targetPlatform !== void 0 ? { targetPlatform } : {},
415
- ...id ? { id } : {},
416
- ...sourceRepo ? { sourceRepo } : {},
417
- ...label ? { label } : {},
418
- ...items ? { items } : {}
419
- });
420
- }
421
- return decoded;
422
- }
423
- function videoMetadata(value, url) {
424
- const metadata = {};
425
- if (isRecord(value)) {
426
- for (const key of VIDEO_URL_KEYS) {
427
- const validated = httpsUrl(value[key]);
428
- if (validated) metadata[key] = validated;
429
- }
430
- const declaredId = youtubeVideoId(value.youtubeUrl);
431
- if (declaredId) metadata.youtubeUrl = declaredId;
432
- }
433
- if (url) {
434
- const idFromUrl = youtubeVideoId(url);
435
- if (idFromUrl) {
436
- metadata.youtubeUrl = idFromUrl;
437
- delete metadata.videoUrl;
438
- } else {
439
- metadata.videoUrl = url;
440
- delete metadata.youtubeUrl;
441
- }
442
- }
443
- return metadata;
444
- }
445
- function videos(value) {
446
- if (!Array.isArray(value)) return [];
447
- return value.filter(isRecord).flatMap((video) => {
448
- const match = typeof video.ref === "string" ? CARD_REFERENCE.exec(video.ref) : null;
449
- if (!match || match[1] !== "video") return [];
450
- const id = match[2];
451
- const url = httpsUrl(video.url) ?? null;
452
- const sourceRepo = text(video.sourceRepo);
453
- const metadata = videoMetadata(video.metadata, url);
454
- return [
455
- {
456
- type: "video",
457
- id,
458
- title: text(video.title) ?? id,
459
- url,
460
- ...sourceRepo ? { sourceRepo } : {},
461
- ...Object.keys(metadata).length > 0 ? { metadata } : {}
462
- }
463
- ];
464
- });
465
- }
466
- function cards(value, decodedSources) {
467
- if (!Array.isArray(value)) return [];
468
- return value.filter(isRecord).flatMap((card) => {
469
- const match = typeof card.ref === "string" ? CARD_REFERENCE.exec(card.ref) : null;
470
- if (!match || match[1] === "video") return [];
471
- const type = text(card.entityType);
472
- const id = text(card.entityId);
473
- if (!type || !id || type !== match[1] || id !== match[2]) return [];
474
- const source = decodedSources.find((candidate) => candidate.id === id && candidate.documentType === type);
475
- return [
476
- {
477
- type,
478
- id,
479
- title: source?.name ?? id,
480
- url: source?.externalUrl ?? null,
481
- ...source?.sourceRepo ? { sourceRepo: source.sourceRepo } : {},
482
- ...source?.targetPlatform !== void 0 ? { targetPlatform: source.targetPlatform } : {},
483
- ...source?.path ? { metadata: { path: source.path } } : {}
484
- }
485
- ];
486
- });
487
- }
488
- function deduplicateRefs(refs) {
489
- const byIdentity = /* @__PURE__ */ new Map();
490
- for (const ref of refs) {
491
- const identity = `${ref.type}:${ref.id}`;
492
- if (!byIdentity.has(identity)) byIdentity.set(identity, ref);
493
- }
494
- return [...byIdentity.values()];
495
- }
496
- function sourceMetadataEvent(payload) {
497
- if (!isRecord(payload)) return null;
498
- const decodedSources = sources(payload.sources);
499
- const refs = deduplicateRefs([...videos(payload.videos), ...cards(payload.cards, decodedSources)]);
500
- if (decodedSources.length === 0 && refs.length === 0) return null;
501
- return {
502
- type: "sources",
503
- ...decodedSources.length > 0 ? { sources: decodedSources } : {},
504
- ...refs.length > 0 ? { refs } : {}
505
- };
506
- }
507
-
508
316
  // src/chat-protocol/nats-decoder.ts
509
317
  function str(value) {
510
318
  return typeof value === "string" ? value : void 0;
@@ -570,16 +378,6 @@ function decodeNatsChunk(chunk) {
570
378
  return { type: "thinking-delta", text: data.text, ...seq };
571
379
  }
572
380
  return null;
573
- // Two chunk names, one payload and one decoder. `SOURCES` is the contract
574
- // the backend is moving to; `GUIDE` is the v2 envelope it ships in during
575
- // the rollout (see `MESSAGE_TYPE.GUIDE`). The chunk arrives BEFORE or
576
- // between the answer's text deltas, so the reducer — not this decoder —
577
- // owns attaching it to the right turn.
578
- case MESSAGE_TYPE.GUIDE:
579
- case MESSAGE_TYPE.SOURCES: {
580
- const event = sourceMetadataEvent(data.payload);
581
- return event ? { ...event, ...seq } : null;
582
- }
583
381
  // An ask card is only an ask card with something to pick: a question and at
584
382
  // least one option. Anything less is dropped rather than rendered as an
585
383
  // empty card the user can't answer — the backend already falls back to a