@hivegpt/hiveai-angular 0.0.434 → 0.0.435

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.
@@ -2292,6 +2292,54 @@
2292
2292
  });
2293
2293
  });
2294
2294
  };
2295
+ /**
2296
+ * Parse get_event_sessions_v2 plain-text content into session objects for cards.
2297
+ * Format: "Found N sessions:\n1. <title>\n - Time: Start: ..., End: ..., TimeZone: ...\n - Room: ...\n - Type: ...\n2. ..."
2298
+ */
2299
+ ChatDrawerComponent.prototype.parseSessionContentV2 = function (content) {
2300
+ if (!content || typeof content !== 'string')
2301
+ return [];
2302
+ var sessions = [];
2303
+ // Split into blocks by "1. ", "2. ", etc. (number + dot + space at line start)
2304
+ var blockRegex = /\n\d+\.\s+/;
2305
+ var parts = content.split(blockRegex);
2306
+ // First part may be "Found N sessions:" or similar; skip if it doesn't look like a session title
2307
+ for (var i = 0; i < parts.length; i++) {
2308
+ var block = parts[i].trim();
2309
+ if (!block)
2310
+ continue;
2311
+ var lines = block.split(/\n/).map(function (l) { return l.trim(); }).filter(Boolean);
2312
+ var title = lines[0] || '';
2313
+ if (!title || /^Found\s+\d+\s+sessions/i.test(title))
2314
+ continue;
2315
+ var dateTimeRange = '';
2316
+ var roomName = '';
2317
+ var sessionType = '';
2318
+ for (var j = 1; j < lines.length; j++) {
2319
+ var line = lines[j];
2320
+ var timeMatch = line.match(/Time:\s*(.+)/i);
2321
+ if (timeMatch) {
2322
+ dateTimeRange = timeMatch[1].trim();
2323
+ }
2324
+ var roomMatch = line.match(/Room:\s*(.+)/i);
2325
+ if (roomMatch) {
2326
+ roomName = roomMatch[1].trim();
2327
+ }
2328
+ var typeMatch = line.match(/Type:\s*(.+)/i);
2329
+ if (typeMatch) {
2330
+ sessionType = typeMatch[1].trim();
2331
+ }
2332
+ }
2333
+ sessions.push({
2334
+ title: title,
2335
+ roomName: roomName || undefined,
2336
+ dateTimeRange: dateTimeRange || undefined,
2337
+ sessionType: sessionType || undefined,
2338
+ sessionRoles: [],
2339
+ });
2340
+ }
2341
+ return sessions;
2342
+ };
2295
2343
  ChatDrawerComponent.prototype.getVisibleSessionCards = function (chat) {
2296
2344
  var _a;
2297
2345
  var list = (_a = chat === null || chat === void 0 ? void 0 : chat.sessionCards) !== null && _a !== void 0 ? _a : [];
@@ -2370,7 +2418,7 @@
2370
2418
  else if ((_k = res === null || res === void 0 ? void 0 : res.m) === null || _k === void 0 ? void 0 : _k.OtherFields) {
2371
2419
  var otherFields = res.m.OtherFields;
2372
2420
  var serializable = otherFields.serializable_to_return;
2373
- // Session cards: get_event_sessions or get_event_sessions_v2 (v2 may send text content; we only show cards when content is JSON with sessions)
2421
+ // Session cards: get_event_sessions (JSON) or get_event_sessions_v2 (JSON or plain text)
2374
2422
  var isSessionTool = (serializable === null || serializable === void 0 ? void 0 : serializable.tool_name) === 'get_event_sessions' ||
2375
2423
  (serializable === null || serializable === void 0 ? void 0 : serializable.tool_name) === 'get_event_sessions_v2';
2376
2424
  if (isSessionTool) {
@@ -2378,33 +2426,35 @@
2378
2426
  var answerText = otherFields.answer != null ? String(otherFields.answer).trim() : '';
2379
2427
  var pushed = false;
2380
2428
  if (contentStr && typeof contentStr === 'string') {
2429
+ var sessions = [];
2381
2430
  try {
2382
2431
  var parsed = JSON.parse(contentStr);
2383
- var sessions = (_p = parsed === null || parsed === void 0 ? void 0 : parsed.sessions) !== null && _p !== void 0 ? _p : [];
2384
- var mapped = _this.mapSessionsToCardData(sessions);
2385
- if (mapped.length > 0) {
2386
- _this.chatLog.push({
2387
- _id: serializable.message_id || "session_cards_" + Date.now(),
2388
- type: 'session_cards',
2389
- message: answerText ? _this.processMessageForDisplay(answerText) : '',
2390
- time: formatNow(_this.timezone),
2391
- sessionCards: mapped,
2392
- });
2393
- _this.showFeedBackIconsIndex = _this.chatLog.length - 1;
2394
- _this.isChatingWithAi = false;
2395
- _this.scrollToBottom();
2396
- pushed = true;
2397
- }
2432
+ sessions = (_p = parsed === null || parsed === void 0 ? void 0 : parsed.sessions) !== null && _p !== void 0 ? _p : [];
2398
2433
  }
2399
2434
  catch (e) {
2400
- // v2 often sends plain text (e.g. "Found 2 sessions:..."); not JSON - fall through so answer is shown as normal AI message
2435
+ // v2 plain text: "Found 2 sessions:\n1. Title\n - Time: Start: ... End: ...\n - Room: ...\n - Type: ..."
2436
+ sessions = _this.parseSessionContentV2(contentStr);
2437
+ }
2438
+ var mapped = _this.mapSessionsToCardData(sessions);
2439
+ if (mapped.length > 0) {
2440
+ _this.chatLog.push({
2441
+ _id: serializable.message_id || "session_cards_" + Date.now(),
2442
+ type: 'session_cards',
2443
+ message: answerText ? _this.processMessageForDisplay(answerText) : '',
2444
+ time: formatNow(_this.timezone),
2445
+ sessionCards: mapped,
2446
+ });
2447
+ _this.showFeedBackIconsIndex = _this.chatLog.length - 1;
2448
+ _this.isChatingWithAi = false;
2449
+ _this.scrollToBottom();
2450
+ pushed = true;
2401
2451
  }
2402
2452
  }
2403
2453
  if (pushed) {
2404
2454
  _this.cdr.markForCheck();
2405
2455
  return;
2406
2456
  }
2407
- // No session cards pushed (v2 text content or empty): fall through to normal OtherFields handling so answer is displayed
2457
+ // No session cards pushed: fall through to normal OtherFields handling so answer is displayed
2408
2458
  }
2409
2459
  // Attendee cards: tool get_event_attendees (same as React Native)
2410
2460
  if ((serializable === null || serializable === void 0 ? void 0 : serializable.tool_name) === 'get_event_attendees') {
@@ -2664,6 +2714,27 @@
2664
2714
  // })
2665
2715
  // );
2666
2716
  // }
2717
+ /** Push a standard AI message from history (sources, graphs, etc.). Used when not converting to session_cards. */
2718
+ ChatDrawerComponent.prototype.pushAiMessageFromHistory = function (chat) {
2719
+ var sourcesList = chat.WebLinks || [];
2720
+ var displayedSources = (chat.WebLinks || []).slice(0, 3);
2721
+ var remainingSources = (chat.WebLinks || []).slice(3);
2722
+ this.chatLog.push({
2723
+ type: 'ai',
2724
+ message: this.processMessageForDisplay(chat.Text),
2725
+ executionGraphs: chat.ExecutionGraphs,
2726
+ graphs: chat.Graphs,
2727
+ searchTerms: chat.SearchTerms,
2728
+ sourcesList: sourcesList,
2729
+ displayedSources: displayedSources,
2730
+ remainingSources: remainingSources,
2731
+ time: formatTimeStamps(this.timezone, chat.InsertTimestamp),
2732
+ copied: false,
2733
+ isCollapsedTrue: false,
2734
+ _id: chat._id,
2735
+ });
2736
+ this.showFeedBackIconsIndex = this.chatLog.length - 1;
2737
+ };
2667
2738
  ChatDrawerComponent.prototype.mapChatHistory = function (chats) {
2668
2739
  var _this = this;
2669
2740
  var _a;
@@ -2674,6 +2745,7 @@
2674
2745
  });
2675
2746
  if (chats && ((_a = chats === null || chats === void 0 ? void 0 : chats.Messages) === null || _a === void 0 ? void 0 : _a.length)) {
2676
2747
  chats === null || chats === void 0 ? void 0 : chats.Messages.forEach(function (chat) {
2748
+ var _a, _b, _c, _d, _e, _f;
2677
2749
  if (chat.Type == 'user') {
2678
2750
  _this.chatLog.push({
2679
2751
  type: 'user',
@@ -2686,24 +2758,37 @@
2686
2758
  });
2687
2759
  }
2688
2760
  if (chat.Type == 'ai') {
2689
- var sourcesList = chat.WebLinks || [];
2690
- var displayedSources = chat.WebLinks.slice(0, 3); // First 3 cards
2691
- var remainingSources = chat.WebLinks.slice(3); // Remaining items
2692
- _this.chatLog.push({
2693
- type: 'ai',
2694
- message: _this.processMessageForDisplay(chat.Text),
2695
- executionGraphs: chat.ExecutionGraphs,
2696
- graphs: chat.Graphs,
2697
- searchTerms: chat.SearchTerms,
2698
- sourcesList: sourcesList,
2699
- displayedSources: displayedSources,
2700
- remainingSources: remainingSources,
2701
- time: formatTimeStamps(_this.timezone, chat.InsertTimestamp),
2702
- copied: false,
2703
- isCollapsedTrue: false,
2704
- _id: chat._id,
2705
- });
2706
- _this.showFeedBackIconsIndex = _this.chatLog.length - 1;
2761
+ // If this AI message came from get_event_sessions / get_event_sessions_v2, show session cards instead of plain text
2762
+ var toolName = (_a = chat.toolresults) === null || _a === void 0 ? void 0 : _a.tool_name;
2763
+ var isSessionTool = toolName === 'get_event_sessions' || toolName === 'get_event_sessions_v2';
2764
+ if (isSessionTool && ((_e = (_d = (_c = (_b = chat.toolresults) === null || _b === void 0 ? void 0 : _b.tool_result) === null || _c === void 0 ? void 0 : _c.messages) === null || _d === void 0 ? void 0 : _d[0]) === null || _e === void 0 ? void 0 : _e.content)) {
2765
+ var contentStr = chat.toolresults.tool_result.messages[0].content;
2766
+ var sessions = [];
2767
+ try {
2768
+ var parsed = JSON.parse(contentStr);
2769
+ sessions = (_f = parsed === null || parsed === void 0 ? void 0 : parsed.sessions) !== null && _f !== void 0 ? _f : [];
2770
+ }
2771
+ catch (e) {
2772
+ sessions = _this.parseSessionContentV2(contentStr);
2773
+ }
2774
+ var mapped = _this.mapSessionsToCardData(sessions);
2775
+ if (mapped.length > 0) {
2776
+ _this.chatLog.push({
2777
+ _id: chat._id,
2778
+ type: 'session_cards',
2779
+ message: chat.Text ? _this.processMessageForDisplay(chat.Text) : '',
2780
+ time: formatTimeStamps(_this.timezone, chat.InsertTimestamp),
2781
+ sessionCards: mapped,
2782
+ });
2783
+ _this.showFeedBackIconsIndex = _this.chatLog.length - 1;
2784
+ }
2785
+ else {
2786
+ _this.pushAiMessageFromHistory(chat);
2787
+ }
2788
+ }
2789
+ else {
2790
+ _this.pushAiMessageFromHistory(chat);
2791
+ }
2707
2792
  }
2708
2793
  });
2709
2794
  this.showStartAgain = true;