@adecore/agents-react 0.74.1 → 0.75.1

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 (53) hide show
  1. package/dist/chat/logic/timeline.js +3 -0
  2. package/dist/chat/mentions.d.ts +11 -2
  3. package/dist/chat/mentions.js +57 -18
  4. package/dist/chat/stop-task.d.ts +1 -0
  5. package/dist/chat/stop-task.js +34 -0
  6. package/dist/chat/tag-suggestions.d.ts +3 -1
  7. package/dist/chat/tag-suggestions.js +54 -10
  8. package/dist/chat/ui/ChatActivity.js +20 -42
  9. package/dist/chat/ui/Composer.js +397 -381
  10. package/dist/chat/ui/NamedChip.js +49 -44
  11. package/dist/chat/ui/ReferenceChip.d.ts +2 -1
  12. package/dist/chat/ui/ReferenceChip.js +64 -48
  13. package/dist/chat/ui/chip-clipboard.js +17 -6
  14. package/dist/chat/ui/composer/ComposerMenu.js +28 -24
  15. package/dist/chat/ui/composer/QueuedMessages.d.ts +5 -1
  16. package/dist/chat/ui/composer/QueuedMessages.js +60 -30
  17. package/dist/chat/ui/composer/chips.js +19 -8
  18. package/dist/chat/ui/composer/use-prompt-menus.js +138 -137
  19. package/dist/chat/ui/named-chip-look.d.ts +2 -1
  20. package/dist/chat/ui/named-chip-look.js +18 -8
  21. package/dist/chat/ui/rehype-chips.js +6 -3
  22. package/dist/chat/ui/rows/MessageRows.d.ts +6 -2
  23. package/dist/chat/ui/rows/MessageRows.js +122 -45
  24. package/dist/chat/ui/rows/Rows.js +65 -61
  25. package/dist/chat/waiting-on.d.ts +6 -0
  26. package/dist/chat/waiting-on.js +13 -2
  27. package/dist/host/timeline-row.d.ts +1 -0
  28. package/dist/locales/en/agent-chat.d.ts +4 -0
  29. package/dist/locales/en/agent-chat.js +5 -1
  30. package/dist/locales/nl/agent-chat.d.ts +4 -0
  31. package/dist/locales/nl/agent-chat.js +5 -1
  32. package/package.json +9 -9
  33. package/src/chat/logic/timeline.ts +2 -1
  34. package/src/chat/mentions.ts +69 -18
  35. package/src/chat/stop-task.ts +17 -0
  36. package/src/chat/tag-suggestions.ts +73 -11
  37. package/src/chat/ui/ChatActivity.tsx +2 -10
  38. package/src/chat/ui/Composer.tsx +3 -0
  39. package/src/chat/ui/NamedChip.tsx +10 -10
  40. package/src/chat/ui/ReferenceChip.tsx +4 -1
  41. package/src/chat/ui/chip-clipboard.ts +9 -5
  42. package/src/chat/ui/composer/ComposerMenu.tsx +6 -3
  43. package/src/chat/ui/composer/QueuedMessages.tsx +21 -1
  44. package/src/chat/ui/composer/chips.ts +18 -7
  45. package/src/chat/ui/composer/use-prompt-menus.ts +2 -2
  46. package/src/chat/ui/named-chip-look.ts +19 -8
  47. package/src/chat/ui/rehype-chips.ts +7 -3
  48. package/src/chat/ui/rows/MessageRows.tsx +34 -3
  49. package/src/chat/ui/rows/Rows.tsx +1 -1
  50. package/src/chat/waiting-on.ts +13 -2
  51. package/src/host/timeline-row.ts +1 -1
  52. package/src/locales/en/agent-chat.ts +5 -1
  53. package/src/locales/nl/agent-chat.ts +5 -1
@@ -1,4 +1,4 @@
1
- import { chipText, tokenizeChips, tokenizeNamedReferences, type ChipSegment, type ReferenceToken } from '../mentions';
1
+ import { chipText, namedChipValue, tokenizeChips, tokenizeNamedReferences, type ChipSegment, type ReferenceToken } from '../mentions';
2
2
 
3
3
  /* Just the part of hast this plugin touches; the package's own types are not a dependency here. */
4
4
  interface HastText {
@@ -36,8 +36,12 @@ function valueOf(segment: Exclude<ChipSegment, { kind: 'text' }>): string {
36
36
  return segment.path;
37
37
  }
38
38
 
39
- if (segment.kind === 'model' || segment.kind === 'account') {
40
- return `${segment.cli}/${segment.id}`;
39
+ if (segment.kind === 'model') {
40
+ return namedChipValue(segment.cli, segment.id, segment.account);
41
+ }
42
+
43
+ if (segment.kind === 'account') {
44
+ return namedChipValue(segment.cli, segment.id);
41
45
  }
42
46
 
43
47
  return segment.kind === 'skill' ? segment.name : segment.id;
@@ -48,6 +48,7 @@ import { thoughtLine, thoughtPreview } from '../../logic/thought';
48
48
  import { toolStartedAt, toolSummary, toolSummaryIsPath } from '../../logic/tools';
49
49
  import { presentReferences } from '../../mentions';
50
50
  import { splitQuote } from '../../quote';
51
+ import { useStopTask } from '../../stop-task';
51
52
  import { jumpToTimelineItem } from '../../timeline-scroll';
52
53
  import { copySelectionWithChips } from '../chip-clipboard';
53
54
  import { REFERENCE_TONE, TOKEN_IN_MESSAGE } from '../chips';
@@ -654,18 +655,30 @@ const NOTE_ICON = {
654
655
  error: <Icon icon={CircleAlert} size={12} />
655
656
  };
656
657
 
658
+ interface NoteRowProps {
659
+ id: string;
660
+ level: 'info' | 'warning' | 'error';
661
+ text: string;
662
+ from?: string;
663
+ said?: true;
664
+
665
+ /* The chat the note is in and the background task its message waits for, which the note offers to stop. */
666
+ chatId?: string;
667
+ stops?: string;
668
+ }
669
+
657
670
  /*
658
671
  * A line from the machine in the thread. A note of more than one line (a summary a fork sent back)
659
672
  * shows its first line and folds the rest open as markdown; one that came from a fork leads to it.
660
673
  */
661
- export function NoteRow({ id, level, text, from, said }: { id: string; level: 'info' | 'warning' | 'error'; text: string; from?: string; said?: true }) {
674
+ export function NoteRow({ id, level, text, from, said, chatId, stops }: NoteRowProps) {
662
675
  const { saidBy } = useChatHost();
663
676
 
664
677
  if (said && saidBy !== undefined) {
665
678
  return <HostSaidRow id={id} text={text} author={saidBy} />;
666
679
  }
667
680
 
668
- return <NoteLine id={id} level={level} text={text} from={from} />;
681
+ return <NoteLine id={id} level={level} text={text} from={from} chatId={chatId} stops={stops} />;
669
682
  }
670
683
 
671
684
  /* An item of a newer host this version cannot read: one muted line in its place, with nothing on it to act on. */
@@ -684,7 +697,7 @@ export function UnknownRow({ id, waits }: { id: string; waits: boolean }) {
684
697
  );
685
698
  }
686
699
 
687
- function NoteLine({ id, level, text, from }: { id: string; level: 'info' | 'warning' | 'error'; text: string; from?: string }) {
700
+ function NoteLine({ id, level, text, from, chatId, stops }: Omit<NoteRowProps, 'said'>) {
688
701
  const { t } = useTranslation('agent-chat');
689
702
  const [open, setOpen] = useState(false);
690
703
  const breakAt = text.indexOf('\n');
@@ -712,6 +725,7 @@ function NoteLine({ id, level, text, from }: { id: string; level: 'info' | 'warn
712
725
  </button>
713
726
  )}
714
727
  {from !== undefined && <OpenChatButton chatId={from} label={id.startsWith(WAITING_NOTE_PREFIX) ? 'openWaiting' : 'openFork'} />}
728
+ {chatId !== undefined && stops !== undefined && <StopTaskButton chatId={chatId} taskId={stops} />}
715
729
  </div>
716
730
  {open && rest !== '' && (
717
731
  <div data-find-field="output" className="mt-1 text-text-muted select-text">
@@ -723,6 +737,23 @@ function NoteLine({ id, level, text, from }: { id: string; level: 'info' | 'warn
723
737
  );
724
738
  }
725
739
 
740
+ /* Stop on a note about a message that waits for a background task, for as long as the chat runs that task. */
741
+ function StopTaskButton({ chatId, taskId }: { chatId: string; taskId: string }) {
742
+ const { t } = useTranslation('agent-chat');
743
+ const stop = useStopTask(chatId);
744
+ const runs = useChatRow(chatId, (row) => row?.info.background?.some((task) => task.id === taskId) === true);
745
+
746
+ if (!runs) {
747
+ return null;
748
+ }
749
+
750
+ return (
751
+ <button className="text-text-muted hover:text-text" onClick={() => stop(taskId)}>
752
+ {t('activity.stop')}
753
+ </button>
754
+ );
755
+ }
756
+
726
757
  /* "Open fork" on a note a fork sent, or "Open to answer" on one about a waiting child, while that chat is still in the project. */
727
758
  function OpenChatButton({ chatId, label }: { chatId: string; label: 'openFork' | 'openWaiting' }) {
728
759
  const { t } = useTranslation('agent-chat');
@@ -112,7 +112,7 @@ export function Row({ row, chatId, toggleGroup, toggleTurn, toggleSubagent, open
112
112
  case 'question':
113
113
  return <QuestionHistoryRow item={row.item} />;
114
114
  case 'note':
115
- return <NoteRow id={row.id} level={row.level} text={row.text} from={row.from} said={row.said} />;
115
+ return <NoteRow id={row.id} level={row.level} text={row.text} from={row.from} said={row.said} chatId={chatId} stops={row.stops} />;
116
116
  case 'message':
117
117
  return <SentMessageRow chatId={chatId} id={row.id} message={row.message} />;
118
118
  case 'sent':
@@ -13,6 +13,8 @@ export interface WaitingChild {
13
13
  export interface WaitingOnInput {
14
14
  children?: readonly WaitingChild[];
15
15
  background?: readonly ChatThreadBackgroundTask[];
16
+ /* `ChatThreadInfo.queueHeld`: set while a message of the person waits for work of the process to end. */
17
+ queueHeld?: { task?: string };
16
18
  /* Background subagents and workflows of the CLI's own, counted where the thread is loaded. */
17
19
  subagents?: number;
18
20
  workflows?: number;
@@ -24,14 +26,15 @@ export interface WaitingOnInput {
24
26
 
25
27
  export type WaitingOn =
26
28
  | { kind: 'needs-you'; count: number }
29
+ | { kind: 'queue'; task: ChatThreadBackgroundTask | null }
27
30
  | { kind: 'paused'; until?: number }
28
31
  | { kind: 'command'; task: ChatThreadBackgroundTask }
29
32
  | { kind: 'background'; subagents: number; workflows: number }
30
33
  | { kind: 'plan'; text: string };
31
34
 
32
35
  /*
33
- * The one thing a chat waits on, most pressing first: a child that needs the person, a child paused
34
- * until a time, the oldest command or monitor in the background, background subagents and workflows,
36
+ * The one thing a chat waits on, most pressing first: a child that needs the person, the work a
37
+ * message of the person waits for, a child paused until a time, the oldest command or monitor in the background, background subagents and workflows,
35
38
  * and the plan's status line. Null when it waits on none of them.
36
39
  */
37
40
  export function waitingOnOf(input: WaitingOnInput): WaitingOn | null {
@@ -42,6 +45,12 @@ export function waitingOnOf(input: WaitingOnInput): WaitingOn | null {
42
45
  return { kind: 'needs-you', count: needsYou };
43
46
  }
44
47
 
48
+ if (input.queueHeld !== undefined) {
49
+ const holding = input.queueHeld.task;
50
+
51
+ return { kind: 'queue', task: (input.background ?? []).find((task) => task.id === holding) ?? null };
52
+ }
53
+
45
54
  const paused = children.filter((entry) => entry.paused !== undefined);
46
55
 
47
56
  if (paused.length > 0) {
@@ -78,6 +87,8 @@ export function waitingOnLabel(waiting: WaitingOn, now: number): string {
78
87
  switch (waiting.kind) {
79
88
  case 'needs-you':
80
89
  return t('waitingOn.needsYou', { count: waiting.count });
90
+ case 'queue':
91
+ return waiting.task === null ? t('waitingOn.queueWork') : t('waitingOn.queue', { command: backgroundTaskName(waiting.task) });
81
92
  case 'paused':
82
93
  return waiting.until === undefined ? t('waitingOn.paused') : t('waitingOn.pausedUntil', { time: formatMoment(waiting.until, now) });
83
94
  case 'command':
@@ -58,7 +58,7 @@ export type TimelineRow =
58
58
  | ({ kind: 'subagent' } & SubagentBranch)
59
59
  | { kind: 'approval'; id: string; item: ChatApprovalItem }
60
60
  | { kind: 'question'; id: string; item: ChatQuestionItem }
61
- | { kind: 'note'; id: string; level: 'info' | 'warning' | 'error'; text: string; from?: string; said?: true }
61
+ | { kind: 'note'; id: string; level: 'info' | 'warning' | 'error'; text: string; from?: string; said?: true; stops?: string }
62
62
  // A message another node sent the chat, drawn as said to it under the name of its sender.
63
63
  | { kind: 'message'; id: string; message: ChatNoteMessage; createdAt: number }
64
64
  // A message this chat's agent sent another node with a command of a look, drawn as said instead of as its call.
@@ -440,7 +440,9 @@ export default {
440
440
  alreadySent: 'Already sent',
441
441
  editFailed: 'Could not edit message',
442
442
  sendNow: 'Send now',
443
- paused: 'Queue paused. Send a message or choose Send now.'
443
+ paused: 'Queue paused. Send a message or choose Send now.',
444
+ heldBy: 'Waiting for {{command}} to end',
445
+ heldByWork: 'Waiting for work in the background to end'
444
446
  },
445
447
  quote: {
446
448
  add: 'Quote',
@@ -511,6 +513,8 @@ export default {
511
513
  waitingOn: {
512
514
  needsYou_one: 'A sub-agent needs you',
513
515
  needsYou_other: '{{count}} sub-agents need you',
516
+ queue: 'A message waits for {{command}}',
517
+ queueWork: 'A message waits for work in the background',
514
518
  paused: 'A sub-agent is paused',
515
519
  pausedUntil: 'A sub-agent is paused until {{time}}',
516
520
  command: '{{command}} · {{age}}',
@@ -440,7 +440,9 @@ export default {
440
440
  alreadySent: 'Al verstuurd',
441
441
  editFailed: 'Kon het bericht niet bewerken',
442
442
  sendNow: 'Nu versturen',
443
- paused: 'Wachtrij gepauzeerd. Verstuur een bericht of kies Nu versturen.'
443
+ paused: 'Wachtrij gepauzeerd. Verstuur een bericht of kies Nu versturen.',
444
+ heldBy: 'Wacht tot {{command}} klaar is',
445
+ heldByWork: 'Wacht tot werk op de achtergrond klaar is'
444
446
  },
445
447
  quote: {
446
448
  add: 'Citeren',
@@ -511,6 +513,8 @@ export default {
511
513
  waitingOn: {
512
514
  needsYou_one: 'Een sub-agent vraagt aandacht',
513
515
  needsYou_other: '{{count}} sub-agents vragen aandacht',
516
+ queue: 'Een bericht wacht op {{command}}',
517
+ queueWork: 'Een bericht wacht op werk op de achtergrond',
514
518
  paused: 'Een sub-agent is gepauzeerd',
515
519
  pausedUntil: 'Een sub-agent is gepauzeerd tot {{time}}',
516
520
  command: '{{command}} · {{age}}',