@adecore/agents-react 0.67.0 → 0.68.0

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 (77) hide show
  1. package/dist/agents/AgentIcon.d.ts +7 -0
  2. package/dist/agents/AgentIcon.js +70 -31
  3. package/dist/chat/logic/timeline.d.ts +2 -0
  4. package/dist/chat/logic/timeline.js +47 -0
  5. package/dist/chat/subagent-list.d.ts +1 -2
  6. package/dist/chat/ui/Composer.js +491 -447
  7. package/dist/chat/ui/Markdown.d.ts +1 -1
  8. package/dist/chat/ui/Markdown.js +277 -203
  9. package/dist/chat/ui/PromptEditor.d.ts +3 -1
  10. package/dist/chat/ui/PromptEditor.js +4 -1
  11. package/dist/chat/ui/Timeline.js +5 -4
  12. package/dist/chat/ui/composer/ComposerMenu.js +22 -12
  13. package/dist/chat/ui/composer/chips.d.ts +2 -1
  14. package/dist/chat/ui/composer/chips.js +44 -1
  15. package/dist/chat/ui/composer/key-handler.d.ts +2 -0
  16. package/dist/chat/ui/composer/key-handler.js +12 -2
  17. package/dist/chat/ui/composer/placeholder.d.ts +2 -1
  18. package/dist/chat/ui/composer/placeholder.js +31 -10
  19. package/dist/chat/ui/composer/use-composer-menus.js +49 -39
  20. package/dist/chat/ui/composer/use-prompt-menus.d.ts +10 -7
  21. package/dist/chat/ui/composer/use-prompt-menus.js +183 -157
  22. package/dist/chat/ui/composer/use-prompt-suggestion.d.ts +16 -0
  23. package/dist/chat/ui/composer/use-prompt-suggestion.js +55 -0
  24. package/dist/chat/ui/index.d.ts +1 -1
  25. package/dist/chat/ui/index.js +1 -1
  26. package/dist/chat/ui/markdown-cache.d.ts +4 -0
  27. package/dist/chat/ui/markdown-cache.js +47 -0
  28. package/dist/chat/ui/reference-lookup.d.ts +2 -1
  29. package/dist/chat/ui/reference-lookup.js +1 -1
  30. package/dist/chat/ui/rows/SubagentRow.js +26 -24
  31. package/dist/chat/ui/rows/TaskRow.d.ts +11 -1
  32. package/dist/chat/ui/rows/TaskRow.js +281 -197
  33. package/dist/chat/ui/thread-references.js +12 -9
  34. package/dist/chat-client.d.ts +3 -1
  35. package/dist/chat-client.js +82 -30
  36. package/dist/chat-sink.d.ts +1 -0
  37. package/dist/host/host-hooks.d.ts +4 -1
  38. package/dist/host/host-hooks.js +11 -0
  39. package/dist/host/host.d.ts +18 -0
  40. package/dist/index.d.ts +1 -1
  41. package/dist/locales/en/agent-chat.d.ts +1 -0
  42. package/dist/locales/en/agent-chat.js +2 -1
  43. package/dist/locales/nl/agent-chat.d.ts +1 -0
  44. package/dist/locales/nl/agent-chat.js +2 -1
  45. package/dist/state/chats.d.ts +2 -0
  46. package/dist/state/chats.js +21 -5
  47. package/dist/theme.css +6 -0
  48. package/package.json +9 -9
  49. package/src/agents/AgentIcon.tsx +6 -2
  50. package/src/chat/logic/timeline.ts +63 -0
  51. package/src/chat/subagent-list.ts +1 -4
  52. package/src/chat/ui/Composer.tsx +15 -2
  53. package/src/chat/ui/Markdown.tsx +97 -55
  54. package/src/chat/ui/PromptEditor.tsx +7 -2
  55. package/src/chat/ui/Timeline.tsx +17 -14
  56. package/src/chat/ui/composer/ComposerMenu.tsx +14 -6
  57. package/src/chat/ui/composer/chips.ts +51 -2
  58. package/src/chat/ui/composer/key-handler.ts +17 -2
  59. package/src/chat/ui/composer/placeholder.ts +14 -3
  60. package/src/chat/ui/composer/use-composer-menus.ts +8 -3
  61. package/src/chat/ui/composer/use-prompt-menus.ts +33 -4
  62. package/src/chat/ui/composer/use-prompt-suggestion.ts +36 -0
  63. package/src/chat/ui/index.ts +1 -1
  64. package/src/chat/ui/markdown-cache.ts +60 -0
  65. package/src/chat/ui/reference-lookup.ts +4 -2
  66. package/src/chat/ui/rows/SubagentRow.tsx +1 -1
  67. package/src/chat/ui/rows/TaskRow.tsx +54 -9
  68. package/src/chat/ui/thread-references.ts +4 -2
  69. package/src/chat-client.ts +79 -22
  70. package/src/chat-sink.ts +6 -1
  71. package/src/host/host-hooks.ts +19 -1
  72. package/src/host/host.ts +41 -0
  73. package/src/index.ts +3 -0
  74. package/src/locales/en/agent-chat.ts +2 -1
  75. package/src/locales/nl/agent-chat.ts +2 -1
  76. package/src/state/chats.ts +22 -6
  77. package/src/theme.css +6 -0
@@ -37,7 +37,7 @@ export { uiTableColumns } from './intelligent-ui/table-data.js';
37
37
  export { ForksRow } from './rows/ForksRow.js';
38
38
  export { GeneratedImageRow } from './rows/GeneratedImageRow.js';
39
39
  export { ReportRow, NoteRow, AgentTurnRow, CompactionRow } from './rows/MessageRows.js';
40
- export { TaskRow } from './rows/TaskRow.js';
40
+ export { TaskRow, TaskRowHead } from './rows/TaskRow.js';
41
41
  export { WorkRow, WorkGroupRow, WorkingRow } from './rows/WorkRows.js';
42
42
  export { WorkflowRow } from './rows/WorkflowRow.js';
43
43
  export { WorkflowAgentLine } from './WorkflowAgentLine.js';
@@ -0,0 +1,4 @@
1
+ import type { ReactElement } from 'react';
2
+ import { type Options } from 'react-markdown';
3
+ export declare function parseMarkdown(variant: string | null, options: Options): ReactElement;
4
+ export declare function forgetParsedMarkdown(): void;
@@ -0,0 +1,47 @@
1
+ import ReactMarkdown from 'react-markdown';
2
+ // What the cache may hold, counted in the characters of its keys, which hold the text. A parsed tree
3
+ // takes some tens of bytes per character, so this keeps it to a few tens of megabytes.
4
+ const MAX_CHARACTERS = 500_000;
5
+ const MAX_ENTRIES = 1000;
6
+ const parsed = new Map();
7
+ let characters = 0;
8
+ function remember(key, element) {
9
+ parsed.set(key, element);
10
+ characters += key.length;
11
+ for (const [oldest] of parsed) {
12
+ if (characters <= MAX_CHARACTERS && parsed.size <= MAX_ENTRIES) {
13
+ break;
14
+ }
15
+ parsed.delete(oldest);
16
+ characters -= oldest.length;
17
+ }
18
+ }
19
+ /*
20
+ * Markdown drawn as react-markdown draws it, parsed once for a text a thread showed before, so a
21
+ * thread that mounts again (another chat in the same place, and back) parses none of it. `variant`
22
+ * names everything of `options` besides the text (plugins, their options, components); null leaves
23
+ * the cache out, for text that is still growing. react-markdown's own `Markdown` uses no hooks, so it
24
+ * is called as the function it is, and a parsed tree is the same elements wherever it is drawn: its
25
+ * components read their context when they render.
26
+ */
27
+ export function parseMarkdown(variant, options) {
28
+ if (variant === null) {
29
+ return ReactMarkdown(options);
30
+ }
31
+ const key = `${variant}\u0000${options.children ?? ''}`;
32
+ const known = parsed.get(key);
33
+ if (known !== undefined) {
34
+ // Taken out and put back, so the Map's order stays the order of last use.
35
+ parsed.delete(key);
36
+ parsed.set(key, known);
37
+ return known;
38
+ }
39
+ const element = ReactMarkdown(options);
40
+ remember(key, element);
41
+ return element;
42
+ }
43
+ /* Empties the cache, for a test that counts parses from a clean start. */
44
+ export function forgetParsedMarkdown() {
45
+ parsed.clear();
46
+ characters = 0;
47
+ }
@@ -1,9 +1,10 @@
1
- import type { OutsideReference } from '../../host/host.js';
1
+ import type { HostSkill, OutsideReference } from '../../host/host.js';
2
2
  import type { Referable } from '../../host/references.js';
3
3
  export interface ReferenceLookup {
4
4
  items: readonly Referable[];
5
5
  open: ((id: string) => void) | null;
6
6
  outside?(id: string): OutsideReference | null;
7
7
  referenced?: readonly string[];
8
+ skills?: readonly HostSkill[];
8
9
  }
9
10
  export declare const ReferenceLookupContext: import("react").Context<ReferenceLookup>;
@@ -1,5 +1,5 @@
1
1
  import { createContext } from 'react';
2
- /* What the views and nodes of a message stand for now, handed down by the row that draws it. */
2
+ /* What the views, nodes and host skills of a message stand for now, handed down by the row that draws it. */
3
3
  export const ReferenceLookupContext = createContext({
4
4
  items: [],
5
5
  open: null
@@ -436,7 +436,7 @@ function _temp2(o) {
436
436
  return !o;
437
437
  }
438
438
  export function SubagentRow(t0) {
439
- const $ = _c(24);
439
+ const $ = _c(25);
440
440
  const {
441
441
  chatId,
442
442
  item,
@@ -483,8 +483,9 @@ export function SubagentRow(t0) {
483
483
  const refused = useSubagentSupport(t3);
484
484
  const press = onOpenConversation !== undefined && canOpenSubagent(item, refused) ? onOpenConversation : onToggle;
485
485
  let t4;
486
- if ($[7] !== detail || $[8] !== expanded || $[9] !== item || $[10] !== press || $[11] !== running || $[12] !== t || $[13] !== task) {
486
+ if ($[7] !== chatId || $[8] !== detail || $[9] !== expanded || $[10] !== item || $[11] !== press || $[12] !== running || $[13] !== t || $[14] !== task) {
487
487
  t4 = item.origin === HOST_TASK_ORIGIN ? /*#__PURE__*/_jsx(TaskRow, {
488
+ chatId: chatId,
488
489
  item: item,
489
490
  task: task,
490
491
  open: expanded,
@@ -513,19 +514,20 @@ export function SubagentRow(t0) {
513
514
  })]
514
515
  })
515
516
  });
516
- $[7] = detail;
517
- $[8] = expanded;
518
- $[9] = item;
519
- $[10] = press;
520
- $[11] = running;
521
- $[12] = t;
522
- $[13] = task;
523
- $[14] = t4;
517
+ $[7] = chatId;
518
+ $[8] = detail;
519
+ $[9] = expanded;
520
+ $[10] = item;
521
+ $[11] = press;
522
+ $[12] = running;
523
+ $[13] = t;
524
+ $[14] = task;
525
+ $[15] = t4;
524
526
  } else {
525
- t4 = $[14];
527
+ t4 = $[15];
526
528
  }
527
529
  let t5;
528
- if ($[15] !== chatId || $[16] !== expanded || $[17] !== item || $[18] !== work) {
530
+ if ($[16] !== chatId || $[17] !== expanded || $[18] !== item || $[19] !== work) {
529
531
  t5 = expanded && /*#__PURE__*/_jsxs("div", {
530
532
  className: "mb-1",
531
533
  children: [/*#__PURE__*/_jsx(SubagentWork, {
@@ -537,26 +539,26 @@ export function SubagentRow(t0) {
537
539
  result: item.result
538
540
  })]
539
541
  });
540
- $[15] = chatId;
541
- $[16] = expanded;
542
- $[17] = item;
543
- $[18] = work;
544
- $[19] = t5;
542
+ $[16] = chatId;
543
+ $[17] = expanded;
544
+ $[18] = item;
545
+ $[19] = work;
546
+ $[20] = t5;
545
547
  } else {
546
- t5 = $[19];
548
+ t5 = $[20];
547
549
  }
548
550
  let t6;
549
- if ($[20] !== item.id || $[21] !== t4 || $[22] !== t5) {
551
+ if ($[21] !== item.id || $[22] !== t4 || $[23] !== t5) {
550
552
  t6 = /*#__PURE__*/_jsxs("div", {
551
553
  "data-find-item": item.id,
552
554
  children: [t4, t5]
553
555
  });
554
- $[20] = item.id;
555
- $[21] = t4;
556
- $[22] = t5;
557
- $[23] = t6;
556
+ $[21] = item.id;
557
+ $[22] = t4;
558
+ $[23] = t5;
559
+ $[24] = t6;
558
560
  } else {
559
- t6 = $[23];
561
+ t6 = $[24];
560
562
  }
561
563
  return t6;
562
564
  }
@@ -1,8 +1,18 @@
1
1
  import type { ChatSubagentItem } from '@adecore/agent-contracts';
2
2
  import type { SubagentTask } from '../../../host/host.js';
3
- export declare function TaskRow({ item, task, open, onPress }: {
3
+ interface TaskRowProps {
4
+ chatId: string;
4
5
  item: ChatSubagentItem;
5
6
  task: SubagentTask | null;
6
7
  open: boolean;
7
8
  onPress(): void;
9
+ }
10
+ export declare function TaskRow({ chatId, item, task, open, onPress }: TaskRowProps): string | number | bigint | boolean | import("react").JSX.Element | Iterable<import("react").ReactNode> | Promise<string | number | bigint | boolean | Iterable<import("react").ReactNode> | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | import("react").ReactPortal | null | undefined>;
11
+ export declare function TaskRowHead({ item, task, open, onPress, line }: {
12
+ item: ChatSubagentItem;
13
+ task: SubagentTask | null;
14
+ open: boolean;
15
+ onPress(): void;
16
+ line?: string;
8
17
  }): import("react").JSX.Element;
18
+ export {};