@adecore/agents-react 0.48.1 → 0.48.3

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.
@@ -69,6 +69,7 @@ export type TimelineRow = {
69
69
  level: 'info' | 'warning' | 'error';
70
70
  text: string;
71
71
  from?: string;
72
+ said?: true;
72
73
  } | {
73
74
  kind: 'message';
74
75
  id: string;
@@ -257,49 +257,33 @@ function flushTools(buffer, rows, options) {
257
257
  return;
258
258
  }
259
259
  const tools = buffer.splice(0);
260
- const live = tools.filter(tool => tool.state === 'running');
261
- const settled = tools.filter(tool => tool.state !== 'running');
262
- if (settled.length === 1) {
263
- rows.push({
264
- kind: 'work',
265
- id: settled[0].id,
266
- tool: settled[0]
267
- });
268
- } else if (settled.length > 1) {
269
- const id = `group-${settled[0].id}`;
270
- const expanded = options.expandedGroups.has(id);
271
- const looked = lookSummary(settled, options.commandLooks);
272
- rows.push(looked === null ? {
273
- kind: 'work-group',
274
- id,
275
- tools: settled,
276
- summary: summarizeGroup(settled),
277
- expanded
278
- } : {
279
- kind: 'work-group',
280
- id,
281
- tools: settled,
282
- summary: looked.summary,
283
- expanded,
284
- look: looked.look
285
- });
286
- if (expanded) {
287
- for (const tool of settled) {
288
- rows.push({
289
- kind: 'work',
290
- id: tool.id,
291
- tool
292
- });
293
- }
260
+ const first = tools[0];
261
+ const id = `group-${first.id}`;
262
+ const expanded = options.expandedGroups.has(id);
263
+ const looked = lookSummary(tools, options.commandLooks);
264
+ rows.push(looked === null ? {
265
+ kind: 'work-group',
266
+ id,
267
+ tools,
268
+ summary: summarizeGroup(tools),
269
+ expanded
270
+ } : {
271
+ kind: 'work-group',
272
+ id,
273
+ tools,
274
+ summary: looked.summary,
275
+ expanded,
276
+ look: looked.look
277
+ });
278
+ if (expanded) {
279
+ for (const tool of tools) {
280
+ rows.push({
281
+ kind: tool.state === 'running' ? 'work-live' : 'work',
282
+ id: tool.id,
283
+ tool
284
+ });
294
285
  }
295
286
  }
296
- for (const tool of live) {
297
- rows.push({
298
- kind: 'work-live',
299
- id: tool.id,
300
- tool
301
- });
302
- }
303
287
  }
304
288
  function isImageRow(row) {
305
289
  return (row.kind === 'work' || row.kind === 'work-live') && isImageGeneration(row.tool);
@@ -411,6 +395,9 @@ function rowsForItems(items, options, children) {
411
395
  text: item.text,
412
396
  ...(item.from === undefined ? {} : {
413
397
  from: item.from
398
+ }),
399
+ ...(item.said === undefined ? {} : {
400
+ said: item.said
414
401
  })
415
402
  });
416
403
  }
@@ -471,7 +458,7 @@ function lastAssistantRow(rows) {
471
458
  refused.add(row.item.toolUseId);
472
459
  continue;
473
460
  }
474
- if (row.kind === 'work' && refused.has(row.tool.toolUseId)) {
461
+ if (row.kind === 'work' && refused.has(row.tool.toolUseId) || row.kind === 'work-group' && row.tools.length === 1 && refused.has(row.tools[0].toolUseId)) {
475
462
  continue;
476
463
  }
477
464
  if (row.kind !== 'note' && !isImageRow(row)) {
@@ -493,7 +480,8 @@ function withLiveThought(rows, items) {
493
480
  return rows;
494
481
  }
495
482
  const after = new Set(items.slice(thoughtAt + 1).map(item => item.id));
496
- const index = rows.findIndex(row => row.kind === 'work-live' && after.has(row.tool.id));
483
+ const grouped = new Set(rows.flatMap(row => row.kind === 'work-group' ? row.tools.map(tool => tool.id) : []));
484
+ const index = rows.findIndex(row => row.kind === 'work-live' && after.has(row.tool.id) && !grouped.has(row.tool.id));
497
485
  const call = rows[index];
498
486
  const shownAt = rows.findIndex(row => row.kind === 'thinking' && row.id === thought.id);
499
487
  const inSight = shownAt !== -1 && shownAt < index && !rows.slice(shownAt + 1, index).some(row => row.kind === 'work' || row.kind === 'work-group');
@@ -28,11 +28,12 @@ export declare function LiveThoughtRow({ chatId, item: derived }: {
28
28
  chatId: string;
29
29
  item: ChatThinkingItem;
30
30
  }): import("react").JSX.Element | null;
31
- export declare function NoteRow({ id, level, text, from }: {
31
+ export declare function NoteRow({ id, level, text, from, said }: {
32
32
  id: string;
33
33
  level: 'info' | 'warning' | 'error';
34
34
  text: string;
35
35
  from?: string;
36
+ said?: true;
36
37
  }): import("react").JSX.Element;
37
38
  export declare function AgentTurnRow({ label, onOpen }: {
38
39
  label: string;
@@ -28,7 +28,9 @@ import { ROW_GUTTER } from '../icons.js';
28
28
  import { useOpenForFind } from '../find-reveal.js';
29
29
  import { ReplyContext, UiReplyNavigationContext } from '../reply-context.js';
30
30
  import { UiReply } from '../intelligent-ui/UiReply.js';
31
+ import { useChatHost } from '../../../host.js';
31
32
  import { useHostAttachmentUrl, useHostChatPlace, useHostReplyAuthor, useHostStreaming } from '../../../host-hooks.js';
33
+ import { REFERENCE_TONE, TOKEN_IN_MESSAGE } from '../chips.js';
32
34
  import { copySelectionWithChips } from '../chip-clipboard.js';
33
35
  import { useReferenceLookup } from '../thread-references.js';
34
36
  // A long prompt folds so the answer stays in view; the reader can open it.
@@ -444,7 +446,7 @@ function _temp(e) {
444
446
  return copySelectionWithChips(e.nativeEvent);
445
447
  }
446
448
  export function SentMessageRow(t0) {
447
- const $ = _c(32);
449
+ const $ = _c(14);
448
450
  const {
449
451
  chatId,
450
452
  id,
@@ -453,24 +455,152 @@ export function SentMessageRow(t0) {
453
455
  const {
454
456
  t
455
457
  } = useTranslation("agent-chat");
458
+ const lookup = useReferenceLookup(chatId);
459
+ let t1;
460
+ if ($[0] !== message.title || $[1] !== t) {
461
+ t1 = message.title || t("rows.message.unnamed");
462
+ $[0] = message.title;
463
+ $[1] = t;
464
+ $[2] = t1;
465
+ } else {
466
+ t1 = $[2];
467
+ }
468
+ let t2;
469
+ if ($[3] !== message.from || $[4] !== message.title) {
470
+ t2 = /*#__PURE__*/_jsx(ReferenceChip, {
471
+ id: message.from,
472
+ lastName: message.title
473
+ });
474
+ $[3] = message.from;
475
+ $[4] = message.title;
476
+ $[5] = t2;
477
+ } else {
478
+ t2 = $[5];
479
+ }
480
+ let t3;
481
+ if ($[6] !== id || $[7] !== message.text || $[8] !== t1 || $[9] !== t2) {
482
+ t3 = /*#__PURE__*/_jsx(SaidMessage, {
483
+ id: id,
484
+ name: t1,
485
+ chip: t2,
486
+ text: message.text
487
+ });
488
+ $[6] = id;
489
+ $[7] = message.text;
490
+ $[8] = t1;
491
+ $[9] = t2;
492
+ $[10] = t3;
493
+ } else {
494
+ t3 = $[10];
495
+ }
496
+ let t4;
497
+ if ($[11] !== lookup || $[12] !== t3) {
498
+ t4 = /*#__PURE__*/_jsx(ReferenceLookupContext, {
499
+ value: lookup,
500
+ children: t3
501
+ });
502
+ $[11] = lookup;
503
+ $[12] = t3;
504
+ $[13] = t4;
505
+ } else {
506
+ t4 = $[13];
507
+ }
508
+ return t4;
509
+ }
510
+ /* What the host told the agent in front of a prompt, said under the host's own name, which the text no longer has to lead with. */
511
+ function HostSaidRow(t0) {
512
+ const $ = _c(14);
513
+ const {
514
+ id,
515
+ text,
516
+ author
517
+ } = t0;
518
+ const prefix = `${author.name}: `;
519
+ let t1;
520
+ if ($[0] !== prefix || $[1] !== text) {
521
+ let t2;
522
+ if ($[3] !== prefix) {
523
+ t2 = part => part.startsWith(prefix) ? part.slice(prefix.length) : part;
524
+ $[3] = prefix;
525
+ $[4] = t2;
526
+ } else {
527
+ t2 = $[4];
528
+ }
529
+ t1 = text.split("\n\n").map(t2).join("\n\n");
530
+ $[0] = prefix;
531
+ $[1] = text;
532
+ $[2] = t1;
533
+ } else {
534
+ t1 = $[2];
535
+ }
536
+ const words = t1;
537
+ const t2 = author.name;
538
+ let t3;
539
+ if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
540
+ t3 = clsx(TOKEN_IN_MESSAGE, REFERENCE_TONE, "inline-flex items-center gap-1");
541
+ $[5] = t3;
542
+ } else {
543
+ t3 = $[5];
544
+ }
545
+ let t4;
546
+ if ($[6] !== author.mark || $[7] !== author.name) {
547
+ t4 = /*#__PURE__*/_jsxs("span", {
548
+ className: t3,
549
+ children: [author.mark, author.name]
550
+ });
551
+ $[6] = author.mark;
552
+ $[7] = author.name;
553
+ $[8] = t4;
554
+ } else {
555
+ t4 = $[8];
556
+ }
557
+ let t5;
558
+ if ($[9] !== author.name || $[10] !== id || $[11] !== t4 || $[12] !== words) {
559
+ t5 = /*#__PURE__*/_jsx(SaidMessage, {
560
+ id: id,
561
+ name: t2,
562
+ chip: t4,
563
+ text: words
564
+ });
565
+ $[9] = author.name;
566
+ $[10] = id;
567
+ $[11] = t4;
568
+ $[12] = words;
569
+ $[13] = t5;
570
+ } else {
571
+ t5 = $[13];
572
+ }
573
+ return t5;
574
+ }
575
+ /* A message the person did not write: a bubble on the left, quieter than theirs, under a chip of who said it. A long one folds. */
576
+ function SaidMessage(t0) {
577
+ const $ = _c(28);
578
+ const {
579
+ id,
580
+ name,
581
+ chip,
582
+ text
583
+ } = t0;
584
+ const {
585
+ t
586
+ } = useTranslation("agent-chat");
456
587
  const [open, setOpen] = useState(false);
457
588
  let t1;
458
- if ($[0] !== message.text) {
459
- t1 = message.text.split("\n").length > USER_FOLD_LINES || message.text.length > USER_FOLD_CHARS;
460
- $[0] = message.text;
589
+ if ($[0] !== text) {
590
+ t1 = text.split("\n").length > USER_FOLD_LINES || text.length > USER_FOLD_CHARS;
591
+ $[0] = text;
461
592
  $[1] = t1;
462
593
  } else {
463
594
  t1 = $[1];
464
595
  }
465
596
  const long = t1;
466
- const lookup = useReferenceLookup(chatId);
467
597
  useOpenForFind(id, "text", setOpen);
468
598
  let t2;
469
- if ($[2] !== message.title || $[3] !== t) {
599
+ if ($[2] !== name || $[3] !== t) {
470
600
  t2 = t("rows.message.heading", {
471
- name: message.title || t("rows.message.unnamed")
601
+ name
472
602
  });
473
- $[2] = message.title;
603
+ $[2] = name;
474
604
  $[3] = t;
475
605
  $[4] = t2;
476
606
  } else {
@@ -487,54 +617,50 @@ export function SentMessageRow(t0) {
487
617
  t3 = $[6];
488
618
  }
489
619
  let t4;
490
- if ($[7] !== message.from || $[8] !== message.title) {
620
+ if ($[7] !== chip) {
491
621
  t4 = /*#__PURE__*/_jsx("div", {
492
622
  className: "mb-1.5 flex max-w-[80%]",
493
- children: /*#__PURE__*/_jsx(ReferenceChip, {
494
- id: message.from,
495
- lastName: message.title
496
- })
623
+ children: chip
497
624
  });
498
- $[7] = message.from;
499
- $[8] = message.title;
500
- $[9] = t4;
625
+ $[7] = chip;
626
+ $[8] = t4;
501
627
  } else {
502
- t4 = $[9];
628
+ t4 = $[8];
503
629
  }
504
630
  const t5 = long && !open && FOLD;
505
631
  let t6;
506
- if ($[10] !== t5) {
632
+ if ($[9] !== t5) {
507
633
  t6 = clsx(t5);
508
- $[10] = t5;
509
- $[11] = t6;
634
+ $[9] = t5;
635
+ $[10] = t6;
510
636
  } else {
511
- t6 = $[11];
637
+ t6 = $[10];
512
638
  }
513
639
  let t7;
514
- if ($[12] !== message.text) {
640
+ if ($[11] !== text) {
515
641
  t7 = /*#__PURE__*/_jsx(MessageMarkdown, {
516
- text: message.text
642
+ text: text
517
643
  });
518
- $[12] = message.text;
519
- $[13] = t7;
644
+ $[11] = text;
645
+ $[12] = t7;
520
646
  } else {
521
- t7 = $[13];
647
+ t7 = $[12];
522
648
  }
523
649
  let t8;
524
- if ($[14] !== t6 || $[15] !== t7) {
650
+ if ($[13] !== t6 || $[14] !== t7) {
525
651
  t8 = /*#__PURE__*/_jsx("div", {
526
652
  "data-find-field": "text",
527
653
  className: t6,
528
654
  children: t7
529
655
  });
530
- $[14] = t6;
531
- $[15] = t7;
532
- $[16] = t8;
656
+ $[13] = t6;
657
+ $[14] = t7;
658
+ $[15] = t8;
533
659
  } else {
534
- t8 = $[16];
660
+ t8 = $[15];
535
661
  }
536
662
  let t9;
537
- if ($[17] !== long || $[18] !== open || $[19] !== t) {
663
+ if ($[16] !== long || $[17] !== open || $[18] !== t) {
538
664
  t9 = long && /*#__PURE__*/_jsxs("button", {
539
665
  className: "mt-1 flex items-center gap-1 text-xs text-text-muted hover:text-text",
540
666
  onClick: () => setOpen(_temp4),
@@ -544,53 +670,41 @@ export function SentMessageRow(t0) {
544
670
  className: clsx("transition-transform", open && "rotate-180")
545
671
  }), " ", open ? t("rows.user.showLess") : t("rows.user.showAll")]
546
672
  });
547
- $[17] = long;
548
- $[18] = open;
549
- $[19] = t;
550
- $[20] = t9;
673
+ $[16] = long;
674
+ $[17] = open;
675
+ $[18] = t;
676
+ $[19] = t9;
551
677
  } else {
552
- t9 = $[20];
678
+ t9 = $[19];
553
679
  }
554
680
  let t10;
555
- if ($[21] !== t8 || $[22] !== t9) {
681
+ if ($[20] !== t8 || $[21] !== t9) {
556
682
  t10 = /*#__PURE__*/_jsxs("div", {
557
683
  className: "relative max-w-[80%] rounded-2xl bg-surface-hover px-3.5 py-2.5 text-sm wrap-anywhere text-text select-text",
558
684
  children: [t8, t9]
559
685
  });
560
- $[21] = t8;
561
- $[22] = t9;
562
- $[23] = t10;
686
+ $[20] = t8;
687
+ $[21] = t9;
688
+ $[22] = t10;
563
689
  } else {
564
- t10 = $[23];
690
+ t10 = $[22];
565
691
  }
566
692
  let t11;
567
- if ($[24] !== id || $[25] !== t10 || $[26] !== t3 || $[27] !== t4) {
693
+ if ($[23] !== id || $[24] !== t10 || $[25] !== t3 || $[26] !== t4) {
568
694
  t11 = /*#__PURE__*/_jsxs("div", {
569
695
  "data-find-item": id,
570
696
  className: "flex flex-col items-start",
571
697
  children: [t3, t4, t10]
572
698
  });
573
- $[24] = id;
574
- $[25] = t10;
575
- $[26] = t3;
576
- $[27] = t4;
577
- $[28] = t11;
578
- } else {
579
- t11 = $[28];
580
- }
581
- let t12;
582
- if ($[29] !== lookup || $[30] !== t11) {
583
- t12 = /*#__PURE__*/_jsx(ReferenceLookupContext, {
584
- value: lookup,
585
- children: t11
586
- });
587
- $[29] = lookup;
588
- $[30] = t11;
589
- $[31] = t12;
699
+ $[23] = id;
700
+ $[24] = t10;
701
+ $[25] = t3;
702
+ $[26] = t4;
703
+ $[27] = t11;
590
704
  } else {
591
- t12 = $[31];
705
+ t11 = $[27];
592
706
  }
593
- return t12;
707
+ return t11;
594
708
  }
595
709
  /*
596
710
  * The choice a message answers. The label stays out of the message, which holds exactly what the agent
@@ -1473,6 +1587,53 @@ const NOTE_ICON = {
1473
1587
  * shows its first line and folds the rest open as markdown; one that came from a fork leads to it.
1474
1588
  */
1475
1589
  export function NoteRow(t0) {
1590
+ const $ = _c(9);
1591
+ const {
1592
+ id,
1593
+ level,
1594
+ text,
1595
+ from,
1596
+ said
1597
+ } = t0;
1598
+ const {
1599
+ saidBy
1600
+ } = useChatHost();
1601
+ if (said && saidBy !== undefined) {
1602
+ let t1;
1603
+ if ($[0] !== id || $[1] !== saidBy || $[2] !== text) {
1604
+ t1 = /*#__PURE__*/_jsx(HostSaidRow, {
1605
+ id: id,
1606
+ text: text,
1607
+ author: saidBy
1608
+ });
1609
+ $[0] = id;
1610
+ $[1] = saidBy;
1611
+ $[2] = text;
1612
+ $[3] = t1;
1613
+ } else {
1614
+ t1 = $[3];
1615
+ }
1616
+ return t1;
1617
+ }
1618
+ let t1;
1619
+ if ($[4] !== from || $[5] !== id || $[6] !== level || $[7] !== text) {
1620
+ t1 = /*#__PURE__*/_jsx(NoteLine, {
1621
+ id: id,
1622
+ level: level,
1623
+ text: text,
1624
+ from: from
1625
+ });
1626
+ $[4] = from;
1627
+ $[5] = id;
1628
+ $[6] = level;
1629
+ $[7] = text;
1630
+ $[8] = t1;
1631
+ } else {
1632
+ t1 = $[8];
1633
+ }
1634
+ return t1;
1635
+ }
1636
+ function NoteLine(t0) {
1476
1637
  const $ = _c(34);
1477
1638
  const {
1478
1639
  id,
@@ -70,7 +70,7 @@ function AppCardRow(t0) {
70
70
  }
71
71
  /* One row of a thread, the chat's own or a subagent's read back, drawn the same way in both. */
72
72
  export function Row(t0) {
73
- const $ = _c(89);
73
+ const $ = _c(90);
74
74
  const {
75
75
  row,
76
76
  chatId,
@@ -403,96 +403,98 @@ export function Row(t0) {
403
403
  case "note":
404
404
  {
405
405
  let t1;
406
- if ($[71] !== row.from || $[72] !== row.id || $[73] !== row.level || $[74] !== row.text) {
406
+ if ($[71] !== row.from || $[72] !== row.id || $[73] !== row.level || $[74] !== row.said || $[75] !== row.text) {
407
407
  t1 = /*#__PURE__*/_jsx(NoteRow, {
408
408
  id: row.id,
409
409
  level: row.level,
410
410
  text: row.text,
411
- from: row.from
411
+ from: row.from,
412
+ said: row.said
412
413
  });
413
414
  $[71] = row.from;
414
415
  $[72] = row.id;
415
416
  $[73] = row.level;
416
- $[74] = row.text;
417
- $[75] = t1;
417
+ $[74] = row.said;
418
+ $[75] = row.text;
419
+ $[76] = t1;
418
420
  } else {
419
- t1 = $[75];
421
+ t1 = $[76];
420
422
  }
421
423
  return t1;
422
424
  }
423
425
  case "message":
424
426
  {
425
427
  let t1;
426
- if ($[76] !== chatId || $[77] !== row.id || $[78] !== row.message) {
428
+ if ($[77] !== chatId || $[78] !== row.id || $[79] !== row.message) {
427
429
  t1 = /*#__PURE__*/_jsx(SentMessageRow, {
428
430
  chatId: chatId,
429
431
  id: row.id,
430
432
  message: row.message
431
433
  });
432
- $[76] = chatId;
433
- $[77] = row.id;
434
- $[78] = row.message;
435
- $[79] = t1;
434
+ $[77] = chatId;
435
+ $[78] = row.id;
436
+ $[79] = row.message;
437
+ $[80] = t1;
436
438
  } else {
437
- t1 = $[79];
439
+ t1 = $[80];
438
440
  }
439
441
  return t1;
440
442
  }
441
443
  case "compaction":
442
444
  {
443
445
  let t1;
444
- if ($[80] !== row.preTokens) {
446
+ if ($[81] !== row.preTokens) {
445
447
  t1 = /*#__PURE__*/_jsx(CompactionRow, {
446
448
  preTokens: row.preTokens
447
449
  });
448
- $[80] = row.preTokens;
449
- $[81] = t1;
450
+ $[81] = row.preTokens;
451
+ $[82] = t1;
450
452
  } else {
451
- t1 = $[81];
453
+ t1 = $[82];
452
454
  }
453
455
  return t1;
454
456
  }
455
457
  case "working":
456
458
  {
457
459
  let t1;
458
- if ($[82] !== row.startedAt) {
460
+ if ($[83] !== row.startedAt) {
459
461
  t1 = /*#__PURE__*/_jsx(WorkingRow, {
460
462
  startedAt: row.startedAt
461
463
  });
462
- $[82] = row.startedAt;
463
- $[83] = t1;
464
+ $[83] = row.startedAt;
465
+ $[84] = t1;
464
466
  } else {
465
- t1 = $[83];
467
+ t1 = $[84];
466
468
  }
467
469
  return t1;
468
470
  }
469
471
  case "app-card":
470
472
  {
471
473
  let t1;
472
- if ($[84] !== row.card) {
474
+ if ($[85] !== row.card) {
473
475
  t1 = /*#__PURE__*/_jsx(AppCardRow, {
474
476
  card: row.card
475
477
  });
476
- $[84] = row.card;
477
- $[85] = t1;
478
+ $[85] = row.card;
479
+ $[86] = t1;
478
480
  } else {
479
- t1 = $[85];
481
+ t1 = $[86];
480
482
  }
481
483
  return t1;
482
484
  }
483
485
  case "visual":
484
486
  {
485
487
  let t1;
486
- if ($[86] !== chatId || $[87] !== row.visual) {
488
+ if ($[87] !== chatId || $[88] !== row.visual) {
487
489
  t1 = /*#__PURE__*/_jsx(VisualRow, {
488
490
  chatId: chatId,
489
491
  visual: row.visual
490
492
  });
491
- $[86] = chatId;
492
- $[87] = row.visual;
493
- $[88] = t1;
493
+ $[87] = chatId;
494
+ $[88] = row.visual;
495
+ $[89] = t1;
494
496
  } else {
495
- t1 = $[88];
497
+ t1 = $[89];
496
498
  }
497
499
  return t1;
498
500
  }