@flamingo-stack/openframe-frontend-core 0.0.584-1973.5461.1 → 0.0.584
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 -8
- package/dist/chat-protocol/events.d.ts.map +1 -1
- package/dist/chat-protocol/index.cjs +0 -188
- package/dist/chat-protocol/index.cjs.map +1 -1
- package/dist/chat-protocol/index.js +0 -188
- package/dist/chat-protocol/index.js.map +1 -1
- package/dist/chat-protocol/nats-decoder.d.ts.map +1 -1
- package/dist/{chunk-U7MJV2V7.cjs → chunk-33DHEEMP.cjs} +33 -33
- package/dist/{chunk-U7MJV2V7.cjs.map → chunk-33DHEEMP.cjs.map} +1 -1
- package/dist/{chunk-23VBGHBL.js → chunk-3ELW4VML.js} +2 -2
- package/dist/{chunk-7KBKLN2Z.cjs → chunk-3ZA2OYRE.cjs} +3 -3
- package/dist/{chunk-7KBKLN2Z.cjs.map → chunk-3ZA2OYRE.cjs.map} +1 -1
- package/dist/{chunk-73XDYWYG.js → chunk-4T5KOD3G.js} +5 -5
- package/dist/{chunk-MI6PPL3P.js → chunk-5CJKZHWO.js} +5 -5
- package/dist/{chunk-E7Q24T4G.js → chunk-6BJYPG2V.js} +3 -3
- package/dist/{chunk-YXNMLGFI.cjs → chunk-7X5TCK4R.cjs} +10 -10
- package/dist/{chunk-YXNMLGFI.cjs.map → chunk-7X5TCK4R.cjs.map} +1 -1
- package/dist/{chunk-7DEGEI7G.js → chunk-EJKEDCTH.js} +6 -6
- package/dist/{chunk-XIV5VDWL.cjs → chunk-HCKEDTKJ.cjs} +10 -10
- package/dist/{chunk-XIV5VDWL.cjs.map → chunk-HCKEDTKJ.cjs.map} +1 -1
- package/dist/{chunk-EQGAYDTC.cjs → chunk-IIT5HWLY.cjs} +9 -9
- package/dist/{chunk-EQGAYDTC.cjs.map → chunk-IIT5HWLY.cjs.map} +1 -1
- package/dist/{chunk-7SMYBCYH.cjs → chunk-IKUSKKFZ.cjs} +540 -883
- package/dist/chunk-IKUSKKFZ.cjs.map +1 -0
- package/dist/{chunk-JKYALZB7.cjs → chunk-JAJQ5P2Q.cjs} +22 -22
- package/dist/{chunk-JKYALZB7.cjs.map → chunk-JAJQ5P2Q.cjs.map} +1 -1
- package/dist/{chunk-WAXL3E3B.cjs → chunk-JFKK3ZOA.cjs} +43 -43
- package/dist/{chunk-WAXL3E3B.cjs.map → chunk-JFKK3ZOA.cjs.map} +1 -1
- package/dist/{chunk-AWAHYAII.js → chunk-JVWRMLQZ.js} +2 -2
- package/dist/{chunk-PZ27ELFP.cjs → chunk-JWKAJTNA.cjs} +43 -33
- package/dist/chunk-JWKAJTNA.cjs.map +1 -0
- package/dist/{chunk-PISJGXXI.js → chunk-KP6VJP36.js} +3 -3
- package/dist/{chunk-NSDZAUJK.js → chunk-LNKULR4V.js} +2 -2
- package/dist/{chunk-AFQB4YL7.cjs → chunk-MEJFHD5N.cjs} +15 -15
- package/dist/{chunk-AFQB4YL7.cjs.map → chunk-MEJFHD5N.cjs.map} +1 -1
- package/dist/{chunk-5VHCSN44.js → chunk-MYEG5ZDT.js} +2 -2
- package/dist/{chunk-MMA3MTJD.cjs → chunk-P2VRLSAP.cjs} +21 -21
- package/dist/{chunk-MMA3MTJD.cjs.map → chunk-P2VRLSAP.cjs.map} +1 -1
- package/dist/{chunk-7Q34BVL7.cjs → chunk-Q66AMADB.cjs} +4 -4
- package/dist/{chunk-7Q34BVL7.cjs.map → chunk-Q66AMADB.cjs.map} +1 -1
- package/dist/{chunk-4ARYZTGV.cjs → chunk-QJR32JM2.cjs} +159 -159
- package/dist/{chunk-4ARYZTGV.cjs.map → chunk-QJR32JM2.cjs.map} +1 -1
- package/dist/{chunk-M4IIK3B7.js → chunk-RURZ6QLN.js} +3 -3
- package/dist/{chunk-TCEU6DCF.js → chunk-TLKHLGAB.js} +3 -3
- package/dist/{chunk-JCWUJHOD.js → chunk-TOUD3AGK.js} +23 -13
- package/dist/chunk-TOUD3AGK.js.map +1 -0
- package/dist/{chunk-CHI7GJ3K.cjs → chunk-UCNEQKIT.cjs} +5 -5
- package/dist/{chunk-CHI7GJ3K.cjs.map → chunk-UCNEQKIT.cjs.map} +1 -1
- package/dist/{chunk-ZRGBLM6W.cjs → chunk-VOAZU46B.cjs} +69 -69
- package/dist/{chunk-ZRGBLM6W.cjs.map → chunk-VOAZU46B.cjs.map} +1 -1
- package/dist/{chunk-GYJVLFK5.js → chunk-VZSTL5VG.js} +2 -2
- package/dist/{chunk-3CAC3AAE.js → chunk-XPJKQ63S.js} +3 -3
- package/dist/{chunk-KSC5LNSY.js → chunk-XWBND4G5.js} +187 -530
- package/dist/chunk-XWBND4G5.js.map +1 -0
- package/dist/{chunk-22DWXIV3.js → chunk-YFZDIEVC.js} +5 -5
- package/dist/{chunk-7J7XDGY6.cjs → chunk-ZHUBNWEX.cjs} +3 -3
- package/dist/{chunk-7J7XDGY6.cjs.map → chunk-ZHUBNWEX.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/entity-cards/dispatch.d.ts.map +1 -1
- package/dist/components/chat/hooks/use-nats-chat-adapter.d.ts +1 -4
- package/dist/components/chat/hooks/use-nats-chat-adapter.d.ts.map +1 -1
- package/dist/components/chat/hooks/use-slash-commands.d.ts +3 -3
- package/dist/components/chat/hooks/use-slash-commands.d.ts.map +1 -1
- package/dist/components/chat/hooks/use-sse-chat-adapter.d.ts +28 -2
- 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/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 -4
- package/dist/components/chat/types/component.types.d.ts.map +1 -1
- package/dist/components/chat/types/message.types.d.ts +1 -35
- package/dist/components/chat/types/message.types.d.ts.map +1 -1
- package/dist/components/chat/types/unified-chat-state.types.d.ts +3 -3
- 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 +36 -36
- package/dist/components/index.js +13 -13
- package/dist/components/meeting-scheduler/index.cjs +21 -21
- 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/navigation/navigation-sidebar-item.d.ts.map +1 -1
- 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/hover-dropdown.d.ts.map +1 -1
- 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__/nats-decoder-golden.test.ts +0 -130
- package/src/chat-protocol/events.ts +1 -9
- package/src/chat-protocol/nats-decoder.ts +0 -7
- package/src/components/chat/__tests__/chat-message-list.test.tsx +0 -70
- package/src/components/chat/__tests__/chat-message-streaming-memo.test.tsx +0 -86
- package/src/components/chat/chat-message-enhanced.tsx +13 -28
- package/src/components/chat/chat-message-list.tsx +22 -27
- package/src/components/chat/embeddable-chat.tsx +36 -55
- package/src/components/chat/entity-cards/dispatch.tsx +17 -86
- package/src/components/chat/hooks/use-nats-chat-adapter.ts +0 -7
- package/src/components/chat/hooks/use-slash-commands.ts +5 -9
- package/src/components/chat/hooks/use-sse-chat-adapter.ts +29 -2
- package/src/components/chat/stream/__tests__/chat-stream-reducer.test.ts +0 -56
- package/src/components/chat/stream/chat-stream-reducer.ts +0 -31
- package/src/components/chat/tool-execution-display.tsx +2 -5
- package/src/components/chat/types/component.types.ts +0 -4
- package/src/components/chat/types/message.types.ts +0 -39
- package/src/components/chat/types/unified-chat-state.types.ts +3 -4
- package/src/components/chat/utils/__tests__/process-historical-messages-golden.test.ts +0 -57
- package/src/components/chat/utils/process-historical-messages.ts +1 -19
- package/src/components/navigation/navigation-sidebar-item.tsx +19 -9
- package/src/components/ui/hover-dropdown.tsx +3 -8
- package/dist/chat-protocol/source-metadata.d.ts +0 -5
- package/dist/chat-protocol/source-metadata.d.ts.map +0 -1
- package/dist/chunk-7SMYBCYH.cjs.map +0 -1
- package/dist/chunk-JCWUJHOD.js.map +0 -1
- package/dist/chunk-KSC5LNSY.js.map +0 -1
- package/dist/chunk-PZ27ELFP.cjs.map +0 -1
- package/dist/components/chat/utils/chat-source-metadata.d.ts +0 -5
- package/dist/components/chat/utils/chat-source-metadata.d.ts.map +0 -1
- package/src/chat-protocol/__tests__/source-metadata.test.ts +0 -74
- package/src/chat-protocol/source-metadata.ts +0 -202
- package/src/components/chat/__tests__/embeddable-chat-sources.test.tsx +0 -411
- package/src/components/chat/__tests__/tool-execution-display.test.tsx +0 -93
- package/src/components/chat/entity-cards/__tests__/dispatch-video-refs.test.tsx +0 -74
- package/src/components/chat/hooks/__tests__/use-slash-commands.test.ts +0 -64
- package/src/components/chat/utils/chat-source-metadata.ts +0 -19
- /package/dist/{chunk-23VBGHBL.js.map → chunk-3ELW4VML.js.map} +0 -0
- /package/dist/{chunk-73XDYWYG.js.map → chunk-4T5KOD3G.js.map} +0 -0
- /package/dist/{chunk-MI6PPL3P.js.map → chunk-5CJKZHWO.js.map} +0 -0
- /package/dist/{chunk-E7Q24T4G.js.map → chunk-6BJYPG2V.js.map} +0 -0
- /package/dist/{chunk-7DEGEI7G.js.map → chunk-EJKEDCTH.js.map} +0 -0
- /package/dist/{chunk-AWAHYAII.js.map → chunk-JVWRMLQZ.js.map} +0 -0
- /package/dist/{chunk-PISJGXXI.js.map → chunk-KP6VJP36.js.map} +0 -0
- /package/dist/{chunk-NSDZAUJK.js.map → chunk-LNKULR4V.js.map} +0 -0
- /package/dist/{chunk-5VHCSN44.js.map → chunk-MYEG5ZDT.js.map} +0 -0
- /package/dist/{chunk-M4IIK3B7.js.map → chunk-RURZ6QLN.js.map} +0 -0
- /package/dist/{chunk-TCEU6DCF.js.map → chunk-TLKHLGAB.js.map} +0 -0
- /package/dist/{chunk-GYJVLFK5.js.map → chunk-VZSTL5VG.js.map} +0 -0
- /package/dist/{chunk-3CAC3AAE.js.map → chunk-XPJKQ63S.js.map} +0 -0
- /package/dist/{chunk-22DWXIV3.js.map → chunk-YFZDIEVC.js.map} +0 -0
|
@@ -284,8 +284,6 @@ function createSseFrameDecoder() {
|
|
|
284
284
|
var MESSAGE_TYPE = {
|
|
285
285
|
TEXT: "TEXT",
|
|
286
286
|
THINKING: "THINKING",
|
|
287
|
-
GUIDE: "GUIDE",
|
|
288
|
-
SOURCES: "SOURCES",
|
|
289
287
|
ASK: "ASK",
|
|
290
288
|
EXECUTING_TOOL: "EXECUTING_TOOL",
|
|
291
289
|
EXECUTED_TOOL: "EXECUTED_TOOL",
|
|
@@ -307,187 +305,6 @@ var MESSAGE_TYPE = {
|
|
|
307
305
|
DIALOG_CLOSED: "DIALOG_CLOSED"
|
|
308
306
|
};
|
|
309
307
|
|
|
310
|
-
// src/chat-protocol/source-metadata.ts
|
|
311
|
-
var CARD_REFERENCE = /^\[card:\/\/([a-zA-Z0-9_-]+):([a-zA-Z0-9_-]+)\]$/;
|
|
312
|
-
var SOURCE_METADATA_MATCHED = "sourceMetadataMatched";
|
|
313
|
-
function requiredString(value) {
|
|
314
|
-
if (typeof value !== "string") return null;
|
|
315
|
-
const normalized = value.trim();
|
|
316
|
-
return normalized ? normalized : null;
|
|
317
|
-
}
|
|
318
|
-
function optionalString(value) {
|
|
319
|
-
return requiredString(value) ?? void 0;
|
|
320
|
-
}
|
|
321
|
-
function httpsUrl(value) {
|
|
322
|
-
const candidate = optionalString(value);
|
|
323
|
-
if (!candidate) return void 0;
|
|
324
|
-
try {
|
|
325
|
-
return new URL(candidate).protocol === "https:" ? candidate : void 0;
|
|
326
|
-
} catch {
|
|
327
|
-
return void 0;
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
function youtubeId(value) {
|
|
331
|
-
const candidate = optionalString(value);
|
|
332
|
-
if (!candidate) return void 0;
|
|
333
|
-
if (/^[A-Za-z0-9_-]{11}$/.test(candidate)) return candidate;
|
|
334
|
-
const url = httpsUrl(candidate);
|
|
335
|
-
if (!url) return void 0;
|
|
336
|
-
const parsed = new URL(url);
|
|
337
|
-
const hostname = parsed.hostname.toLowerCase();
|
|
338
|
-
const youtubeHost = hostname === "youtu.be" || hostname === "youtube.com" || hostname.endsWith(".youtube.com");
|
|
339
|
-
if (!youtubeHost) return void 0;
|
|
340
|
-
const pathId = hostname === "youtu.be" ? parsed.pathname.split("/").filter(Boolean)[0] : parsed.pathname.match(/^\/(?:embed|v|shorts)\/([A-Za-z0-9_-]{11})(?:\/|$)/)?.[1];
|
|
341
|
-
const id = pathId ?? parsed.searchParams.get("v") ?? void 0;
|
|
342
|
-
return id && /^[A-Za-z0-9_-]{11}$/.test(id) ? id : void 0;
|
|
343
|
-
}
|
|
344
|
-
function nullableString(value) {
|
|
345
|
-
return value === null ? null : optionalString(value);
|
|
346
|
-
}
|
|
347
|
-
function normalizeSourceItems(value) {
|
|
348
|
-
if (!Array.isArray(value)) return void 0;
|
|
349
|
-
const items = value.flatMap((candidate) => {
|
|
350
|
-
if (!candidate || typeof candidate !== "object" || Array.isArray(candidate)) return [];
|
|
351
|
-
const item = candidate;
|
|
352
|
-
const id = requiredString(item.id);
|
|
353
|
-
const documentType = requiredString(item.documentType);
|
|
354
|
-
const name = requiredString(item.name);
|
|
355
|
-
if (!id || !documentType || !name) return [];
|
|
356
|
-
const externalUrl = httpsUrl(item.externalUrl);
|
|
357
|
-
const targetPlatform = nullableString(item.targetPlatform);
|
|
358
|
-
const path = nullableString(item.path);
|
|
359
|
-
return [
|
|
360
|
-
{
|
|
361
|
-
id,
|
|
362
|
-
documentType,
|
|
363
|
-
name,
|
|
364
|
-
...externalUrl ? { externalUrl } : {},
|
|
365
|
-
...targetPlatform !== void 0 ? { targetPlatform } : {},
|
|
366
|
-
...path !== void 0 ? { path } : {}
|
|
367
|
-
}
|
|
368
|
-
];
|
|
369
|
-
});
|
|
370
|
-
return items.length > 0 ? items : void 0;
|
|
371
|
-
}
|
|
372
|
-
function normalizeSources(value) {
|
|
373
|
-
if (!Array.isArray(value)) return [];
|
|
374
|
-
const seen = /* @__PURE__ */ new Set();
|
|
375
|
-
const sources = [];
|
|
376
|
-
for (const candidate of value) {
|
|
377
|
-
if (!candidate || typeof candidate !== "object" || Array.isArray(candidate)) continue;
|
|
378
|
-
const source = candidate;
|
|
379
|
-
const index = source.index;
|
|
380
|
-
const name = requiredString(source.name);
|
|
381
|
-
const path = requiredString(source.path);
|
|
382
|
-
const documentType = requiredString(source.documentType);
|
|
383
|
-
const validIndex = typeof index === "number" && Number.isFinite(index) && Number.isInteger(index) && index > 0 && !seen.has(index);
|
|
384
|
-
if (!validIndex || !name || !path || !documentType) continue;
|
|
385
|
-
seen.add(index);
|
|
386
|
-
const externalUrl = httpsUrl(source.externalUrl);
|
|
387
|
-
const targetPlatform = nullableString(source.targetPlatform);
|
|
388
|
-
const id = optionalString(source.id);
|
|
389
|
-
const sourceRepo = optionalString(source.sourceRepo);
|
|
390
|
-
const label = optionalString(source.label);
|
|
391
|
-
const items = normalizeSourceItems(source.items);
|
|
392
|
-
sources.push({
|
|
393
|
-
index,
|
|
394
|
-
name,
|
|
395
|
-
path,
|
|
396
|
-
documentType,
|
|
397
|
-
...externalUrl ? { externalUrl } : {},
|
|
398
|
-
...targetPlatform !== void 0 ? { targetPlatform } : {},
|
|
399
|
-
...id ? { id } : {},
|
|
400
|
-
...sourceRepo ? { sourceRepo } : {},
|
|
401
|
-
...label ? { label } : {},
|
|
402
|
-
...items ? { items } : {}
|
|
403
|
-
});
|
|
404
|
-
}
|
|
405
|
-
return sources;
|
|
406
|
-
}
|
|
407
|
-
function normalizeVideoMetadata(value) {
|
|
408
|
-
if (!value || typeof value !== "object" || Array.isArray(value)) return {};
|
|
409
|
-
const input = value;
|
|
410
|
-
const metadata = {};
|
|
411
|
-
for (const key of ["videoUrl", "highlightVideoUrl", "videoPoster", "highlightVideoPoster"]) {
|
|
412
|
-
const url = httpsUrl(input[key]);
|
|
413
|
-
if (url) metadata[key] = url;
|
|
414
|
-
}
|
|
415
|
-
const id = youtubeId(input.youtubeUrl);
|
|
416
|
-
if (id) metadata.youtubeUrl = id;
|
|
417
|
-
return metadata;
|
|
418
|
-
}
|
|
419
|
-
function normalizeVideos(value) {
|
|
420
|
-
if (!Array.isArray(value)) return [];
|
|
421
|
-
return value.flatMap((candidate) => {
|
|
422
|
-
if (!candidate || typeof candidate !== "object" || Array.isArray(candidate)) return [];
|
|
423
|
-
const video = candidate;
|
|
424
|
-
const match = typeof video.ref === "string" ? CARD_REFERENCE.exec(video.ref) : null;
|
|
425
|
-
if (!match || match[1] !== "video") return [];
|
|
426
|
-
const id = match[2];
|
|
427
|
-
const title = optionalString(video.title) ?? id;
|
|
428
|
-
const url = httpsUrl(video.url) ?? null;
|
|
429
|
-
const sourceRepo = optionalString(video.sourceRepo);
|
|
430
|
-
const metadata = normalizeVideoMetadata(video.metadata);
|
|
431
|
-
if (url) {
|
|
432
|
-
const idFromUrl = youtubeId(url);
|
|
433
|
-
if (idFromUrl) {
|
|
434
|
-
metadata.youtubeUrl = idFromUrl;
|
|
435
|
-
delete metadata.videoUrl;
|
|
436
|
-
} else {
|
|
437
|
-
metadata.videoUrl = url;
|
|
438
|
-
delete metadata.youtubeUrl;
|
|
439
|
-
}
|
|
440
|
-
}
|
|
441
|
-
return [
|
|
442
|
-
{
|
|
443
|
-
type: "video",
|
|
444
|
-
id,
|
|
445
|
-
title,
|
|
446
|
-
url,
|
|
447
|
-
...sourceRepo ? { sourceRepo } : {},
|
|
448
|
-
...Object.keys(metadata).length > 0 ? { metadata } : {}
|
|
449
|
-
}
|
|
450
|
-
];
|
|
451
|
-
});
|
|
452
|
-
}
|
|
453
|
-
function normalizeCards(value, sources) {
|
|
454
|
-
if (!Array.isArray(value)) return [];
|
|
455
|
-
return value.flatMap((candidate) => {
|
|
456
|
-
if (!candidate || typeof candidate !== "object" || Array.isArray(candidate)) return [];
|
|
457
|
-
const card = candidate;
|
|
458
|
-
const match = typeof card.ref === "string" ? CARD_REFERENCE.exec(card.ref) : null;
|
|
459
|
-
if (!match || match[1] === "video") return [];
|
|
460
|
-
const type = requiredString(card.entityType);
|
|
461
|
-
const id = requiredString(card.entityId);
|
|
462
|
-
if (!type || !id || type !== match[1] || id !== match[2]) return [];
|
|
463
|
-
const source = sources.find((item) => item.id === id && item.documentType === type);
|
|
464
|
-
const ref = {
|
|
465
|
-
type,
|
|
466
|
-
id,
|
|
467
|
-
title: source?.name ?? id,
|
|
468
|
-
url: source?.externalUrl ?? null,
|
|
469
|
-
...source?.sourceRepo ? { sourceRepo: source.sourceRepo } : {},
|
|
470
|
-
...source?.targetPlatform !== void 0 ? { targetPlatform: source.targetPlatform } : {},
|
|
471
|
-
...source?.path ? { metadata: { path: source.path, [SOURCE_METADATA_MATCHED]: true } } : {}
|
|
472
|
-
};
|
|
473
|
-
return [ref];
|
|
474
|
-
});
|
|
475
|
-
}
|
|
476
|
-
function sourceMetadataEvent(payload) {
|
|
477
|
-
if (!payload || typeof payload !== "object" || Array.isArray(payload)) return null;
|
|
478
|
-
const metadata = payload;
|
|
479
|
-
const sources = normalizeSources(metadata.sources);
|
|
480
|
-
const refs = [...normalizeVideos(metadata.videos), ...normalizeCards(metadata.cards, sources)];
|
|
481
|
-
const refsByIdentity = /* @__PURE__ */ new Map();
|
|
482
|
-
refs.forEach((ref) => {
|
|
483
|
-
const identity = `${ref.type}:${ref.id}`;
|
|
484
|
-
if (!refsByIdentity.has(identity)) refsByIdentity.set(identity, ref);
|
|
485
|
-
});
|
|
486
|
-
const uniqueRefs = Array.from(refsByIdentity.values());
|
|
487
|
-
if (sources.length === 0 && uniqueRefs.length === 0) return null;
|
|
488
|
-
return { type: "sources", sources, ...uniqueRefs.length > 0 ? { refs: uniqueRefs } : {} };
|
|
489
|
-
}
|
|
490
|
-
|
|
491
308
|
// src/chat-protocol/nats-decoder.ts
|
|
492
309
|
function isRecord(value) {
|
|
493
310
|
return typeof value === "object" && value !== null;
|
|
@@ -556,11 +373,6 @@ function decodeNatsChunk(chunk) {
|
|
|
556
373
|
return { type: "thinking-delta", text: data.text, ...seq };
|
|
557
374
|
}
|
|
558
375
|
return null;
|
|
559
|
-
case MESSAGE_TYPE.GUIDE:
|
|
560
|
-
case MESSAGE_TYPE.SOURCES: {
|
|
561
|
-
const event = sourceMetadataEvent(data.payload);
|
|
562
|
-
return event ? { ...event, ...seq } : null;
|
|
563
|
-
}
|
|
564
376
|
// An ask card is only an ask card with something to pick: a question and at
|
|
565
377
|
// least one option. Anything less is dropped rather than rendered as an
|
|
566
378
|
// empty card the user can't answer — the backend already falls back to a
|